use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestDiffEquals method testUserSimplePropertyDiff.
@Test
public void testUserSimplePropertyDiff() throws SchemaException {
System.out.println("\n\n===[ testUserSimplePropertyDiff ]===\n");
UserType userType1 = new UserType();
userType1.setName(PrismTestUtil.createPolyStringType("test name"));
UserType userType2 = new UserType();
userType2.setName(PrismTestUtil.createPolyStringType("test name"));
PrismTestUtil.getPrismContext().adopt(userType1);
PrismTestUtil.getPrismContext().adopt(userType2);
ObjectDelta delta = userType1.asPrismObject().diff(userType2.asPrismObject());
assertNotNull(delta);
assertEquals(0, delta.getModifications().size());
userType2.setDescription(null);
delta = userType1.asPrismObject().diff(userType2.asPrismObject());
assertNotNull(delta);
assertEquals("Delta should be empty, nothing changed.", 0, delta.getModifications().size());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestDiffEquals method testContextlessAssignmentEquals2.
@Test
public void testContextlessAssignmentEquals2() throws Exception {
System.out.println("\n\n===[ testContextlessAssignmentEquals2 ]===\n");
// (1) user without prismContext - the functionality is reduced
UserType user = new UserType();
// no prismContext here
AssignmentType a1 = new AssignmentType();
a1.setDescription("descr1");
user.getAssignment().add(a1);
// no prismContext here
AssignmentType a2 = new AssignmentType();
a2.setDescription("descr2");
user.getAssignment().add(a2);
AssignmentType a2identical = new AssignmentType();
a2identical.setDescription("descr2");
assertTrue(user.getAssignment().contains(a2identical));
// delta1 is without prismContext
ObjectDelta delta1 = user.asPrismObject().createDelta(ChangeType.DELETE);
assertNull(delta1.getPrismContext());
// (2) user with prismContext
UserType userWithContext = new UserType(PrismTestUtil.getPrismContext());
// no prismContext here
AssignmentType b1 = new AssignmentType();
b1.setDescription("descr1");
userWithContext.getAssignment().add(b1);
// no prismContext here
AssignmentType b2 = new AssignmentType();
b2.setDescription("descr2");
userWithContext.getAssignment().add(b2);
AssignmentType b2identical = new AssignmentType();
b2identical.setDescription("descr2");
assertTrue(user.getAssignment().contains(b2identical));
// b1 and b2 obtain context when they are added to the container
assertNotNull(b1.asPrismContainerValue().getPrismContext());
assertNotNull(b2.asPrismContainerValue().getPrismContext());
assertFalse(b1.equals(b2));
ObjectDelta delta2 = userWithContext.asPrismObject().createDelta(ChangeType.DELETE);
assertNotNull(delta2.getPrismContext());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestDiffEquals method testUserListSimpleDiff.
@Test
public void testUserListSimpleDiff() throws SchemaException {
System.out.println("\n\n===[ testUserListSimpleDiff ]===\n");
UserType u1 = new UserType();
u1.setName(PrismTestUtil.createPolyStringType("test name"));
UserType u2 = new UserType();
u2.setName(PrismTestUtil.createPolyStringType("test name"));
PrismTestUtil.getPrismContext().adopt(u1);
PrismTestUtil.getPrismContext().adopt(u2);
ObjectDelta delta = u1.asPrismObject().diff(u2.asPrismObject());
assertNotNull(delta);
assertEquals(0, delta.getModifications().size());
u2.getAdditionalName();
delta = u1.asPrismObject().diff(u2.asPrismObject());
assertNotNull(delta);
assertEquals("Delta should be empty, nothing changed.", 0, delta.getModifications().size());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestJaxbSanity method testAssignmentEquals.
@Test
public void testAssignmentEquals() throws JAXBException, SchemaException, FileNotFoundException {
System.out.println("\n\n ===[testAssnignmentEquals]===\n");
// GIVEN
JAXBElement<UserType> userEl1 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME), UserType.class);
UserType user = userEl1.getValue();
assertNotNull(user);
AssignmentType userAssignmentType = user.getAssignment().get(0);
assertNotNull(userAssignmentType);
System.out.println("\n*** user assignment");
System.out.println(PrismTestUtil.serializeAnyDataWrapped(userAssignmentType));
JAXBElement<ObjectModificationType> modEl = JaxbTestUtil.getInstance().unmarshalElement(new File(TEST_DIR, "user-barbossa-modify-delete-assignment-account-opendj-attr.xml"), ObjectModificationType.class);
ObjectModificationType mod = modEl.getValue();
assertNotNull(mod);
//FIXME : modification value -> rawType...
RawType rawType = mod.getItemDelta().get(0).getValue().get(0);
ItemDefinition assignmentDefinition = PrismTestUtil.getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AssignmentType.class);
assertNotNull(assignmentDefinition);
AssignmentType assignmentType = ((PrismContainerValue<AssignmentType>) rawType.getParsedValue(assignmentDefinition, null)).getValue();
// was: (JAXBElement<AssignmentType>) mod.getItemDelta().get(0).getValue().get(0).getContent().get(0);
assertNotNull(assignmentType);
System.out.println("\n*** assignment");
System.out.println(PrismTestUtil.serializeAnyDataWrapped(assignmentType));
// WHEN, THEN
assertTrue("Assignment not equals", userAssignmentType.equals(assignmentType));
assertTrue("HashCode does not match", userAssignmentType.hashCode() == assignmentType.hashCode());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestMappingTime method testNoReferenceTime.
@Test
public void testNoReferenceTime() throws Exception {
final String TEST_NAME = "testNoReferenceTime";
System.out.println("===[ " + TEST_NAME + "]===");
// GIVEN
PrismObject<UserType> userOld = evaluator.getUserOld();
userOld.asObjectable().getActivation().setDisableTimestamp(null);
Mapping.Builder<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> builder = evaluator.createMappingBuilder(MAPPING_TIME_ACTIVATION, TEST_NAME, "title", null, userOld);
builder.setNow(TIME_PAST);
PrismPropertyDefinition<Boolean> existenceDef = new PrismPropertyDefinitionImpl<>(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, evaluator.getPrismContext());
builder.setDefaultTargetDefinition(existenceDef);
Mapping<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> mapping = builder.build();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mapping.getOutputTriple();
assertNullTriple(outputTriple);
assertNextRecompute(mapping, null);
}
Aggregations