@Transactional @Test @Rollback(false) public void testNodeChangeDetectionCreationAddedOnSave() { TestPerson personA = TestPerson.randomPerson(); NodeChangeData changeObject = personA.getMetaData(SharedGraphRepoKeys.NODE_CHANGEDATA_KEY, NodeChangeData.class); assertNull(changeObject); // Saving the node, adds the change detection so that the repo can get changes when it goes to // save. // Attached to the node, it goes out of scope with the node. nodeRepo.save(Arrays.asList(personA)); changeObject = personA.getMetaData(SharedGraphRepoKeys.NODE_CHANGEDATA_KEY, NodeChangeData.class); assertNotNull(changeObject); assertTrue(changeObject.getPropertyKeysChanged().isEmpty()); assertTrue(changeObject.getAddedLinks().isEmpty()); assertTrue(changeObject.getRemovedLinks().isEmpty()); }
@Transactional @Test @Rollback(false) public void testNodeChangeDetectionCreationAddedOnFind() { clearCaches(); TestPerson personA = nodeRepo.findByAppId(TestPerson.class, this.findablePersonId); NodeChangeData changeObject = personA.getMetaData(SharedGraphRepoKeys.NODE_CHANGEDATA_KEY, NodeChangeData.class); assertNotNull(changeObject); assertTrue(changeObject.getPropertyKeysChanged().isEmpty()); assertTrue(changeObject.getAddedLinks().isEmpty()); assertTrue(changeObject.getRemovedLinks().isEmpty()); }
@Transactional @Test @Rollback(false) public void testEdgeChangeDetectionCreationOnLoadingRelations() { clearCaches(); TestPerson foundPerson = nodeRepo.findByAppId(TestPerson.class, findablePersonId); NodeChangeData changeObject = foundPerson.getMetaData(SharedGraphRepoKeys.NODE_CHANGEDATA_KEY, NodeChangeData.class); assertNoChanges(changeObject); Map<String, Set<EdgeLink>> result = foundPerson.getRelationMap().getRelationships(IEdgeMap.Direction.BOTH); for (Set<EdgeLink> links : result.values()) { for (EdgeLink link : links) { EdgeChangeData edgeChangeData = link.getMetaData(SharedGraphRepoKeys.EDGE_CHANGEDATA_KEY, EdgeChangeData.class); assertNoChanges(edgeChangeData); } } }