Search in sources :

Example 26 with Predicate

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

the class PredicateTest method createPredicate.

private Predicate createPredicate(String predicate12, Direction out, String testOwner) {
    Predicate predicate1 = new Predicate(predicate12, out);
    predicate1.setOwner(new Type(testOwner));
    return predicate1;
}
Also used : Type(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type) Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate)

Example 27 with Predicate

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

the class PredicateTest method mergeThrowsExceptionIfPredicateOwnerIsNotSet.

@Test(expected = IllegalArgumentException.class)
public void mergeThrowsExceptionIfPredicateOwnerIsNotSet() throws Exception {
    Predicate predicate1 = new Predicate("predicate", Direction.OUT);
    Predicate predicate2 = new Predicate("predicate", Direction.OUT);
    predicate1.merge(predicate2);
}
Also used : Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate) Test(org.junit.Test)

Example 28 with Predicate

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

the class PredicateTest method mergeSetsOwner.

@Test
public void mergeSetsOwner() throws Exception {
    Predicate predicate1 = createPredicate("predicate", Direction.OUT, "testOwner");
    predicate1.setHasBeenList(true);
    predicate1.setSubjectsWithThisPredicateAsList(2);
    Predicate predicate2 = createPredicate("predicate", Direction.OUT, "testOwner");
    predicate2.setHasBeenList(false);
    predicate2.setSubjectsWithThisPredicateAsList(3);
    Predicate mergedPredicate = predicate1.merge(predicate2);
    assertThat(mergedPredicate.getOwner().getName(), Matchers.is("testOwner"));
}
Also used : Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate) Test(org.junit.Test)

Example 29 with Predicate

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

the class PredicateTest method mergeCombinesReferencesMap.

@Test
public void mergeCombinesReferencesMap() throws Exception {
    final Predicate predicate1 = createPredicate("predicate", Direction.OUT, "testOwner");
    Map<String, Long> referenceTypes1 = new HashMap<>();
    referenceTypes1.put("Test Reference", 1L);
    referenceTypes1.put("Test Reference 2", 1L);
    referenceTypes1.put("Test Reference 3", 1L);
    predicate1.setReferenceTypes(referenceTypes1);
    final Predicate predicate2 = createPredicate("predicate", Direction.OUT, "testOwner");
    Map<String, Long> referenceTypes2 = new HashMap<>();
    referenceTypes2.put("Test Reference", 1L);
    referenceTypes2.put("Test Reference 2", 1L);
    predicate2.setReferenceTypes(referenceTypes2);
    Predicate mergedPredicate = predicate1.merge(predicate2);
    assertThat(mergedPredicate.getReferenceTypes(), IsMapContaining.hasEntry("Test Reference", 2L));
    assertThat(mergedPredicate.getReferenceTypes(), IsMapContaining.hasEntry("Test Reference 2", 2L));
    assertThat(mergedPredicate.getReferenceTypes(), IsMapContaining.hasEntry("Test Reference 3", 1L));
}
Also used : HashMap(java.util.HashMap) Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate) Test(org.junit.Test)

Example 30 with Predicate

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

the class PredicateTest method mergeSumsListOccurrences.

@Test
public void mergeSumsListOccurrences() throws Exception {
    Predicate predicate1 = createPredicate("predicate", Direction.OUT, "testOwner");
    predicate1.setHasBeenList(true);
    predicate1.setSubjectsWithThisPredicateAsList(2);
    Predicate predicate2 = createPredicate("predicate", Direction.OUT, "testOwner");
    predicate2.setHasBeenList(false);
    predicate2.setSubjectsWithThisPredicateAsList(3);
    Predicate mergedPredicate = predicate1.merge(predicate2);
    assertThat(mergedPredicate.getSubjectsWithThisPredicateAsList(), Matchers.is(5L));
}
Also used : Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate) Test(org.junit.Test)

Aggregations

Predicate (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate)16 Test (org.junit.Test)12 RdfProcessingFailedException (nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException)6 Type (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 QuadStore (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore)4 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)4 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)4 SAXException (org.xml.sax.SAXException)4 DocumentLoader (com.github.jsonldjava.core.DocumentLoader)3 DatabaseWriteException (nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.DatabaseWriteException)3 CursorQuad (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad)3 Direction (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction)3 StringValue (graphql.language.StringValue)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ChangeType (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.ChangeType)2