Search in sources :

Example 66 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestEditSchema method test263EditShadowSchemaEmpty.

@Test
public void test263EditShadowSchemaEmpty() throws Exception {
    final String TEST_NAME = "test263EditShadowSchemaEmpty";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(null, null);
    IntegrationTestTools.display("Discr", discr);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObjectDefinition<ShadowType> editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME);
    assertNotNull("No definition for name in shadow", nameDef);
    assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName());
    assertTrue("additionalName not readable", nameDef.canRead());
    PrismPropertyDefinition<Object> attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath());
    assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef);
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) PrismObject(com.evolveum.midpoint.prism.PrismObject) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 67 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestEditSchema method test261EditShadowSchemaObjectclass.

@Test
public void test261EditShadowSchemaObjectclass() throws Exception {
    final String TEST_NAME = "test261EditShadowSchemaObjectclass";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, dummyResourceCtl.getAccountObjectClassQName());
    IntegrationTestTools.display("Discr", discr);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObjectDefinition<ShadowType> editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME);
    assertNotNull("No definition for name in shadow", nameDef);
    assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName());
    assertTrue("additionalName not readable", nameDef.canRead());
    PrismPropertyDefinition<Object> attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath());
    assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef);
    assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName());
    assertTrue("additionalName not readable", attrFullNameDef.canRead());
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) PrismObject(com.evolveum.midpoint.prism.PrismObject) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 68 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestUserTemplate method test100ModifyUserGivenName.

@Test
public void test100ModifyUserGivenName() throws Exception {
    final String TEST_NAME = "test100ModifyUserGivenName";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<UserType> userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, prismContext, new PolyString("Jackie"));
    deltas.add(userDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    assertUserJack(userJack, "Jackie Sparrow", "Jackie", "Sparrow");
    PrismAsserts.assertPropertyValue(userJack, UserType.F_DESCRIPTION, "Where's the rum?");
    assertAssignedAccount(userJack, RESOURCE_DUMMY_BLUE_OID);
    assertAssignedNoRole(userJack);
    assertAssignments(userJack, 1);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    UserType userJackType = userJack.asObjectable();
    assertEquals("Unexpected number of accountRefs", 1, userJackType.getLinkRef().size());
    PrismAsserts.assertPropertyValue(userJack, UserType.F_ADDITIONAL_NAME, PrismTestUtil.createPolyString("Jackie"));
    XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
    XMLGregorianCalendar monthLater = XmlTypeConverter.addDuration(now, XmlTypeConverter.createDuration("P1M"));
    assertTrigger(userJack, RecomputeTriggerHandler.HANDLER_URI, monthLater, 100000L);
    // original value of 0 should be gone now, because the corresponding item in user template is marked as non-tolerant
    PrismAsserts.assertPropertyValue(userJack.findContainer(UserType.F_EXTENSION), PIRACY_BAD_LUCK, 123L, 456L);
    // timezone mapping is normal-strength. The source (locality) has not changed. 
    // The mapping should not be activated (MID-3040)
    PrismAsserts.assertNoItem(userJack, UserType.F_TIMEZONE);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 69 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestUserTemplateWithRanges method test210RemoveUnit1.

/**
	 * OrganizationalUnit U1 disappearing + recompute. Computed value of 'OU: U1 ...' should be removed.
	 * Note that condition is true -> true.
	 */
@Test
public void test210RemoveUnit1() throws Exception {
    final String TEST_NAME = "test210RemoveUnit1";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    executeChanges((ObjectDelta) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_ORGANIZATIONAL_UNIT).delete(PolyString.fromOrig("U1")).asObjectDelta(USER_JACK_OID), ModelExecuteOptions.createRaw(), task, result);
    recomputeUser(USER_JACK_OID, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("jack", userJack);
    PrismAsserts.assertPropertyValue(userJack, UserType.F_ORGANIZATIONAL_UNIT, new PolyString("U2", "u2"), new PolyString("U3", "u3"), new PolyString("U4", "u4"));
    PrismAsserts.assertPropertyValue(userJack, UserType.F_ORGANIZATION, new PolyString("O1", "o1"), new PolyString("OU: U2 emp1234", "ou u2 emp1234"), new PolyString("OU: U3 emp1234", "ou u3 emp1234"), new PolyString("OU: U4 emp1234", "ou u4 emp1234"));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 70 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestUserTemplate method test165ModifyUserGivenNameAgainAgain.

@Test
public void test165ModifyUserGivenNameAgainAgain() throws Exception {
    final String TEST_NAME = "test165ModifyUserGivenNameAgainAgain";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    display("User before", userBefore);
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<UserType> userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, prismContext, new PolyString("jackie"));
    deltas.add(userDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    display("User after", userJack);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    // all the values should be gone now, because the corresponding item in user template is marked as non-tolerant
    PrismAsserts.assertNoItem(userJack, new ItemPath(UserType.F_EXTENSION, PIRACY_BAD_LUCK));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

PolyString (com.evolveum.midpoint.prism.polystring.PolyString)168 Test (org.testng.annotations.Test)103 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)90 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)67 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)53 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)44 Task (com.evolveum.midpoint.task.api.Task)41 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)27 PrismObject (com.evolveum.midpoint.prism.PrismObject)21 QName (javax.xml.namespace.QName)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)16 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)15 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)12 ArrayList (java.util.ArrayList)12 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)10 File (java.io.File)10 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)8 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)8