use of com.evolveum.midpoint.model.impl.util.ObjectTypeNameMatcher 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.model.impl.util.ObjectTypeNameMatcher in project midpoint by Evolveum.
the class ControllerAddObjectTest method addUserCorrect.
/**
* Testing add user with undefined user template
*/
// @Test
@SuppressWarnings("unchecked")
public void addUserCorrect() throws Exception {
TestUtil.displayTestTile("addUserCorrect");
// GIVEN
Task task = taskManager.createTaskInstance();
ModelTUtil.mockGetSystemConfiguration(repository, new File(TEST_FOLDER_COMMON, "system-configuration.xml"));
final PrismObject<UserType> expectedUser = PrismTestUtil.parseObject(new File(TEST_FOLDER, "add-user-correct.xml"));
final UserType expectedUserType = expectedUser.asObjectable();
final String oid = "abababab-abab-abab-abab-000000000001";
when(repository.addObject(argThat(new ObjectTypeNameMatcher(expectedUserType.getName())), any(RepoAddOptions.class), any(OperationResult.class))).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
PrismObject<UserType> user = (PrismObject<UserType>) invocation.getArguments()[0];
IntegrationTestTools.display("Got user", user);
PrismAsserts.assertEquivalent("Unexpected argument to addObject", expectedUser, user);
return oid;
}
});
OperationResult result = new OperationResult("Test Operation");
// WHEN
String userOid = controller.addObject(expectedUser, null, task, result);
// THEN
display("addObject result", result.debugDump());
verify(repository, times(1)).addObject(argThat(new ObjectTypeNameMatcher(expectedUserType.getName())), any(RepoAddOptions.class), any(OperationResult.class));
assertEquals(oid, userOid);
}
Aggregations