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