Search in sources :

Example 11 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method test802EditSchemaJackPropReadSomeModifySomeUser.

/**
	 * MID-3126
	 */
@Test
public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception {
    final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    cleanupAutzTest(USER_JACK_OID);
    assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID);
    login(USER_JACK_USERNAME);
    ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    display("user before", user);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    ObjectWrapper<UserType> objectWrapper = factory.createObjectWrapper("user display name", "user description", user, ContainerStatus.MODIFYING, task);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    IntegrationTestTools.display("Wrapper after", objectWrapper);
    assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean) objectWrapper.isReadonly());
    ContainerWrapper<UserType> mainContainerWrapper = objectWrapper.findMainContainerWrapper();
    assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) mainContainerWrapper.isReadonly());
    ItemWrapper nameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_NAME);
    assertEquals("Wrong name readOnly", Boolean.TRUE, (Boolean) nameWrapper.isReadonly());
    assertEquals("Wrong name visible", Boolean.TRUE, (Boolean) nameWrapper.isVisible());
    assertEquals("Wrong name definition.canRead", Boolean.TRUE, (Boolean) nameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong name definition.canAdd", Boolean.FALSE, (Boolean) nameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong name definition.canModify", Boolean.FALSE, (Boolean) nameWrapper.getItemDefinition().canModify());
    ItemWrapper givenNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_GIVEN_NAME);
    assertEquals("Wrong givenName readOnly", Boolean.TRUE, (Boolean) givenNameWrapper.isReadonly());
    // Emphasized property. But the role given no access to this. Therefore is should not be visible.
    // MID-3206
    assertEquals("Wrong givenName visible", Boolean.FALSE, (Boolean) givenNameWrapper.isVisible());
    assertEquals("Wrong givenName definition.canRead", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong givenName definition.canAdd", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong givenName definition.canModify", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canModify());
    ItemWrapper fullNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_FULL_NAME);
    assertEquals("Wrong fullName readOnly", Boolean.FALSE, (Boolean) fullNameWrapper.isReadonly());
    assertEquals("Wrong fullName visible", Boolean.TRUE, (Boolean) fullNameWrapper.isVisible());
    assertEquals("Wrong fullName definition.canRead", Boolean.TRUE, (Boolean) fullNameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong fullName definition.canAdd", Boolean.FALSE, (Boolean) fullNameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong fullName definition.canModify", Boolean.TRUE, (Boolean) fullNameWrapper.getItemDefinition().canModify());
    ItemWrapper additionalNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_ADDITIONAL_NAME);
    assertEquals("Wrong additionalName readOnly", Boolean.FALSE, (Boolean) additionalNameWrapper.isReadonly());
    assertEquals("Wrong additionalName visible", Boolean.FALSE, (Boolean) additionalNameWrapper.isVisible());
    assertEquals("Wrong additionalName definition.canRead", Boolean.FALSE, (Boolean) additionalNameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong additionalName definition.canAdd", Boolean.FALSE, (Boolean) additionalNameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong additionalName definition.canModify", Boolean.TRUE, (Boolean) additionalNameWrapper.getItemDefinition().canModify());
    ItemWrapper localityNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_LOCALITY);
    // Is this OK?
    assertEquals("Wrong locality readOnly", Boolean.TRUE, (Boolean) localityNameWrapper.isReadonly());
    assertEquals("Wrong locality visible", Boolean.FALSE, (Boolean) localityNameWrapper.isVisible());
    assertEquals("Wrong locality definition.canRead", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong locality definition.canAdd", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong locality definition.canModify", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canModify());
}
Also used : ItemWrapper(com.evolveum.midpoint.web.component.prism.ItemWrapper) Task(com.evolveum.midpoint.task.api.Task) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 12 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method test220AssignRoleLandluberToWally.

