Search in sources :

Example 6 with ExplicitField

use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.ExplicitField in project timbuctoo by HuygensING.

the class MergeExplicitSchemasTest method mergeExplicitSchemaMergesFieldsForSameCollection.

@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://timbuctoo.huygens.knaw.nl/datasets/clusius/Places", Lists.newArrayList(explicitField1));
    Map<String, List<ExplicitField>> explicitSchema2 = new HashMap<>();
    ExplicitField explicitField2 = new ExplicitField("test:test2", false, null, Sets.newHashSet("String"));
    explicitSchema2.put("http://timbuctoo.huygens.knaw.nl/datasets/clusius/Places", Lists.newArrayList(explicitField2));
    MergeExplicitSchemas mergeExplicitSchemas = new MergeExplicitSchemas();
    Map<String, List<ExplicitField>> mergedExplicitSchema = mergeExplicitSchemas.mergeExplicitSchemas(explicitSchema1, explicitSchema2);
    assertThat(mergedExplicitSchema, hasKey("http://timbuctoo.huygens.knaw.nl/datasets/clusius/Places"));
    assertThat(mergedExplicitSchema.get("http://timbuctoo.huygens.knaw.nl/datasets/clusius/Places"), containsInAnyOrder(explicitField1, explicitField2));
}
Also used : ExplicitField(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.ExplicitField) HashMap(java.util.HashMap) List(java.util.List) MergeExplicitSchemas(nl.knaw.huygens.timbuctoo.v5.graphql.customschema.MergeExplicitSchemas) Test(org.junit.Test)

Example 7 with ExplicitField

use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.ExplicitField in project timbuctoo by HuygensING.

the class MergeExplicitSchemasTest method mergeExplicitSchemaMergesFieldWithSameUriForSameCollection.

@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://timbuctoo.huygens.knaw.nl/datasets/clusius/Places", Lists.newArrayList(explicitField1));
    Map<String, List<ExplicitField>> explicitSchema2 = new HashMap<>();
    ExplicitField explicitField2 = new ExplicitField("test:test1", false, Sets.newHashSet("Integer"), null);
    explicitSchema2.put("http://timbuctoo.huygens.knaw.nl/datasets/clusius/Places", Lists.newArrayList(explicitField2));
    MergeExplicitSchemas mergeExplicitSchemas = new MergeExplicitSchemas();
    Map<String, List<ExplicitField>> mergedExplicitSchema = mergeExplicitSchemas.mergeExplicitSchemas(explicitSchema1, explicitSchema2);
    assertThat(mergedExplicitSchema, hasKey("http://timbuctoo.huygens.knaw.nl/datasets/clusius/Places"));
    MatcherAssert.assertThat(mergedExplicitSchema.get("http://timbuctoo.huygens.knaw.nl/datasets/clusius/Places"), Matchers.contains(ExplicitFieldMatcher.explicitField().withValues(Sets.newHashSet("Integer", "String"))));
}
Also used : ExplicitField(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.ExplicitField) HashMap(java.util.HashMap) List(java.util.List) MergeExplicitSchemas(nl.knaw.huygens.timbuctoo.v5.graphql.customschema.MergeExplicitSchemas) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)6 List (java.util.List)6 ExplicitField (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.ExplicitField)6 MergeExplicitSchemas (nl.knaw.huygens.timbuctoo.v5.graphql.customschema.MergeExplicitSchemas)4 Map (java.util.Map)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)2 ExplicitType (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.ExplicitType)2 Type (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type)2 MergeSchemas (nl.knaw.huygens.timbuctoo.v5.graphql.customschema.MergeSchemas)2 Test (org.junit.Test)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Charsets (com.google.common.base.Charsets)1 Resources (com.google.common.io.Resources)1 Resources.getResource (com.google.common.io.Resources.getResource)1 GraphQLSchema (graphql.schema.GraphQLSchema)1 RuntimeWiring (graphql.schema.idl.RuntimeWiring)1 SchemaGenerator (graphql.schema.idl.SchemaGenerator)1