use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType 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.ShadowType in project midpoint by Evolveum.
the class TestDependencies method fillContextWithDummyElaineAccount.
private LensProjectionContext fillContextWithDummyElaineAccount(LensContext<UserType> context, String dummyName, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, IOException, ExpressionEvaluationException {
String resourceOid = getDummyOid(dummyName);
String accountOid = getDummuAccountOid(dummyName, "e");
PrismObject<ShadowType> account = PrismTestUtil.parseObject(ACCOUNT_ELAINE_TEMPLATE_FILE);
ShadowType accountType = account.asObjectable();
accountType.setOid(accountOid);
accountType.getResourceRef().setOid(resourceOid);
provisioningService.applyDefinition(account, task, result);
return fillContextWithAccount(context, account, task, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class PageAccounts method loadShadowOwner.
private <F extends FocusType> F loadShadowOwner(IModel<SelectableBean> model) {
F owner = null;
ShadowType shadow = getShadow(model);
String shadowOid;
if (shadow != null) {
shadowOid = shadow.getOid();
} else {
return null;
}
Task task = createSimpleTask(OPERATION_LOAD_ACCOUNT_OWNER);
OperationResult result = new OperationResult(OPERATION_LOAD_ACCOUNT_OWNER);
try {
PrismObject prismOwner = getModelService().searchShadowOwner(shadowOid, null, task, result);
if (prismOwner != null) {
owner = (F) prismOwner.asObjectable();
}
} catch (ObjectNotFoundException exception) {
//owner was not found, it's possible and it's ok on unlinked accounts
} catch (Exception ex) {
result.recordFatalError(getString("PageAccounts.message.ownerNotFound", shadowOid), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Could not load owner of account with oid: " + shadowOid, ex);
} finally {
result.computeStatusIfUnknown();
}
if (WebComponentUtil.showResultInPage(result)) {
showResult(result, false);
}
return owner;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test150CreateWrapperShadow.
@Test
public void test150CreateWrapperShadow() throws Exception {
final String TEST_NAME = "test150CreateWrapperShadow";
TestUtil.displayTestTile(TEST_NAME);
PrismObject<ShadowType> shadow = getShadowModel(accountJackOid);
shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy);
// WHEN
TestUtil.displayWhen(TEST_NAME);
Task task = taskManager.createTaskInstance(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<ShadowAttributesType> attributesContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ATTRIBUTES));
PrismContainer<ShadowAttributesType> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
WrapperTestUtil.assertWrapper(attributesContainerWrapper, "prismContainer.shadow.mainPanelDisplayName", new ItemPath(ShadowType.F_ATTRIBUTES), attributesContainer, true, ContainerStatus.MODIFYING);
WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, dummyResourceCtl.getAttributeFullnameQName(), USER_JACK_FULL_NAME);
WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, SchemaConstants.ICFS_NAME, USER_JACK_USERNAME);
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);
assertEquals("Wrong attributes container wrapper readOnly", Boolean.FALSE, (Boolean) attributesContainerWrapper.isReadonly());
ItemWrapper fullnameWrapper = attributesContainerWrapper.findPropertyWrapper(dummyResourceCtl.getAttributeFullnameQName());
// Is this OK?
assertEquals("Wrong attribute fullname readOnly", Boolean.FALSE, (Boolean) fullnameWrapper.isReadonly());
assertEquals("Wrong attribute fullname visible", Boolean.TRUE, (Boolean) fullnameWrapper.isVisible());
ItemDefinition fullNameDefinition = fullnameWrapper.getItemDefinition();
display("fullname attribute definition", fullNameDefinition);
assertEquals("Wrong attribute fullname definition.canRead", Boolean.TRUE, (Boolean) fullNameDefinition.canRead());
assertEquals("Wrong attribute fullname definition.canAdd", Boolean.TRUE, (Boolean) fullNameDefinition.canAdd());
assertEquals("Wrong attribute fullname definition.canModify", Boolean.TRUE, (Boolean) fullNameDefinition.canModify());
// MID-3144
if (fullNameDefinition.getDisplayOrder() == null || fullNameDefinition.getDisplayOrder() < 100 || fullNameDefinition.getDisplayOrder() > 400) {
AssertJUnit.fail("Wrong fullname definition.displayOrder: " + fullNameDefinition.getDisplayOrder());
}
assertEquals("Wrong attribute fullname definition.displayName", "Full Name", fullNameDefinition.getDisplayName());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestSchemaRegistry method testCommonSchemaAccountType.
@Test
public void testCommonSchemaAccountType() throws SchemaException, SAXException, IOException {
MidPointPrismContextFactory factory = getContextFactory();
PrismContext context = factory.createInitializedPrismContext();
SchemaRegistry schemaRegistry = context.getSchemaRegistry();
PrismObjectDefinition<ShadowType> accountDef = schemaRegistry.findObjectDefinitionByCompileTimeClass(ShadowType.class);
assertNotNull("No account definition", accountDef);
System.out.println("testCommonSchemaAccountType:");
System.out.println(accountDef.debugDump());
PrismPropertyDefinition nameDef = accountDef.findPropertyDefinition(ShadowType.F_NAME);
assertNotNull("No name definition", nameDef);
PrismContainerDefinition extensionDef = accountDef.findContainerDefinition(ShadowType.F_EXTENSION);
assertNotNull("No 'extension' definition", extensionDef);
assertTrue("'extension' definition is not marked as runtime", extensionDef.isRuntimeSchema());
PrismContainerDefinition attributesDef = accountDef.findContainerDefinition(ShadowType.F_ATTRIBUTES);
assertNotNull("No 'attributes' definition", attributesDef);
assertTrue("'attributes' definition is not marked as runtime", attributesDef.isRuntimeSchema());
}
Aggregations