Ejemplo n.º 1
0
  @Test
  public void testUserSimplePropertyDiffReplace() throws Exception {
    System.out.println("\n\n===[ testUserSimplePropertyDiffReplace ]===\n");
    // GIVEN
    PrismObjectDefinition<UserType> userDef = getUserTypeDefinition();

    PrismObject<UserType> user1 = userDef.instantiate();
    user1.setOid(USER_JACK_OID);
    user1.setPropertyRealValue(UserType.F_NAME, PrismTestUtil.createPolyString("test name"));

    PrismObject<UserType> user2 = userDef.instantiate();
    user2.setOid(USER_JACK_OID);
    user2.setPropertyRealValue(UserType.F_NAME, PrismTestUtil.createPolyString("other name"));

    // WHEN
    ObjectDelta<UserType> delta = user1.diff(user2);

    // THEN
    assertNotNull(delta);
    System.out.println(delta.debugDump());
    assertEquals("Unexpected number of midifications", 1, delta.getModifications().size());
    PrismAsserts.assertPropertyReplace(
        delta, UserType.F_NAME, PrismTestUtil.createPolyString("other name"));
    assertEquals("Wrong OID", USER_JACK_OID, delta.getOid());
    delta.checkConsistence();
  }
Ejemplo n.º 2
0
  @Test
  public void testContainerValueDiffDesciptionNoPath() throws Exception {
    System.out.println("\n\n===[ testContainerValueDiffDesciptionNoPath ]===\n");

    // GIVEN
    PrismObjectDefinition<UserType> userDef = getUserTypeDefinition();
    PrismContainerDefinition<AssignmentType> assignmentContDef =
        userDef.findContainerDefinition(UserType.F_ASSIGNMENT);

    PrismContainer<AssignmentType> ass1 = assignmentContDef.instantiate();
    PrismContainerValue<AssignmentType> ass1cval = ass1.createNewValue();
    ass1cval.setPropertyRealValue(
        AssignmentType.F_DESCRIPTION, "blah blah", PrismTestUtil.getPrismContext());

    PrismContainer<AssignmentType> ass2 = assignmentContDef.instantiate();
    PrismContainerValue<AssignmentType> ass2cval = ass2.createNewValue();
    ass2cval.setPropertyRealValue(
        AssignmentType.F_DESCRIPTION,
        "chamalalia patlama paprtala",
        PrismTestUtil.getPrismContext());

    // WHEN
    Collection<? extends ItemDelta> modifications = ass1cval.diff(ass2cval);

    // THEN
    assertNotNull(modifications);
    System.out.println(DebugUtil.debugDump(modifications));
    assertEquals("Unexpected number of midifications", 1, modifications.size());
    PrismAsserts.assertPropertyReplace(
        modifications,
        new ItemPath(UserType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION),
        "chamalalia patlama paprtala");
    ItemDelta.checkConsistence(modifications);
  }