Search in sources :

Example 81 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class AbstractWebserviceTest method cleanObjects.

private <O extends ObjectType> void cleanObjects(Class<O> type, boolean raw, String... protectedOids) throws FaultMessage {
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    SelectorQualifiedGetOptionsType rootOpts = null;
    ModelExecuteOptionsType execOpts = null;
    if (raw) {
        rootOpts = ModelClientUtil.createRootGetOptions(ModelClientUtil.createRawGetOption());
        execOpts = ModelClientUtil.createRawExecuteOption();
    }
    modelPort.searchObjects(getTypeQName(type), null, rootOpts, objectListHolder, resultHolder);
    List<String> protectedOidList = Arrays.asList(protectedOids);
    ObjectListType objectList = objectListHolder.value;
    for (ObjectType object : objectList.getObject()) {
        if (!protectedOidList.contains(object.getOid())) {
            display("Deleting " + type.getSimpleName() + " " + ModelClientUtil.toString(object));
            deleteObject(type, object.getOid(), execOpts);
        }
    }
}
Also used : Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType)

Example 82 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class ModelWebServiceTest method badPagingSearch.

@Test(expectedExceptions = FaultMessage.class)
public void badPagingSearch() throws FaultMessage, SchemaException, IOException, JAXBException {
    PagingType paging = new PagingType();
    paging.setMaxSize(-1);
    paging.setOffset(-1);
    final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
    setSecurityContext(expectedUser);
    try {
        QueryType queryType = new QueryType();
        queryType.setPaging(paging);
        modelService.searchObjects(UserType.COMPLEX_TYPE, queryType, null, new Holder<ObjectListType>(), new Holder<OperationResultType>());
    } catch (FaultMessage ex) {
        ModelTUtil.assertIllegalArgumentFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
    Assert.fail("Illegal argument exception was not thrown.");
}
Also used : FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Example 83 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class ModelWebServiceTest method nullQueryTypeAndPaging.

//    @Test(expectedExceptions = FaultMessage.class)
public void nullQueryTypeAndPaging() throws FaultMessage, SchemaException, IOException, JAXBException {
    try {
        final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
        setSecurityContext(expectedUser);
        modelService.searchObjects(UserType.COMPLEX_TYPE, null, null, new Holder<ObjectListType>(), new Holder<OperationResultType>());
        Assert.fail("Illegal argument exception was not thrown.");
    } catch (FaultMessage ex) {
        ModelTUtil.assertIllegalArgumentFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
}
Also used : FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File)

Example 84 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class ModelWebServiceTest method testGetNullPropertyRef.

//    @Test(expectedExceptions = FaultMessage.class)
public void testGetNullPropertyRef() throws FaultMessage, SchemaException, IOException, JAXBException {
    final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
    setSecurityContext(expectedUser);
    try {
        modelService.getObject(UserType.COMPLEX_TYPE, "001", null, new Holder<ObjectType>(), new Holder<OperationResultType>());
    } catch (FaultMessage ex) {
        ModelTUtil.assertIllegalArgumentFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
    Assert.fail("get must fail");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File)

Example 85 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class ModelWebServiceTest method nullQueryType.

//    @Test(expectedExceptions = FaultMessage.class)
//    public void testDeleteNullOid() throws FaultMessage {
//        try {
//            modelService.deleteObject(UserType.COMPLEX_TYPE, null);
//        } catch (FaultMessage ex) {
//            ModelTUtil.assertIllegalArgumentFault(ex);
//        }
//        Assert.fail("delete must fail");
//    }
//    @Test(expectedExceptions = FaultMessage.class)
//    public void testDeleteEmptyOid() throws FaultMessage {
//        try {
//            modelService.deleteObject(UserType.COMPLEX_TYPE, "");
//        } catch (FaultMessage ex) {
//            ModelTUtil.assertIllegalArgumentFault(ex);
//        }
//        Assert.fail("delete must fail");
//    }
//    @Test(expectedExceptions = FaultMessage.class)
//    public void testDeleteNonExisting() throws FaultMessage, ObjectNotFoundException, SchemaException, JAXBException, FileNotFoundException {
//        try {
//            final String oid = "abababab-abab-abab-abab-000000000001";
//            when(
//                    repositoryService.getObject(any(Class.class), eq(oid),
//                            any(Collection.class), any(OperationResult.class))).thenThrow(
//                    new ObjectNotFoundException("Object with oid '' not found."));
//
//            final UserType user = PrismTestUtil.unmarshalObject(new File(
//                    TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml"), UserType.class);
//            setSecurityContext(user);
//
//            modelService.deleteObject(UserType.COMPLEX_TYPE, oid);
//        } catch (FaultMessage ex) {
//            ModelTUtil.assertObjectNotFoundFault(ex);
//        } finally {
//            SecurityContextHolder.getContext().setAuthentication(null);
//        }
//        Assert.fail("delete must fail");
//    }
//    @Test(expectedExceptions = FaultMessage.class)
public void nullQueryType() throws FaultMessage, SchemaException, IOException, JAXBException {
    try {
        final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
        setSecurityContext(expectedUser);
        modelService.searchObjects(UserType.COMPLEX_TYPE, null, null, new Holder<ObjectListType>(), new Holder<OperationResultType>());
        Assert.fail("Illegal argument exception was not thrown.");
    } catch (FaultMessage ex) {
        ModelTUtil.assertIllegalArgumentFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
}
Also used : FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File)

Aggregations

OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)46 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)36 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)33 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 Holder (javax.xml.ws.Holder)32 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)25 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)22 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)22 Test (org.testng.annotations.Test)22 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)21 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)16 QName (javax.xml.namespace.QName)15 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 Document (org.w3c.dom.Document)13 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)10 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)10 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)10