Search in sources :

Example 16 with UserType

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());
}
Also used : ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 17 with UserType

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());
}
Also used : AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 18 with UserType

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());
}
Also used : ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 19 with UserType

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());
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) File(java.io.File) Test(org.testng.annotations.Test)

Example 20 with UserType

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);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Aggregations

UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1275 Test (org.testng.annotations.Test)1093 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1079 Task (com.evolveum.midpoint.task.api.Task)962 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)403 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)379 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)235 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)227 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)224 ArrayList (java.util.ArrayList)138 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)115 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)114 PrismObject (com.evolveum.midpoint.prism.PrismObject)88 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)88 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)85 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)77 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)77 QName (javax.xml.namespace.QName)66 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)64 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)63