Search in sources :

Example 61 with PolyString

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

the class TestEditSchema method test210UserDefinition.

@Test
public void test210UserDefinition() throws Exception {
    final String TEST_NAME = "test210UserDefinition";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObject<UserType> user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {

        @Override
        public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
            assertNotNull("No definition for additionalName in user", propDef);
            assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName());
            assertTrue("additionalName not readable", propDef.canRead());
        }
    }, PrismTestUtil.createPolyString("Jackie"));
    assertPropertyValues(user, UserType.F_COST_CENTER, new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertNotNull("No definition for costCenter in user", propDef);
            assertEquals("Wrong costCenter displayOrder", (Integer) 123, propDef.getDisplayOrder());
            assertTrue("costCenter not readable", propDef.canRead());
        }
    });
    assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertNotNull("No definition for preferredLanguage in user", propDef);
            assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName());
            assertTrue("preferredLanguage not readable", propDef.canRead());
            PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef();
            assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
            assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
        }
    });
    assertContainer(user, UserType.F_CREDENTIALS, new Validator<PrismContainerDefinition<CredentialsType>>() {

        @Override
        public void validate(PrismContainerDefinition<CredentialsType> credentialsDef, String name) throws Exception {
            assertNotNull("No definition for credentials in user", credentialsDef);
            assertTrue("Credentials not readable", credentialsDef.canRead());
        }
    }, true);
    assertProperty(user, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertTrue("Password not readable", propDef.canRead());
        }
    });
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 62 with PolyString

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

the class TestEditSchema method assertUntouchedUserDefinition.

private void assertUntouchedUserDefinition() {
    // WHEN
    PrismObjectDefinition<UserType> userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
    // THEN
    PrismPropertyDefinition<PolyString> descriptionDef = userDefinition.findPropertyDefinition(UserType.F_DESCRIPTION);
    assertNotNull("No definition for description in user", descriptionDef);
    assertEquals("Wrong description displayName", "ObjectType.description", descriptionDef.getDisplayName());
    assertTrue("description not readable", descriptionDef.canRead());
    assertTrue("description not creatable", descriptionDef.canAdd());
    assertTrue("description not modifiable", descriptionDef.canModify());
    PrismPropertyDefinition<PolyString> additionalNameDef = userDefinition.findPropertyDefinition(UserType.F_ADDITIONAL_NAME);
    assertNotNull("No definition for additionalName in user", additionalNameDef);
    assertEquals("Wrong additionalName displayName", "UserType.additionalName", additionalNameDef.getDisplayName());
    assertTrue("additionalName not readable", additionalNameDef.canRead());
    assertTrue("additionalName not creatable", additionalNameDef.canAdd());
    assertTrue("additionalName not modifiable", additionalNameDef.canModify());
    PrismPropertyDefinition<String> costCenterDef = userDefinition.findPropertyDefinition(UserType.F_COST_CENTER);
    assertNotNull("No definition for costCenter in user", costCenterDef);
    assertEquals("Wrong costCenter displayOrder", (Integer) 420, costCenterDef.getDisplayOrder());
    assertTrue("costCenter not readable", costCenterDef.canRead());
    assertTrue("costCenter not creatable", costCenterDef.canAdd());
    assertTrue("costCenter not modifiable", costCenterDef.canModify());
    PrismReferenceValue valueEnumerationRef = costCenterDef.getValueEnumerationRef();
    assertNull("valueEnumerationRef for costCente sneaked in", valueEnumerationRef);
    PrismPropertyDefinition<String> preferredLanguageDef = userDefinition.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE);
    assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef);
    assertEquals("Wrong preferredLanguage displayName", "UserType.preferredLanguage", preferredLanguageDef.getDisplayName());
    assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead());
    assertTrue("preferredLanguage not creatable", preferredLanguageDef.canAdd());
    assertTrue("preferredLanguage not modifiable", preferredLanguageDef.canModify());
    valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef();
    assertNotNull("valueEnumerationRef for preferredLanguage missing", valueEnumerationRef);
    assertEquals("wrong OID in valueEnumerationRef for preferredLanguage missing", SystemObjectsType.LOOKUP_LANGUAGES.value(), valueEnumerationRef.getOid());
    PrismContainerDefinition<CredentialsType> credentialsDef = userDefinition.findContainerDefinition(UserType.F_CREDENTIALS);
    assertNotNull("No definition for credentials in user", credentialsDef);
    assertTrue("Credentials not readable", credentialsDef.canRead());
    assertTrue("Credentials not creatable", credentialsDef.canAdd());
    assertTrue("Credentials not modifiable", credentialsDef.canModify());
    ItemPath passwdValPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE);
    PrismPropertyDefinition<ProtectedStringType> passwdValDef = userDefinition.findPropertyDefinition(passwdValPath);
    assertNotNull("No definition for " + passwdValPath + " in user", passwdValDef);
    assertTrue("Password not readable", passwdValDef.canRead());
    assertTrue("Password not creatable", passwdValDef.canAdd());
    assertTrue("Password not modifiable", passwdValDef.canModify());
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 63 with PolyString

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

