コード例 #1
0
  @Transactional
  @Test
  @Rollback(false)
  public void testEdgeChangeDetectionCreationAddedOnFind() {

    TestPerson2PersonRelationship link =
        edgeRepo.findByAppId(TestPerson2PersonRelationship.class, this.findableEdgeId);

    EdgeChangeData changeObject =
        link.getMetaData(SharedGraphRepoKeys.EDGE_CHANGEDATA_KEY, EdgeChangeData.class);
    assertNotNull(changeObject);
    assertTrue(changeObject.getPropertyKeysChanged().isEmpty());
  }
コード例 #2
0
  @Transactional
  @Test
  @Rollback(false)
  public void testEdgePropertyChangeDetection() {

    TestPerson personA = TestPerson.randomPerson();
    TestPerson personB = TestPerson.randomPerson();

    nodeRepo.save(Arrays.asList(personA, personB));

    TestPerson2PersonRelationship relationA = new TestPerson2PersonRelationship(personA, personB);
    TestPerson2PersonRelationship relationB = new TestPerson2PersonRelationship(personB, personA);
    TestPerson2PersonRelationship relationC = new TestPerson2PersonRelationship(personB, personA);

    edgeRepo.save(Arrays.asList(relationA, relationB, relationC));

    // -- PERSON A -- Add 1 property --
    EdgeChangeData changeDO = getEdgeChangeData(relationA);
    assertNoChanges(changeDO);

    // Now CHANGE a property...
    relationA.getPropertyMap().put("X", "New Data");
    assertPropertyMapChanged(changeDO, 1);

    // -- PERSON B -- Add 3 property --
    changeDO = getEdgeChangeData(relationB);
    assertNoChanges(changeDO);
    // Now CHANGE a property...
    relationB.getPropertyMap().put("X", "X New Data");
    // The below does not add another...
    relationB.getPropertyMap().put("X", "Same key Changed");
    relationB.getPropertyMap().put("Y", "Y New Data");
    relationB.getPropertyMap().put("Z", "Z New Data");
    assertPropertyMapChanged(changeDO, 3);

    // -- PERSON C -- Remove a property --
    changeDO = getEdgeChangeData(relationC);
    assertNoChanges(changeDO);
    // Now CHANGE a property...
    relationC.getPropertyMap().remove("frequencyOfContact");
    assertPropertyMapChanged(changeDO, 1);
  }