### Question:
MergeExplicitSchemas { public MergeExplicitSchemas() { } MergeExplicitSchemas(); Map<String, List<ExplicitField>> mergeExplicitSchemas(Map<String, List<ExplicitField>> explicitSchema1,
                                                               Map<String, List<ExplicitField>> explicitSchema2);  }### Answer:
@Test public void mergeeExplicitSchemaMergesSchemasWithDifferentCollections() throws Exception { Map<String, List<ExplicitField>> explicitSchema1 = new HashMap<>(); ExplicitField explicitField1 = new ExplicitField("test:test1", false, Sets.newHashSet("String"), null); explicitSchema1.put("http: Map<String, List<ExplicitField>> explicitSchema2 = new HashMap<>(); ExplicitField explicitField2 = new ExplicitField("test:test2", false, null, Sets.newHashSet("String")); explicitSchema2.put("http: MergeExplicitSchemas mergeExplicitSchemas = new MergeExplicitSchemas(); Map<String, List<ExplicitField>> mergedExplicitSchema = mergeExplicitSchemas.mergeExplicitSchemas( explicitSchema1, explicitSchema2 ); Map<String, List<ExplicitField>> expectedMergedSchema = new HashMap<>(); expectedMergedSchema.put("http: Lists.newArrayList(explicitField1)); expectedMergedSchema.put("http: Lists.newArrayList(explicitField2)); assertThat(mergedExplicitSchema, is(expectedMergedSchema)); }
@Test public void mergeExplicitSchemaMergesFieldsForSameCollection() throws Exception { Map<String, List<ExplicitField>> explicitSchema1 = new HashMap<>(); ExplicitField explicitField1 = new ExplicitField("test:test1", false, Sets.newHashSet("String"), null); explicitSchema1.put("http: Map<String, List<ExplicitField>> explicitSchema2 = new HashMap<>(); ExplicitField explicitField2 = new ExplicitField("test:test2", false, null, Sets.newHashSet("String")); explicitSchema2.put("http: MergeExplicitSchemas mergeExplicitSchemas = new MergeExplicitSchemas(); Map<String, List<ExplicitField>> mergedExplicitSchema = mergeExplicitSchemas.mergeExplicitSchemas( explicitSchema1, explicitSchema2 ); assertThat(mergedExplicitSchema, hasKey("http: assertThat(mergedExplicitSchema.get("http: containsInAnyOrder(explicitField1, explicitField2)); }
@Test public void mergeExplicitSchemaMergesFieldWithSameUriForSameCollection() throws Exception { Map<String, List<ExplicitField>> explicitSchema1 = new HashMap<>(); ExplicitField explicitField1 = new ExplicitField("test:test1", false, Sets.newHashSet("String"), null); explicitSchema1.put("http: Map<String, List<ExplicitField>> explicitSchema2 = new HashMap<>(); ExplicitField explicitField2 = new ExplicitField("test:test1", false, Sets.newHashSet("Integer"), null); explicitSchema2.put("http: MergeExplicitSchemas mergeExplicitSchemas = new MergeExplicitSchemas(); Map<String, List<ExplicitField>> mergedExplicitSchema = mergeExplicitSchemas.mergeExplicitSchemas( explicitSchema1, explicitSchema2 ); assertThat(mergedExplicitSchema, hasKey("http: MatcherAssert.assertThat(mergedExplicitSchema.get("http: Matchers.contains(ExplicitFieldMatcher.explicitField().withValues(Sets.newHashSet("Integer", "String")))); }