Skip to content

Commit 2efc634

Browse files
MODTEMPENG-117: adjust tests
1 parent da8e3b2 commit 2efc634

File tree

10 files changed

+84
-178
lines changed

10 files changed

+84
-178
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2025-XX-XX v1.23.0-SNAPSHOT
2+
* Replace `mod-configuration` with `mod-settings` to get language and locale settings ([MODTEMPENG-117](https://folio-org.atlassian.net/browse/MODTEMPENG-117))
3+
14
## 2025-03-13 v1.22.0
25
* Support barcode image generate for HRID tokens (MODTEMPENG-111)
36
* Upgrade Java and RMB version for Sunflower (FOLIO-4220)

ramls/configuration.json

Lines changed: 0 additions & 53 deletions
This file was deleted.

ramls/configurations.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

ramls/entries.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"type": "object",
3+
"description": "Collection of settings records",
4+
"properties": {
5+
"items": {
6+
"id": "settingsData",
7+
"description": "List of settings records",
8+
"type": "array",
9+
"items": {
10+
"type": "object",
11+
"$ref": "entry.json"
12+
}
13+
},
14+
"resultInfo": {
15+
"$ref": "raml-util/schemas/resultInfo.schema",
16+
"readonly": true
17+
}
18+
},
19+
"additionalProperties": false,
20+
"required": [
21+
"items"
22+
]
23+
}

ramls/entry.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"type": "object",
3+
"description": "Setting",
4+
"properties": {
5+
"id": {
6+
"type": "string",
7+
"description": "setting id",
8+
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
9+
},
10+
"scope": {
11+
"type": "string",
12+
"description": "Scope for this entry (normally a module)"
13+
},
14+
"key": {
15+
"type": "string",
16+
"description": "Key within scope for this setting"
17+
},
18+
"value": {
19+
"description": "Settings value (any type)"
20+
},
21+
"description": {
22+
"type": "string",
23+
"description": "Setting record description"
24+
},
25+
"userId": {
26+
"type": "string",
27+
"description": "User id",
28+
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
29+
}
30+
},
31+
"additionalProperties": false,
32+
"required": [
33+
"id",
34+
"scope",
35+
"key",
36+
"value"
37+
]
38+
}

ramls/template-engine.raml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ types:
1515
templateProcessingRequest: !include templateProcessingRequest.json
1616
templateProcessingResult: !include templateProcessingResult.json
1717
errors: !include raml-util/schemas/errors.schema
18-
configuration: !include configuration.json
19-
configurations: !include configurations.json
18+
item: !include entry.json
19+
settings: !include entries.json
2020

2121
traits:
2222
pageable: !include ./raml-util/traits/pageable.raml

src/main/java/org/folio/template/client/ConfigurationClient.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/main/java/org/folio/template/client/SettingsClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ private Future<JsonObject> lookupSettingsByScopeAndKey(String scope, String key,
4242

4343
LOG.debug("lookupSettingsByScopeAndKey:: Lookup locale settings by scope {} and key {}", scope, key);
4444
String query = format("scope==%s and key==%s", scope, key);
45-
LOG.info("lookupSettingsByScopeAndKey:: Locale settings with scope and key looked up successfully");
4645
return lookupSettingsByQuery(query, limit, offset);
4746
}
4847

@@ -56,7 +55,7 @@ private Future<JsonObject> lookupSettingsByQuery(String query, int limit, int of
5655
throw new OkapiModuleClientException(
5756
format("Error getting locale settings. Status: %d, body: %s", response.statusCode(), response.body()));
5857
}
59-
LOG.info("lookupSettingsByQuery:: Locale settings by query looked up successfully: {}", response.bodyAsJsonObject());
58+
LOG.info("lookupSettingsByQuery:: Locale settings by query looked up successfully.");
6059
return response.bodyAsJsonObject();
6160
});
6261
}
@@ -70,7 +69,7 @@ private LocaleSettings mapToLocaleSettings(JsonObject localeSettings) {
7069
.map(obj -> (JsonObject)obj)
7170
.findFirst()
7271
.orElse(new JsonObject());
73-
LOG.info("mapToLocaleSettings:: Found locale setting: {}", localeSetting);
72+
LOG.debug("mapToLocaleSettings:: Found locale setting: {}", localeSetting);
7473

7574
var valueObj = Optional.ofNullable(localeSetting.getJsonObject("value")).orElse(new JsonObject());
7675
String languageTag = valueObj.getString("locale", DEFAULT_LANGUAGE_TAG);

src/main/java/org/folio/template/service/TemplateServiceImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ public Future<TemplateProcessingResult> processTemplate(TemplateProcessingReques
147147
.withLang(templateRequest.getLang())
148148
.withOutputFormat(templateRequest.getOutputFormat());
149149

150-
LOG.info("processTemplate:: Template processed successfully, body: {}, attachments: {}",
151-
processedTemplate.getBody(), processedTemplate.getAttachments());
150+
LOG.info("processTemplate:: Template processed successfully");
152151

153152
return new TemplateProcessingResult()
154153
.withResult(processedTemplate)

src/test/java/org/folio/rest/impl/TemplateRequestTest.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class TemplateRequestTest {
5353

5454
private static final String TEMPLATE_PATH = "/templates";
5555
private static final String TEMPLATE_REQUEST_PATH = "/template-request";
56-
private static final String CONFIG_REQUEST_PATH = "/configurations/entries";
56+
private static final String SETTINGS_REQUEST_PATH = "/settings/entries";
5757

5858
private static final String TXT_OUTPUT_FORMAT = "txt";
5959
private static final String HTML_OUTPUT_FORMAT = "html";
@@ -1004,22 +1004,25 @@ private Template createTemplateWithMultipleItems() {
10041004
}
10051005

10061006
private void mockConfigModule() {
1007-
Configurations configurations =
1008-
new Configurations().withConfigs(Collections.emptyList()).withTotalRecords(0);
1009-
stubFor(get(urlPathEqualTo(CONFIG_REQUEST_PATH))
1010-
.willReturn(okJson(toJson(mapFrom(configurations)))));
1007+
Settings settings =
1008+
new Settings().withItems(Collections.emptyList());
1009+
stubFor(get(urlPathEqualTo(SETTINGS_REQUEST_PATH))
1010+
.willReturn(okJson(toJson(mapFrom(settings)))));
10111011
}
10121012

10131013
private void mockLocaleSettings(String languageToken, String timezoneId) {
1014-
String localeConfigValue = new JsonObject()
1014+
var localeConfigValue = new JsonObject()
10151015
.put("locale", languageToken)
1016-
.put("timezone", timezoneId).encode();
1016+
.put("timezone", timezoneId);
10171017

1018-
Config config = new Config().withValue(localeConfigValue);
1019-
Configurations configurations =
1020-
new Configurations().withConfigs(Collections.singletonList(config)).withTotalRecords(1);
1018+
Item setting = new Item()
1019+
.withScope("stripes-core.prefs.manage")
1020+
.withKey("tenantLocaleSettings")
1021+
.withValue(localeConfigValue);
1022+
Settings settings =
1023+
new Settings().withItems(Collections.singletonList(setting));
10211024

1022-
stubFor(get(urlPathEqualTo(CONFIG_REQUEST_PATH))
1023-
.willReturn(okJson(toJson(configurations))));
1025+
stubFor(get(urlPathEqualTo(SETTINGS_REQUEST_PATH))
1026+
.willReturn(okJson(toJson(settings))));
10241027
}
10251028
}

0 commit comments

Comments
 (0)