Search in sources :

Example 56 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath 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 57 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class ModelRestService method compare.

@POST
@Path("/rpc/compare")
//	@Produces({"text/html", "application/xml"})
@Consumes({ "application/xml" })
public <T extends ObjectType> Response compare(PrismObject<T> clientObject, @QueryParam("readOptions") List<String> restReadOptions, @QueryParam("compareOptions") List<String> restCompareOptions, @QueryParam("ignoreItems") List<String> restIgnoreItems, @Context MessageContext mc) {
    Task task = RestServiceUtil.initRequest(mc);
    OperationResult result = task.getResult().createSubresult(OPERATION_COMPARE);
    Response response;
    try {
        ResponseBuilder builder;
        List<ItemPath> ignoreItemPaths = ItemPath.fromStringList(restIgnoreItems);
        final GetOperationOptions getOpOptions = GetOperationOptions.fromRestOptions(restReadOptions);
        Collection<SelectorOptions<GetOperationOptions>> readOptions = getOpOptions != null ? SelectorOptions.createCollection(getOpOptions) : null;
        ModelCompareOptions compareOptions = ModelCompareOptions.fromRestOptions(restCompareOptions);
        CompareResultType compareResult = modelService.compareObject(clientObject, readOptions, compareOptions, ignoreItemPaths, task, result);
        response = RestServiceUtil.createResponse(Response.Status.OK, compareResult, result);
    //			builder = Response.ok();
    //			builder.entity(compareResult);
    //
    //			response = builder.build();
    } catch (Exception ex) {
        response = RestServiceUtil.handleException(result, ex);
    }
    result.computeStatus();
    finishRequest(task);
    return response;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 58 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class ModelController method resolve.

private void resolve(Containerable object, SelectorOptions<GetOperationOptions> option, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException {
    if (!GetOperationOptions.isResolve(option.getOptions())) {
        return;
    }
    ObjectSelector selector = option.getSelector();
    if (selector == null) {
        return;
    }
    ItemPath path = selector.getPath();
    ItemPath.checkNoSpecialSymbolsExceptParent(path);
    resolve(object, path, option, task, result);
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 59 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testEmployeeNumberDecimal.

@Test
public void testEmployeeNumberDecimal() throws Exception {
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<Integer>> outputTriple = evaluator.evaluateMappingDynamicReplace("mapping-script-system-variables-employee-number.xml", "testEmployeeNumberString", // target
    new ItemPath(UserType.F_EXTENSION, SchemaTestConstants.EXTENSION_DECIMAL_TYPE_ELEMENT), // changed property
    "employeeNumber", // changed values
    "666.33");
    // THEN
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTriplePlus(outputTriple, new BigDecimal("666.33"));
    PrismAsserts.assertTripleNoMinus(outputTriple);
}
Also used : BigDecimal(java.math.BigDecimal) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 60 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testEmployeeNumberProtectedString.

@Test
public void testEmployeeNumberProtectedString() throws Exception {
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<ProtectedStringType>> outputTriple = evaluator.evaluateMappingDynamicReplace("mapping-script-system-variables-employee-number.xml", "testEmployeeNumberProtectedString", // target
    new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), // changed property
    "employeeNumber", // changed values
    "666");
    // THEN
    evaluator.assertProtectedString("plus set", outputTriple.getPlusSet(), "666");
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTripleNoMinus(outputTriple);
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Aggregations

ItemPath (com.evolveum.midpoint.prism.path.ItemPath)693 Test (org.testng.annotations.Test)184 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)143 QName (javax.xml.namespace.QName)137 Task (com.evolveum.midpoint.task.api.Task)104 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)84 ArrayList (java.util.ArrayList)79 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)68 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)61 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)48 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)46 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)41 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)41 PrismObject (com.evolveum.midpoint.prism.PrismObject)38 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)38 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)33 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)31 NotNull (org.jetbrains.annotations.NotNull)30