use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.
the class TestIteration method test820SubtypeSetByInbound.
/**
* MID-5618: When subtype is set by inbound, wrong iterator is used.
*/
@Test
public void test820SubtypeSetByInbound() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
setDefaultObjectTemplate(UserType.COMPLEX_TYPE, null);
setDefaultObjectTemplate(UserType.COMPLEX_TYPE, "associate", USER_TEMPLATE_ITERATION_ASSOCIATE_OID, result);
DummyResourceContoller associateCtl = dummyResourceCollection.get("associate");
// should be imported as jim-0
associateCtl.addAccount("u1", "jim");
// should be imported as jim-1
associateCtl.addAccount("u2", "jim");
ObjectQuery query = prismContext.queryFor(ShadowType.class).item(ShadowType.F_RESOURCE_REF).ref(RESOURCE_DUMMY_ASSOCIATE_OID).and().item(ShadowType.F_OBJECT_CLASS).eq(SchemaConstants.RI_ACCOUNT_OBJECT_CLASS).build();
SearchResultList<PrismObject<ShadowType>> shadows = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
display("shadows", shadows);
assertEquals("Wrong # of shadows", 2, shadows.size());
// WHEN
when();
importFromResourceLauncher.importSingleShadow(shadows.get(0).getOid(), task, result);
importFromResourceLauncher.importSingleShadow(shadows.get(1).getOid(), task, result);
// THEN
then();
assertSuccess(result);
ObjectQuery userQuery = prismContext.queryFor(UserType.class).item(UserType.F_SUBTYPE).eq("associate").asc(UserType.F_NAME).build();
SearchResultList<PrismObject<UserType>> usersAfter = repositoryService.searchObjects(UserType.class, userQuery, null, result);
display("users", usersAfter);
assertEquals("Wrong # of created users", 2, usersAfter.size());
assertEquals("Wrong name of user 1", "jim-0", usersAfter.get(0).getName().getOrig());
assertEquals("Wrong name of user 2", "jim-1", usersAfter.get(1).getName().getOrig());
}
use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.
the class TestWriter method initSystem.
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
DummyResourceContoller writerDummyController = DummyResourceContoller.create(RESOURCE_WRITER_DUMMY_NAME);
writerDummyController.extendSchemaPirate();
dummyResourceCollection.initDummyResource(RESOURCE_WRITER_DUMMY_NAME, writerDummyController);
PrismObject<ResourceType> resourceWriter = importAndGetObjectFromFile(ResourceType.class, RESOURCE_WRITER_FILE, RESOURCE_WRITER_OID, initTask, initResult);
writerDummyController.setResource(resourceWriter);
}
use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.
the class AbstractProvisioningIntegrationTest method initDummyResource.
protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, FailableProcessor<DummyResourceContoller> controllerInitLambda, OperationResult result) throws Exception {
DummyResourceContoller controller = DummyResourceContoller.create(name);
if (controllerInitLambda != null) {
controllerInitLambda.process(controller);
} else {
controller.populateWithDefaultSchema();
}
if (resourceFile != null) {
addResourceFromFile(resourceFile, IntegrationTestTools.DUMMY_CONNECTOR_TYPE, result);
}
if (resourceOid != null) {
PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, resourceOid, null, result);
controller.setResource(resource);
}
return controller;
}
use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.
the class DummyResourceCollection method initDummyResource.
public DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, FailableProcessor<DummyResourceContoller> controllerInitLambda, Task task, OperationResult result) throws Exception {
if (map.containsKey(name)) {
throw new IllegalArgumentException("Dummy resource " + name + " already initialized");
}
DummyResourceContoller controller = DummyResourceContoller.create(name);
if (controllerInitLambda != null) {
controllerInitLambda.process(controller);
} else {
controller.populateWithDefaultSchema();
}
if (resourceFile != null) {
LOGGER.info("Importing {}", resourceFile);
modelService.importObjectsFromFile(resourceFile, null, task, result);
OperationResult importResult = result.getLastSubresult();
if (importResult.isError()) {
throw new RuntimeException("Error importing " + resourceFile + ": " + importResult.getMessage());
}
LOGGER.debug("File {} imported: {}", resourceFile, importResult);
}
if (resourceOid != null) {
PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, resourceOid, null, task, result);
controller.setResource(resource);
}
map.put(name, controller);
return controller;
}
use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.
the class AbstractProvisioningIntegrationTest method initDummyResource.
protected DummyResourceContoller initDummyResource(DummyTestResource resource, OperationResult result) throws Exception {
DummyResourceContoller controller = initDummyResource(resource.name, resource.file, resource.oid, resource.controllerInitLambda, result);
resource.controller = controller;
return controller;
}
Aggregations