Search in sources :

Example 11 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class ConsistencyTest method test001TestConnectionOpenDJ.

/**
	 * Test the testResource method. Expect a complete success for now.
	 */
@Test
public void test001TestConnectionOpenDJ() throws Exception {
    final String TEST_NAME = "test001TestConnectionOpenDJ";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance();
    // GIVEN
    assertNoRepoCache();
    // WHEN
    OperationResultType result = modelWeb.testResource(RESOURCE_OPENDJ_OID);
    // THEN
    assertNoRepoCache();
    displayJaxb("testResource result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("testResource has failed", result);
    OperationResult opResult = new OperationResult(ConsistencyTest.class.getName() + "." + TEST_NAME);
    PrismObject<ResourceType> resourceOpenDjRepo = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, opResult);
    resourceTypeOpenDjrepo = resourceOpenDjRepo.asObjectable();
    assertNoRepoCache();
    assertEquals(RESOURCE_OPENDJ_OID, resourceTypeOpenDjrepo.getOid());
    display("Initialized OpenDJ resource (respository)", resourceTypeOpenDjrepo);
    assertNotNull("Resource schema was not generated", resourceTypeOpenDjrepo.getSchema());
    Element resourceOpenDjXsdSchemaElement = ResourceTypeUtil.getResourceXsdSchema(resourceTypeOpenDjrepo);
    assertNotNull("Resource schema was not generated", resourceOpenDjXsdSchemaElement);
    PrismObject<ResourceType> openDjResourceProvisioninig = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, opResult);
    display("Initialized OpenDJ resource resource (provisioning)", openDjResourceProvisioninig);
    PrismObject<ResourceType> openDjResourceModel = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, opResult);
    display("Initialized OpenDJ resource OpenDJ resource (model)", openDjResourceModel);
    checkOpenDjResource(resourceTypeOpenDjrepo, "repository");
    System.out.println("------------------------------------------------------------------");
    display("OpenDJ resource schema (repo XML)", DOMUtil.serializeDOMToString(ResourceTypeUtil.getResourceXsdSchema(resourceOpenDjRepo)));
    System.out.println("------------------------------------------------------------------");
    checkOpenDjResource(openDjResourceProvisioninig.asObjectable(), "provisioning");
    checkOpenDjResource(openDjResourceModel.asObjectable(), "model");
// TODO: model web
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 12 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class AuditController method getObjectFromLastEvent.

/**
 * Side effect: removes the last event.
 *
 * The reason is that we don't want to use it when rolling back the time later in
 * {@link #rollBackTime(PrismObject, List)}. It is the reference event that we want to
 * know the object state on.
 */
private <O extends ObjectType> PrismObject<O> getObjectFromLastEvent(PrismObject<O> object, List<AuditEventRecordType> changeTrail, String eventIdentifier) {
    if (changeTrail.isEmpty()) {
        return object;
    }
    AuditEventRecordType lastEvent = changeTrail.remove(changeTrail.size() - 1);
    if (!eventIdentifier.equals(lastEvent.getEventIdentifier())) {
        throw new IllegalStateException("Wrong last event identifier, expected " + eventIdentifier + " but was " + lastEvent.getEventIdentifier());
    }
    List<ObjectDeltaOperationType> lastEventDeltasOperations = lastEvent.getDelta();
    for (ObjectDeltaOperationType lastEventDeltasOperation : lastEventDeltasOperations) {
        if (!isApplicable(lastEventDeltasOperation, object, lastEvent)) {
            continue;
        }
        ObjectDeltaType objectDelta = lastEventDeltasOperation.getObjectDelta();
        if (objectDelta.getChangeType() == ChangeTypeType.ADD) {
            // We are lucky. This is object add, so we have complete object there.
            // No need to roll back the operations.
            // noinspection unchecked
            PrismObject<O> objectToAdd = objectDelta.getObjectToAdd().asPrismObject();
            LOGGER.trace("Taking object from add delta in last event {}:\n{}", lastEvent.getEventIdentifier(), objectToAdd.debugDumpLazily(1));
            return objectToAdd;
        }
    }
    return null;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType)

Example 13 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class ClusterwideUserSessionManagerImpl method getLoggedInPrincipals.

