use of nl.knaw.huygens.timbuctoo.core.dto.CreateEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntityThrowsAnIoExceptionWhenItEncountersAnUnknownProperty.
@Test(expected = IOException.class)
public void createEntityThrowsAnIoExceptionWhenItEncountersAnUnknownProperty() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
final Collection collection = vres.getCollection("testthings").get();
final TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
properties.add(new StringProperty("prop1", "val1"));
properties.add(new StringProperty("unknowProp", "val2"));
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntitySetsTheRevToOne.
// TODO move the TimbuctooActions
@Test
public void createEntitySetsTheRevToOne() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).has("rev", 1).hasNext(), is(true));
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntityAddsAnEntityWithItsPropertiesToTheDatabase.
@Test
public void createEntityAddsAnEntityWithItsPropertiesToTheDatabase() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
final Collection collection = vres.getCollection("testthings").get();
final TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
properties.add(new StringProperty("prop1", "val1"));
properties.add(new StringProperty("prop2", "val2"));
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).has("testthing_prop1", "val1").has("testthing_prop2", "val2").hasNext(), is(true));
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntitySetsCreatedAndModified.
@Test
public void createEntitySetsCreatedAndModified() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
String userId = "userId";
long timeStamp = Instant.now().toEpochMilli();
CreateEntity createEntity = withProperties(properties, userId, timeStamp);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).next().value("created"), sameJSONAs(String.format("{\"timeStamp\": %s,\"userId\": \"%s\"}", timeStamp, userId)));
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).next().value("modified"), sameJSONAs(String.format("{\"timeStamp\": %s,\"userId\": \"%s\"}", timeStamp, userId)));
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntitySetsTypesWithTheCollectionAndTheBaseCollection.
@Test
public void createEntitySetsTypesWithTheCollectionAndTheBaseCollection() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).next().value("types"), allOf(containsString("testthing"), containsString("thing")));
}
Aggregations