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());
}
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);
}
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);
}
}
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();
}
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();
}
Aggregations