@Test
public void test220AssignRoleLandluberToWally() throws Exception {
    final String TEST_NAME = "test220AssignRoleLandluberToWally";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestIntegrationObjectWrapperFactory.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    DummyGroup mapmakers = new DummyGroup(GROUP_DUMMY_MAPMAKERS_NAME);
    dummyResource.addGroup(mapmakers);
    PrismObject<UserType> user = createUser(USER_WALLY_NAME, USER_WALLY_FULLNAME, true);
    addObject(user);
    userWallyOid = user.getOid();
    assignRole(userWallyOid, ROLE_MAPMAKER_OID, task, result);
    // preconditions
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(userWallyOid);
    display("User after change execution", userAfter);
    accountWallyOid = getSingleLinkOid(userAfter);
    PrismObject<ShadowType> shadow = getShadowModel(accountWallyOid);
    shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy);
    display("Shadow", shadow);
    DummyGroup dummyGroup = dummyResource.getGroupByName(GROUP_DUMMY_MAPMAKERS_NAME);
    assertNotNull("No group on dummy resource", dummyGroup);
    display("Group", dummyGroup);
    assertGroupMember(dummyGroup, USER_WALLY_NAME);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
    ObjectWrapper<ShadowType> objectWrapper = factory.createObjectWrapper("shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING, task);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    display("Wrapper after", objectWrapper);
    WrapperTestUtil.assertWrapper(objectWrapper, "shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING);
    assertEquals("wrong number of containers in " + objectWrapper, 9, objectWrapper.getContainers().size());
    ContainerWrapper attributesContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ATTRIBUTES));
    WrapperTestUtil.assertWrapper(attributesContainerWrapper, "prismContainer.shadow.mainPanelDisplayName", new ItemPath(ShadowType.F_ATTRIBUTES), shadow.findContainer(ShadowType.F_ATTRIBUTES), true, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, dummyResourceCtl.getAttributeFullnameQName(), USER_WALLY_FULLNAME);
    WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, SchemaConstants.ICFS_NAME, USER_WALLY_NAME);
    assertEquals("wrong number of items in " + attributesContainerWrapper, 16, attributesContainerWrapper.getItems().size());
    ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(UserType.F_ACTIVATION));
    WrapperTestUtil.assertWrapper(activationContainerWrapper, "ShadowType.activation", UserType.F_ACTIVATION, shadow, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_LOCKOUT_STATUS, null);
    ContainerWrapper<ShadowAssociationType> associationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ASSOCIATION));
    assertNotNull("No association container wrapper", associationContainerWrapper);
    assertEquals("wrong number of items in " + associationContainerWrapper, 2, associationContainerWrapper.getItems().size());
    ItemWrapper groupAssociationWrapper = associationContainerWrapper.findPropertyWrapper(RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME);
    assertNotNull("No group association property wrapper", groupAssociationWrapper);
    assertTrue("Wrong type of group association property wrapper: " + groupAssociationWrapper.getClass(), groupAssociationWrapper instanceof AssociationWrapper);
    List<ValueWrapper> groupAssociationValues = groupAssociationWrapper.getValues();
    assertEquals("wrong number of values in " + groupAssociationWrapper, 1, groupAssociationValues.size());
    ValueWrapper groupAssociationValue = groupAssociationValues.get(0);
    PrismContainerValue<ShadowAssociationType> groupAssociationValuePVal = (PrismContainerValue<ShadowAssociationType>) groupAssociationValue.getValue();
    display("groupAssociationValuePVal", groupAssociationValuePVal);
    assertEquals("wrong number of values in " + groupAssociationValue, ValueStatus.NOT_CHANGED, groupAssociationValue.getStatus());
    assertEquals("Wrong group association name", RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME, groupAssociationValuePVal.findProperty(ShadowAssociationType.F_NAME).getRealValue());
    PrismContainer<ShadowIdentifiersType> groupAssociationValueIdentifiers = groupAssociationValuePVal.findContainer(ShadowAssociationType.F_IDENTIFIERS);
    PrismProperty<String> groupAssociationUidProp = groupAssociationValueIdentifiers.findProperty(new QName(null, "uid"));
    PrismAsserts.assertPropertyValue(groupAssociationUidProp, GROUP_DUMMY_MAPMAKERS_NAME);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ValueWrapper(com.evolveum.midpoint.web.component.prism.ValueWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ContainerWrapper(com.evolveum.midpoint.web.component.prism.ContainerWrapper) ItemWrapper(com.evolveum.midpoint.web.component.prism.ItemWrapper) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) AssociationWrapper(com.evolveum.midpoint.web.component.prism.AssociationWrapper) ShadowIdentifiersType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowIdentifiersType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 13 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestJaxbConstruction method assertAccountRefs.

