Search in sources :

Example 1 with QResource

use of com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource in project midpoint by Evolveum.

the class MidScaleNewRepoTest method test010InitResources.

@Test
public void test010InitResources() throws SchemaException {
    OperationResult operationResult = createOperationResult();
    Stopwatch stopwatch = stopwatch("resource.add", "Repository addObject(resource)");
    for (int resourceIndex = 1; resourceIndex <= RESOURCE_COUNT; resourceIndex++) {
        String name = String.format("resource-%03d", resourceIndex);
        ResourceType resourceType = new ResourceType(prismContext).name(PolyStringType.fromOrig(name)).description(randomDescription(name));
        if (resourceIndex == RESOURCE_COUNT) {
            queryRecorder.clearBufferAndStartRecording();
        }
        try (Split ignored = stopwatch.start()) {
            repositoryService.addObject(resourceType.asPrismObject(), null, operationResult);
        } catch (ObjectAlreadyExistsException e) {
            QResource r = aliasFor(QResource.class);
            resourceType.setOid(selectOne(r, r.nameOrig.eq(name)).oid.toString());
        }
        resources.put(name, resourceType.getOid());
    }
    queryRecorder.stopRecording();
}
Also used : QResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource) Stopwatch(org.javasimon.Stopwatch) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Split(org.javasimon.Split) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)1 QResource (com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 Split (org.javasimon.Split)1 Stopwatch (org.javasimon.Stopwatch)1 Test (org.testng.annotations.Test)1