Skip to content

Commit

Permalink
Merge pull request #483 from commercetools/fix-localizedstring-locale…
Browse files Browse the repository at this point in the history
…values
  • Loading branch information
jenschude authored Sep 7, 2023
2 parents 4c51dff + a91eaa9 commit cd3ebe7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
15 changes: 9 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ tasks.register('internaldocs', Javadoc) {
setAuthor false
noTimestamp = true
splitIndex = true
docTitle 'commercetools-java-sdks'
links 'https://docs.oracle.com/javase/8/docs/api/', "https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/${versions.jackson}/", 'https://commercetools.github.io/commercetools-jvm-sdk/apidocs/'
noTree = true
title = "commercetools Java SDK"
links 'https://docs.oracle.com/javase/8/docs/api/', "https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/${versions.jackson}/", 'https://commercetools.github.io/commercetools-jvm-sdk/apidocs/', 'https://newrelic.github.io/java-agent-api/javadoc/'
overview = "src/main/javadoc/overview.html"
bottom = """
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/styles/default.min.css">
Expand All @@ -301,13 +302,14 @@ tasks.register('internaldocs', Javadoc) {
<script src="{@docRoot}/resources/javascripts/main.js"></script>
<link rel="stylesheet" href="{@docRoot}/resources/stylesheets/main.css">
"""
taglets = ['com.commercetools.taglets.CodeTaglet','com.commercetools.taglets.ToCTaglet', 'com.commercetools.taglets.FileIncludeTaglet', 'org.jdrupes.taglets.plantUml.StartUml', 'org.jdrupes.taglets.plantUml.EndUml', 'org.jdrupes.taglets.plantUml.PlantUml']
taglets = ['com.commercetools.taglets.CodeTaglet', 'com.commercetools.taglets.ToCTaglet', 'com.commercetools.taglets.FileIncludeTaglet', 'org.jdrupes.taglets.plantUml.StartUml', 'org.jdrupes.taglets.plantUml.EndUml', 'org.jdrupes.taglets.plantUml.PlantUml']
tagletPath = configurations.taglet.files as List
maxMemory = '2g'
encoding = 'utf-8'
excludes = ['com/commercetools/graphql/api/client/**', 'com/commercetools/graphql/api/Dgs**','com/commercetools/graphql/api/types/**', 'com/commercetools/api/predicates/query/**/*Dsl.java', 'com/commercetools/**/*Impl.java']
addBooleanOption('-allow-script-in-comments', true)
addStringOption('Xdoclint:missing,accessibility,reference', '-quiet')
addBooleanOption('linksource', true)
// addBooleanOption('linksource', true)
encoding = 'utf-8'
groups = [
"API" : ["com.commercetools.api.*"],
"History" : ["com.commercetools.history.*"],
Expand All @@ -317,7 +319,8 @@ tasks.register('internaldocs', Javadoc) {
"HTTP Clients" : [
"com.commercetools.http.*",
"io.vrap.rmf.okhttp.*"
]
],
"Monitoring" : ["com.commercetools.monitoring.*"]
]
addStringOption('source', '8')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ default <T> T withLocalizedString(Function<LocalizedString, T> helper) {
@NotNull
@JsonIgnore
default public Map<Locale, String> localeValues() {
return values().entrySet().stream().collect(Collectors.toMap(e -> new Locale(e.getKey()), Map.Entry::getValue));
return values().entrySet()
.stream()
.collect(Collectors.toMap(e -> Locale.forLanguageTag(e.getKey()), Map.Entry::getValue));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,15 @@ public void deserializeWithFullLocale() {
assertThat(JsonUtils.toJsonNode(localizedString)).isEqualTo(JsonUtils.parse(FULL_LOCALE_JSON_STRING));
}

@Test
public void deserializeWithFullLocaleLocaleValues() {
final LocalizedString localizedString = JsonUtils.fromJsonString(FULL_LOCALE_JSON_STRING,
LocalizedString.class);
assertThat(localizedString.localeValues().get(Locale.US)).isEqualTo("kids");
assertThat(localizedString.localeValues().get(Locale.UK)).isEqualTo("children");

}

@Test
public void ofStringToStringMap() {
final Map<String, String> map = new HashMap<>();
Expand Down

0 comments on commit cd3ebe7

Please sign in to comment.