private void assertAccountRefs(UserType userType, String... accountOids) {
    List<ObjectReferenceType> accountRefs = userType.getLinkRef();
    assertEquals("Wrong number of accountRefs", accountOids.length, accountRefs.size());
    for (String expectedAccountOid : accountOids) {
        assertAccountRef(accountRefs, expectedAccountOid);
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 14 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestJaxbConstruction method testUserConstructionReverse.

/**
	 * Similar to testUserConstruction, but some operations are done in a different order
	 * e.g. assignment is filled in first then set to the user.
	 */
@Test
public void testUserConstructionReverse() throws JAXBException, SchemaException {
    System.out.println("\n\n ===[ testUserConstructionReverse ]===\n");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    UserType userType = new UserType(prismContext);
    PrismObject<UserType> user = userType.asPrismObject();
    assertNotNull("No object definition after adopt", user.getDefinition());
    // Extension
    ExtensionType extension = new ExtensionType();
    userType.setExtension(extension);
    user.checkConsistence();
    PrismContainer<Containerable> extensionContainer = user.findContainer(GenericObjectType.F_EXTENSION);
    checkExtension(extensionContainer, "user extension after setExtension");
    checkExtension(extension, "user extension after setExtension");
    AssignmentType assignmentType = new AssignmentType(prismContext);
    ExtensionType assignmentExtension = new ExtensionType();
    assignmentType.setExtension(assignmentExtension);
    PrismContainerValue<ExtensionType> assignmentExtensionValueFromJaxb = assignmentExtension.asPrismContainerValue();
    PrismProperty<Integer> intProperty = assignmentExtensionValueFromJaxb.findOrCreateProperty(EXTENSION_INT_TYPE_ELEMENT);
    intProperty.setRealValue(15);
    PrismProperty<String> stringProperty = assignmentExtensionValueFromJaxb.findOrCreateItem(EXTENSION_STRING_TYPE_ELEMENT, PrismProperty.class);
    stringProperty.setRealValue("fifteen men on a dead man chest");
    // Adding assignemnt to the user should cause application of definitions
    userType.getAssignment().add(assignmentType);
    PrismAsserts.assertDefinition(assignmentType.asPrismContainerValue().getParent().getDefinition(), UserType.F_ASSIGNMENT, AssignmentType.COMPLEX_TYPE, 0, -1);
    PrismAsserts.assertDefinition(assignmentExtensionValueFromJaxb.getParent().getDefinition(), AssignmentType.F_EXTENSION, ExtensionType.COMPLEX_TYPE, 0, 1);
    assertTrue("assignment extension definition is not runtime", assignmentExtensionValueFromJaxb.getParent().getDefinition().isRuntimeSchema());
    assertTrue("assignment extension definition is not dynamic", assignmentExtensionValueFromJaxb.getParent().getDefinition().isDynamic());
    PrismAsserts.assertDefinition(intProperty.getDefinition(), EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1);
    PrismAsserts.assertDefinition(stringProperty.getDefinition(), EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1);
    user.assertDefinitions();
    user.checkConsistence();
}
Also used : ExtensionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 15 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestDeltaConverter method testRefWithObject.

@Test
public void testRefWithObject() throws SchemaException, IOException, JAXBException {
    System.out.println("===[ testRefWithObject ]====");
    ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "user-modify-add-account.xml"), ObjectModificationType.COMPLEX_TYPE);
    ObjectDelta<UserType> objectDelta = DeltaConvertor.createObjectDelta(objectChange, UserType.class, getPrismContext());
    System.out.println("delta: " + objectDelta.debugDump());
    assertNotNull("No object delta", objectDelta);
    objectDelta.checkConsistence();
    assertEquals("Wrong OID", "c0c010c0-d34d-b33f-f00d-111111111111", objectDelta.getOid());
    ReferenceDelta accoutRefDelta = objectDelta.findReferenceModification(UserType.F_LINK_REF);
    assertNotNull("No accountRef delta", accoutRefDelta);
    Collection<PrismReferenceValue> valuesToAdd = accoutRefDelta.getValuesToAdd();
    assertEquals("Wrong number of values to add", 1, valuesToAdd.size());
    PrismReferenceValue accountRefVal = valuesToAdd.iterator().next();
    assertNotNull("No object in accountRef value", accountRefVal.getObject());
    objectDelta.assertDefinitions();
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) File(java.io.File) 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