use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.
the class ModelWebServiceTest method getNonexistingObject.
@Test(expectedExceptions = FaultMessage.class)
public void getNonexistingObject() throws FaultMessage, ObjectNotFoundException, SchemaException, IOException, JAXBException {
final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
setSecurityContext(expectedUser);
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 '" + oid + "' not found."));
modelService.getObject(UserType.COMPLEX_TYPE, oid, new SelectorQualifiedGetOptionsType(), new Holder<ObjectType>(), new Holder<OperationResultType>());
} catch (FaultMessage ex) {
ModelTUtil.assertObjectNotFoundFault(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 nonExistingUidModify.
@Test(expectedExceptions = FaultMessage.class)
public void nonExistingUidModify() throws FaultMessage, ObjectNotFoundException, SchemaException, JAXBException, IOException {
final String oid = "1";
ObjectDeltaType objectDeltaType = new ObjectDeltaType();
objectDeltaType.setChangeType(ChangeTypeType.MODIFY);
objectDeltaType.setObjectType(UserType.COMPLEX_TYPE);
objectDeltaType.setOid(oid);
ItemDeltaType mod1 = new ItemDeltaType();
mod1.setModificationType(ModificationTypeType.ADD);
// ItemDeltaType.Value value = new ItemDeltaType.Value();
// value.getAny().add(DOMUtil.createElement(DOMUtil.getDocument(), new QName(SchemaConstants.NS_C, "fullName")));
mod1.setPath(new ItemPathType(new ItemPath(UserType.F_FULL_NAME)));
objectDeltaType.getItemDelta().add(mod1);
when(repositoryService.getObject(any(Class.class), eq(oid), any(Collection.class), any(OperationResult.class))).thenThrow(new ObjectNotFoundException("Oid '" + oid + "' not found."));
final UserType user = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
setSecurityContext(user);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(objectDeltaType);
try {
modelService.executeChanges(deltaListType, null);
} catch (FaultMessage ex) {
ModelTUtil.assertObjectNotFoundFault(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 ControllerAddObjectTest method addResourceCorrect.
// @Test
@SuppressWarnings("unchecked")
public void addResourceCorrect() throws JAXBException, FaultMessage, ObjectAlreadyExistsException, SchemaException, CommunicationException, ObjectNotFoundException, ExpressionEvaluationException, IOException, ConfigurationException, PolicyViolationException, SecurityViolationException {
TestUtil.displayTestTile("addResourceCorrect");
Task task = taskManager.createTaskInstance();
final PrismObject<ResourceType> expectedResource = PrismTestUtil.parseObject(new File(TEST_FOLDER, "add-resource-correct.xml"));
final ResourceType expectedResourceType = expectedResource.asObjectable();
AssertJUnit.assertNotNull("resource to add must not be null", expectedResource);
final String oid = "abababab-abab-abab-abab-000000000002";
when(provisioning.addObject(argThat(new ObjectTypeNameMatcher(expectedResourceType.getName())), any(OperationProvisioningScriptsType.class), any(ProvisioningOperationOptions.class), any(Task.class), any(OperationResult.class))).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
PrismObject<ResourceType> resource = (PrismObject<ResourceType>) invocation.getArguments()[0];
PrismAsserts.assertEquivalent("Wrong argument to addObject", expectedResource, resource);
return oid;
}
});
OperationResult result = new OperationResult("Test Operation");
try {
String resourceOid = controller.addObject(expectedResource, null, task, result);
assertEquals(oid, resourceOid);
} finally {
LOGGER.debug(result.debugDump());
verify(provisioning, times(1)).addObject(argThat(new ObjectTypeNameMatcher(expectedResourceType.getName())), any(OperationProvisioningScriptsType.class), any(ProvisioningOperationOptions.class), any(Task.class), any(OperationResult.class));
}
}
use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.
the class Action method handleError.
protected void handleError(String message, Exception ex) throws Exception {
STD_ERR.info(message);
STD_ERR.info("Error occurred: {}", ex.getMessage());
if (ex instanceof FaultMessage) {
FaultMessage faultMessage = (FaultMessage) ex;
FaultType fault = faultMessage.getFaultInfo();
if (fault != null && fault.getOperationResult() != null) {
OperationResultType result = fault.getOperationResult();
STD_ERR.info("Operation result: {}", result.getMessage());
if (getParams().isVerbose()) {
try {
STD_ERR.debug(ToolsUtils.serializeObject(result));
} catch (JAXBException e) {
STD_ERR.debug("Couldn't serialize operation result, reason: {}", e.getMessage());
}
}
}
}
if (getParams().isVerbose()) {
STD_ERR.debug("Error details", ex);
}
throw ex;
}
use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.
the class BulkAction method executeAction.
@Override
protected void executeAction() throws Exception {
ModelPortType port = createModelPort();
try {
ExecuteScriptsOptionsType options = new ExecuteScriptsOptionsType();
options.setExecuteAsynchronously(getParams().isAsync());
options.setObjectLimit(getParams().getLimit());
options.setOutputFormat(getParams().getOutput());
ExecuteScriptsType parameters = new ExecuteScriptsType();
parameters.setOptions(options);
parameters.setMslScripts(getParams().getMslScript());
//todo implement xml support
//parameters.setXmlScripts(xml);
ExecuteScriptsResponseType response = port.executeScripts(parameters);
//todo implement
} catch (FaultMessage ex) {
handleError("Couldn't execute scripts", ex);
}
}
Aggregations