@Override
@NotNull
public List<UserSessionManagementType> getLoggedInPrincipals(Task task, OperationResult result) {
    List<UserSessionManagementType> loggedUsers = guiProfiledPrincipalManager.getLocalLoggedInPrincipals();
    Map<String, UserSessionManagementType> usersMap = new HashMap<>();
    // fix for mid-6328
    loggedUsers.forEach(loggedUser -> {
        UserSessionManagementType addedUser = usersMap.get(loggedUser.getFocus().getOid());
        if (addedUser != null) {
            addedUser.setActiveSessions(addedUser.getActiveSessions() + loggedUser.getActiveSessions());
            addedUser.getNode().addAll(loggedUser.getNode());
        } else {
            usersMap.put(loggedUser.getFocus().getOid(), loggedUser);
        }
    });
    // We try to invoke this call also on nodes that are in transition. We want to get
    // information as complete as realistically possible.
    clusterExecutionHelper.execute((client, node, result1) -> {
        client.path(ClusterServiceConsts.EVENT_LIST_USER_SESSION);
        Response response = client.get();
        LOGGER.debug("Remote-node retrieval of user sessions finished on {} with status {}, {}", node.getNodeIdentifier(), response.getStatusInfo().getStatusCode(), response.getStatusInfo().getReasonPhrase());
        if (response.hasEntity()) {
            UserSessionManagementListType remoteSessionsWrapper = response.readEntity(UserSessionManagementListType.class);
            List<UserSessionManagementType> remoteSessions = remoteSessionsWrapper.getSession();
            for (UserSessionManagementType remoteSession : MiscUtil.emptyIfNull(remoteSessions)) {
                UserSessionManagementType existingUser = usersMap.get(remoteSession.getFocus().getOid());
                if (existingUser != null) {
                    existingUser.setActiveSessions(existingUser.getActiveSessions() + remoteSession.getActiveSessions());
                    existingUser.getNode().addAll(remoteSession.getNode());
                } else {
                    usersMap.put(remoteSession.getFocus().getOid(), remoteSession);
                }
            }
        }
        response.close();
    }, new ClusterExecutionOptions().tryNodesInTransition(), " list principals from remote nodes ", result);
    return new ArrayList<>(usersMap.values());
}
Also used : Response(javax.ws.rs.core.Response) UserSessionManagementType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UserSessionManagementListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementListType) ClusterExecutionOptions(com.evolveum.midpoint.task.api.ClusterExecutionOptions) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class TestNoOpTask method test100BucketAnalysisUsingCondition.

@Test
public void test100BucketAnalysisUsingCondition() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    when();
    addTask(TASK_BUCKET_ANALYSIS_WITH_CONDITION, result);
    waitForTaskCloseOrSuspend(TASK_BUCKET_ANALYSIS_WITH_CONDITION.oid, 10000);
    then();
    // @formatter:off
    TaskType taskAfter = assertTask(TASK_BUCKET_ANALYSIS_WITH_CONDITION.oid, "after").display().assertSuccess().assertClosed().rootActivityState().bucketManagementStatistics().display().assertComplete(// These are all the buckets. We must complete also those that are skipped.
    20).end().end().getObjectable();
    // @formatter:on
    String reportOid = getBucketReportDataOid(taskAfter, ActivityPath.empty());
    try (var reader = SimpleReportReader.createForLocalReportData(reportOid, List.of("sequentialNumber", "content-from", "content-to"), commonTaskBeans, result)) {
        List<List<String>> rows = reader.getRows();
        displayValue("rows of bucket analysis report", rows);
        assertThat(rows).as("rows").hasSize(5);
        assertThat(rows.get(0)).as("row 0").containsExactly("4", "1500", "2000");
        assertThat(rows.get(1)).as("row 1").containsExactly("8", "3500", "4000");
        assertThat(rows.get(2)).as("row 2").containsExactly("12", "5500", "6000");
        assertThat(rows.get(3)).as("row 3").containsExactly("16", "7500", "8000");
        assertThat(rows.get(4)).as("row 4").containsExactly("20", "9500", "10000");
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) List(java.util.List) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 15 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class TestNoOpTask method test110BucketAnalysisUsingRegularSampling.

@Test
public void test110BucketAnalysisUsingRegularSampling() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    when();
    addTask(TASK_BUCKET_ANALYSIS_WITH_REGULAR_SAMPLING, result);
    waitForTaskCloseOrSuspend(TASK_BUCKET_ANALYSIS_WITH_REGULAR_SAMPLING.oid, 10000);
    then();
    // @formatter:off
    TaskType taskAfter = assertTask(TASK_BUCKET_ANALYSIS_WITH_REGULAR_SAMPLING.oid, "after").display().assertSuccess().assertClosed().rootActivityState().bucketManagementStatistics().display().assertComplete(// Great! Skipped buckets do not undergo get->complete process.
    10).end().end().getObjectable();
    // @formatter:on
    String reportOid = getBucketReportDataOid(taskAfter, ActivityPath.empty());
    try (var reader = SimpleReportReader.createForLocalReportData(reportOid, List.of("sequentialNumber", "content-from", "content-to"), commonTaskBeans, result)) {
        List<List<String>> rows = reader.getRows();
        displayValue("rows of bucket analysis report", rows);
        assertThat(rows).as("rows").hasSize(10);
        assertThat(rows.get(0)).as("row 0").containsExactly("20", "950", "1000");
        assertThat(rows.get(1)).as("row 1").containsExactly("40", "1950", "2000");
        assertThat(rows.get(2)).as("row 2").containsExactly("60", "2950", "3000");
        assertThat(rows.get(3)).as("row 3").containsExactly("80", "3950", "4000");
        assertThat(rows.get(9)).as("row 9").containsExactly("200", "9950", "10000");
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) List(java.util.List) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)25 Test (org.testng.annotations.Test)21 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)14 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)12 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)11 Task (com.evolveum.midpoint.task.api.Task)11 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)10 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)9 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)9 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)9 Holder (javax.xml.ws.Holder)9 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)8 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)7 Element (org.w3c.dom.Element)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)5 List (java.util.List)5