use of nl.knaw.huygens.timbuctoo.core.dto.CreateRelation in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method acceptRelationCallTheChangeListener.
@Test
public void acceptRelationCallTheChangeListener() throws Exception {
ChangeListener changeListener = mock(ChangeListener.class);
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testrelations").get();
UUID typeId = UUID.randomUUID();
UUID sourceId = UUID.randomUUID();
UUID targetId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(typeId.toString()).withType("relationtype").withProperty("relationtype_regularName", "regularName").withProperty("rev", 1).withProperty("isLatest", true)).withVertex(v -> v.withTimId(sourceId.toString()).withProperty("rev", 1).withVre("test").withType("thing").withProperty("isLatest", true)).withVertex(v -> v.withTimId(targetId.toString()).withProperty("rev", 1).withVre("test").withType("thing").withProperty("isLatest", true)).wrap();
TinkerPopOperations instance = forGraphMappingsAndChangeListener(graphManager, vres, changeListener);
CreateRelation createRelation = new CreateRelation(sourceId, typeId, targetId);
createRelation.setCreated(new Change(Instant.now().toEpochMilli(), "userId", null));
instance.acceptRelation(collection, createRelation);
verify(changeListener).onCreateEdge(argThat(is(sameInstance(collection))), argThat(is(likeEdge().withSourceWithId(sourceId).withTargetWithId(targetId).withTypeId(typeId))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateRelation in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method acceptRelationThrowsARelationNotPossibleExceptionIfTheSourceIsNotInTheRightVre.
@Test(expected = RelationNotPossibleException.class)
public void acceptRelationThrowsARelationNotPossibleExceptionIfTheSourceIsNotInTheRightVre() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testrelations").get();
UUID typeId = UUID.randomUUID();
UUID sourceId = UUID.randomUUID();
UUID targetId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(typeId.toString()).withType("relationtype").withProperty("relationtype_regularName", "regularName").withProperty("rev", 1).withProperty("isLatest", true)).withVertex(v -> v.withTimId(sourceId.toString()).withProperty("rev", 1).withVre("other").withType("thing").withProperty("isLatest", true)).withVertex(v -> v.withTimId(targetId.toString()).withProperty("rev", 1).withVre("test").withType("thing").withProperty("isLatest", true)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
CreateRelation createRelation = new CreateRelation(sourceId, typeId, targetId);
createRelation.setCreated(new Change(Instant.now().toEpochMilli(), "userId", null));
instance.acceptRelation(collection, createRelation);
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateRelation in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method acceptRelationSetsTheCreatedInformation.
@Test
public void acceptRelationSetsTheCreatedInformation() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testrelations").get();
UUID typeId = UUID.randomUUID();
UUID sourceId = UUID.randomUUID();
UUID targetId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(typeId.toString()).withType("relationtype").withProperty("relationtype_regularName", "regularName").withProperty("rev", 1).withProperty("isLatest", true)).withVertex(v -> v.withTimId(sourceId.toString()).withProperty("rev", 1).withVre("test").withType("thing").withProperty("isLatest", true)).withVertex(v -> v.withTimId(targetId.toString()).withProperty("rev", 1).withVre("test").withType("thing").withProperty("isLatest", true)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
CreateRelation createRelation = new CreateRelation(sourceId, typeId, targetId);
long timeStamp = Instant.now().toEpochMilli();
String userId = "userId";
createRelation.setCreated(new Change(timeStamp, userId, null));
UUID relId = instance.acceptRelation(collection, createRelation);
Edge newEdge = graphManager.getGraph().traversal().E().has("tim_id", relId.toString()).next();
assertThat(getModificationInfo("modified", newEdge), is(jsnO("timeStamp", jsn(timeStamp), "userId", jsn(userId))));
assertThat(getModificationInfo("created", newEdge), is(jsnO("timeStamp", jsn(timeStamp), "userId", jsn(userId))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateRelation in project timbuctoo by HuygensING.
the class TimbuctooActionsRelationTest method setUp.
@Before
public void setUp() throws Exception {
clock = mock(Clock.class);
instant = Instant.now();
when(clock.instant()).thenReturn(instant);
createRelation = new CreateRelation(null, null, null);
collection = mock(Collection.class);
dataStoreOperations = mock(DataStoreOperations.class);
}
Aggregations