the class TestEditSchema method test810OtisGetJack.

@Test
public void test810OtisGetJack() throws Exception {
    final String TEST_NAME = "test810OtisGetJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    login(USER_OTIS_USERNAME);
    Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObject<UserType> user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertPropertyValues(user, UserType.F_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {

        @Override
        public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
            assertNotNull("No definition for name in user", propDef);
            assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName());
            assertTrue(name + " not readable", propDef.canRead());
            assertTrue(name + " is creatable", !propDef.canAdd());
            assertTrue(name + " is modifiable", !propDef.canModify());
        }
    }, PrismTestUtil.createPolyString("jack"));
    assertPropertyValues(user, UserType.F_DESCRIPTION, new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertNotNull("No definition for description in user", propDef);
            assertEquals("Wrong description displayName", "Comment", propDef.getDisplayName());
            assertTrue(name + " not readable", propDef.canRead());
            assertTrue(name + " is creatable", !propDef.canAdd());
            assertTrue(name + " not modifiable", propDef.canModify());
        }
    }, "Where's the rum?");
    assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {

        @Override
        public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
            assertNotNull("No definition for additionalName in user", propDef);
            assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName());
            assertTrue(name + " is readable", !propDef.canRead());
            assertTrue(name + " is creatable", !propDef.canAdd());
            assertTrue(name + " not modifiable", propDef.canModify());
        }
    });
    assertPropertyValues(user, UserType.F_COST_CENTER, new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertNotNull("No definition for costCenter in user", propDef);
            assertEquals("Wrong costCenter displayOrder", (Integer) 123, propDef.getDisplayOrder());
            assertTrue(name + " is readable", !propDef.canRead());
            assertTrue(name + " is creatable", !propDef.canAdd());
            assertTrue(name + " is modifiable", !propDef.canModify());
        }
    });
    assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertNotNull("No definition for preferredLanguage in user", propDef);
            assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName());
            PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef();
            assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
            assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
            assertTrue(name + " is readable", !propDef.canRead());
            assertTrue(name + " is creatable", !propDef.canAdd());
            assertTrue(name + " is modifiable", !propDef.canModify());
        }
    });
    PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS);
    assertUntouchedUserDefinition();
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 64 with PolyString

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

the class TestEditSchema method test265EditShadowSchemaNull.

@Test
public void test265EditShadowSchemaNull() throws Exception {
    final String TEST_NAME = "test265EditShadowSchemaNull";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObjectDefinition<ShadowType> editDef = modelInteractionService.getEditShadowDefinition(null, 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) PrismObject(com.evolveum.midpoint.prism.PrismObject) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 65 with PolyString

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

the class TestEditSchema method test213ModifiedUserJack.

/**
     * Modify jack, see if the schema still applies.
     */
@Test
public void test213ModifiedUserJack() throws Exception {
    final String TEST_NAME = "test213ModifiedUserJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR");
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObject<UserType> user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {

        @Override
        public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
            assertNotNull("No definition for additionalName in user", propDef);
            assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName());
            assertTrue("additionalName not readable", propDef.canRead());
        }
    }, PrismTestUtil.createPolyString("Jackie"));
    assertPropertyValues(user, UserType.F_COST_CENTER, new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertNotNull("No definition for costCenter in user", propDef);
            assertEquals("Wrong costCenter displayOrder", (Integer) 123, propDef.getDisplayOrder());
            assertTrue("costCenter not readable", propDef.canRead());
        }
    }, // This is set by user template
    "G001");
    assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertNotNull("No definition for preferredLanguage in user", propDef);
            assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName());
            assertTrue("preferredLanguage not readable", propDef.canRead());
            PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef();
            assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
            assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
        }
    }, "en_PR");
    assertContainer(user, UserType.F_CREDENTIALS, new Validator<PrismContainerDefinition<CredentialsType>>() {

        @Override
        public void validate(PrismContainerDefinition<CredentialsType> credentialsDef, String name) throws Exception {
            assertNotNull("No definition for credentials in user", credentialsDef);
            assertTrue("Credentials not readable", credentialsDef.canRead());
        }
    }, true);
    assertProperty(user, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), new Validator<PrismPropertyDefinition<String>>() {

        @Override
        public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
            assertTrue("Password not readable", propDef.canRead());
        }
    });
    assertUntouchedUserDefinition();
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) 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