use of nl.knaw.huygens.timbuctoo.core.dto.property.StringProperty in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method replaceEntityPreparesABackupCopyAfterMakingTheChanges.
@Test
public void replaceEntityPreparesABackupCopyAfterMakingTheChanges() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id).withVre("test").withType("thing").withProperty("isLatest", true).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList(new StringProperty("prop1", "newValue"));
UpdateEntity updateEntity = new UpdateEntity(id, properties, 1);
long timeStamp = Instant.now().toEpochMilli();
updateEntity.setModified(new Change(timeStamp, "userId", null));
Vertex beforeUpdate = graphManager.getGraph().traversal().V().has("tim_id", id.toString()).has("isLatest", true).next();
instance.replaceEntity(collection, updateEntity);
Vertex afterUpdate = graphManager.getGraph().traversal().V().has("tim_id", id.toString()).has("isLatest", true).next();
assertThat(afterUpdate.id(), is(not(beforeUpdate.id())));
assertThat(afterUpdate.edges(Direction.IN).next().outVertex().id(), is(beforeUpdate.id()));
}
use of nl.knaw.huygens.timbuctoo.core.dto.property.StringProperty 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.property.StringProperty 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.property.StringProperty in project timbuctoo by HuygensING.
the class TriplePropertyConverterTest method toAddsThePropertyNameToTheLeftOfTheTuple.
@Test
public void toAddsThePropertyNameToTheLeftOfTheTuple() throws Exception {
Tuple<String, List<Triple>> to = instance.to(new StringProperty(PROP_NAME, "stringValue"));
assertThat(to.getLeft(), is(PROP_NAME));
}
use of nl.knaw.huygens.timbuctoo.core.dto.property.StringProperty in project timbuctoo by HuygensING.
the class TriplePropertyConverterTest method toCreatesATripleWithAValueForAString.
@Test
public void toCreatesATripleWithAValueForAString() throws Exception {
Tuple<String, List<Triple>> to = instance.to(new StringProperty(PROP_NAME, "stringValue"));
assertThat(to.getRight(), contains(allOf(hasProperty("subject", is(SUBJECT_URI)), hasProperty("predicate", endsWith(PROP_NAME)), hasProperty("object", is("stringValue")))));
}
Aggregations