Skip to content

Commit ffb04b4

Browse files
author
Grace Calianese
committed
resolve merge conflicts
1 parent c3c9a7c commit ffb04b4

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

examples/src/main/java/com/basistech/rosette/examples/RecordSimilarityExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private void run() throws IOException {
9797
).build();
9898

9999
HttpRosetteAPI rosetteAPI = new HttpRosetteAPI.Builder()
100-
.key(getApiKeyFromSystemProperty())
100+
.key("b1db524b37ad4b75f86729999d6017fd")
101101
.url(getAltUrlFromSystemProperty())
102102
.build();
103103
//The api object creates an http client, but to provide your own:

json/src/test/java/com/basistech/rosette/apimodel/recordsimilarity/RecordSimilarityResponseTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import com.fasterxml.jackson.databind.SerializationFeature;
3131
import org.junit.jupiter.api.Test;
3232

33+
import java.util.ArrayList;
34+
import java.util.Arrays;
3335
import java.util.List;
3436
import java.util.Map;
3537

@@ -39,7 +41,7 @@ public class RecordSimilarityResponseTest {
3941

4042
private static final ObjectMapper MAPPER = ApiModelMixinModule.setupObjectMapper(new ObjectMapper());
4143

42-
private static final String EXPECTED_JSON = "{\"fields\":{\"addr\":{\"type\":\"rni_address\",\"weight\":0.3},\"dob\":{\"type\":\"rni_date\",\"weight\":0.2},\"primaryName\":{\"type\":\"rni_name\",\"weight\":0.5}},\"results\":[{\"explainInfo\":{\"leftOnlyFields\":[\"addr\"],\"scoredFields\":{\"dob\":{\"calculatedWeight\":0.2857142857142857,\"finalScore\":0.74,\"rawScore\":0.8,\"weight\":0.5},\"primaryName\":{\"calculatedWeight\":0.7142857142857143,\"details\":\"any details\",\"finalScore\":0.85,\"rawScore\":0.99,\"weight\":0.5}}},\"left\":{\"addr\":{\"address\":\"123 Roadlane Ave\"},\"dob\":{\"date\":\"1993-04-16\"},\"primaryName\":{\"entityType\":\"PERSON\",\"language\":\"eng\",\"languageOfOrigin\":\"eng\",\"script\":\"Latn\",\"text\":\"Ethan R\"}},\"right\":{\"dob\":\"1993-04-16\",\"primaryName\":{\"text\":\"Seth R\"}},\"score\":0.87},{\"error\":\"Field foo not found in field mapping\",\"left\":{\"addr\":{\"address\":\"123 Roadlane Ave\"},\"dob\":{\"date\":\"1993-04-16\"},\"primaryName\":{\"entityType\":\"PERSON\",\"language\":\"eng\",\"languageOfOrigin\":\"eng\",\"script\":\"Latn\",\"text\":\"Ethan R\"}},\"right\":{\"dob\":\"1993-04-16\",\"primaryName\":{\"text\":\"Seth R\"}}}]}";
44+
private static final String EXPECTED_JSON = "{\"fields\":{\"addr\":{\"scoreIfNull\":0.8,\"type\":\"rni_address\",\"weight\":0.3},\"dob\":{\"type\":\"rni_date\",\"weight\":0.2},\"primaryName\":{\"type\":\"rni_name\",\"weight\":0.5}},\"info\":[\"Field threshold not found in properties! Defaulting to 0.0\",\"Field weight not found in fields! Defaulting to 1.0 for all entries\"],\"results\":[{\"error\":[],\"explainInfo\":{\"leftOnlyFields\":[\"addr\"],\"scoredFields\":{\"dob\":{\"calculatedWeight\":0.2857142857142857,\"finalScore\":0.74,\"rawScore\":0.8,\"weight\":0.5},\"primaryName\":{\"calculatedWeight\":0.7142857142857143,\"details\":\"any details\",\"finalScore\":0.85,\"rawScore\":0.99,\"weight\":0.5}}},\"left\":{\"addr\":{\"houseNumber\":\"123\",\"road\":\"Roadlane Ave\"},\"dob\":{\"date\":\"1993-04-16\"},\"primaryName\":{\"entityType\":\"PERSON\",\"language\":\"eng\",\"languageOfOrigin\":\"eng\",\"script\":\"Latn\",\"text\":\"Ethan R\"}},\"right\":{\"dob\":\"1993-04-16\",\"primaryName\":{\"text\":\"Seth R\"}},\"score\":0.87},{\"error\":[\"Field foo not found in field mapping\"],\"info\":[\"Some info message\",\"Some other info message\"],\"left\":{\"addr\":{\"houseNumber\":\"123\",\"road\":\"Roadlane Ave\"},\"dob\":{\"date\":\"1993-04-16\"},\"primaryName\":{\"entityType\":\"PERSON\",\"language\":\"eng\",\"languageOfOrigin\":\"eng\",\"script\":\"Latn\",\"text\":\"Ethan R\"}},\"right\":{\"dob\":\"1993-04-16\",\"primaryName\":{\"text\":\"Seth R\"}}}]}";
4345

4446
private static final RecordSimilarityResponse EXPECTED_RESPONSE;
4547

@@ -100,6 +102,7 @@ public class RecordSimilarityResponseTest {
100102
.build()
101103
))
102104
.build())
105+
.error(new ArrayList<>())
103106
.build(),
104107
RecordSimilarityResult.builder()
105108
.left(Map.of("primaryName", NameField.FieldedName.builder()
@@ -121,7 +124,7 @@ public class RecordSimilarityResponseTest {
121124
"dob", DateField.UnfieldedDate.builder()
122125
.date("1993-04-16")
123126
.build()))
124-
.error(Arrays.AsList("Field foo not found in field mapping"))
127+
.error(Arrays.asList("Field foo not found in field mapping"))
125128
.info(List.of("Some info message", "Some other info message"))
126129
.build()))
127130
.info(List.of(
@@ -137,8 +140,12 @@ public class RecordSimilarityResponseTest {
137140

138141
@Test
139142
public void testDeserialization() throws JsonProcessingException {
143+
// For testing, force ordering
144+
MAPPER.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
145+
MAPPER.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
140146
final RecordSimilarityResponse response = MAPPER.readValue(EXPECTED_JSON, RecordSimilarityResponse.class);
141-
assertEquals(EXPECTED_RESPONSE, response);
147+
assertEquals(MAPPER.writeValueAsString(EXPECTED_RESPONSE), MAPPER.writeValueAsString(response));
148+
// assertEquals(EXPECTED_RESPONSE, response);
142149
}
143150

144151
@Test

0 commit comments

Comments
 (0)