Search in sources :

Example 36 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class TestOpenDjNegative method test190Synchronize.

@Test
public void test190Synchronize() throws Exception {
    final String TEST_NAME = "test190Synhronize";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_OPENDJ_OID, new QName(RESOURCE_NS, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME));
    try {
        provisioningService.synchronize(coords, task, result);
        AssertJUnit.fail("addObject succeeded unexpectedly");
    } catch (CommunicationException e) {
        // This is expected
        display("Expected exception", e);
    }
    result.computeStatus();
    TestUtil.assertFailure(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) Test(org.testng.annotations.Test)

Example 37 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class ProgressPanel method initLayout.

private void initLayout(ProgressReportingAwarePage page) {
    progressForm = new Form<>(ID_PROGRESS_FORM, true);
    add(progressForm);
    contentsPanel = new WebMarkupContainer(ID_CONTENTS_PANEL);
    contentsPanel.setOutputMarkupId(true);
    progressForm.add(contentsPanel);
    ListView statusItemsListView = new ListView<ProgressReportActivityDto>(ID_ACTIVITIES, new AbstractReadOnlyModel<List<ProgressReportActivityDto>>() {

        @Override
        public List<ProgressReportActivityDto> getObject() {
            ProgressDto progressDto = ProgressPanel.this.getModelObject();
            return progressDto.getProgressReportActivities();
        }
    }) {

        protected void populateItem(final ListItem<ProgressReportActivityDto> item) {
            item.add(new Label(ID_ACTIVITY_DESCRIPTION, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    ProgressReportActivityDto si = item.getModelObject();
                    if (si.getActivityType() == RESOURCE_OBJECT_OPERATION && si.getResourceShadowDiscriminator() != null) {
                        ResourceShadowDiscriminator rsd = si.getResourceShadowDiscriminator();
                        return createStringResource(rsd.getKind()).getString() + " (" + rsd.getIntent() + ") on " + // TODO correct i18n
                        si.getResourceName();
                    } else {
                        return createStringResource(si.getActivityType()).getString();
                    }
                }
            }));
            item.add(createImageLabel(ID_ACTIVITY_STATE, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    OperationResultStatusType statusType = item.getModelObject().getStatus();
                    if (statusType == null) {
                        return null;
                    } else {
                        return OperationResultStatusPresentationProperties.parseOperationalResultStatus(statusType).getIcon() + " fa-lg";
                    }
                }
            }, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    // TODO why this does not work???
                    // TODO i18n
                    OperationResultStatusType statusType = item.getModelObject().getStatus();
                    if (statusType == null) {
                        return null;
                    } else {
                        return statusType.toString();
                    }
                }
            }));
            item.add(new Label(ID_ACTIVITY_COMMENT, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    ProgressReportActivityDto si = item.getModelObject();
                    if (si.getResourceName() != null || si.getResourceOperationResultList() != null) {
                        StringBuilder sb = new StringBuilder();
                        boolean first = true;
                        if (si.getResourceOperationResultList() != null) {
                            for (ResourceOperationResult ror : si.getResourceOperationResultList()) {
                                if (!first) {
                                    sb.append(", ");
                                } else {
                                    first = false;
                                }
                                sb.append(createStringResource("ChangeType." + ror.getChangeType()).getString());
                                sb.append(":");
                                sb.append(createStringResource(ror.getResultStatus()).getString());
                            }
                        }
                        if (si.getResourceObjectName() != null) {
                            if (!first) {
                                sb.append(" -> ");
                            }
                            sb.append(si.getResourceObjectName());
                        }
                        return sb.toString();
                    } else {
                        return null;
                    }
                }
            }));
        }

        private Label createImageLabel(String id, IModel<String> cssClass, IModel<String> title) {
            Label label = new Label(id);
            label.add(AttributeModifier.replace("class", cssClass));
            // does not work, currently
            label.add(AttributeModifier.replace("title", title));
            return label;
        }
    };
    contentsPanel.add(statusItemsListView);
    statisticsPanel = new StatisticsPanel(ID_STATISTICS, new StatisticsDtoModel());
    contentsPanel.add(statisticsPanel);
    ListView logItemsListView = new ListView(ID_LOG_ITEMS, new AbstractReadOnlyModel<List>() {

        @Override
        public List getObject() {
            ProgressDto progressDto = ProgressPanel.this.getModelObject();
            return progressDto.getLogItems();
        }
    }) {

        protected void populateItem(ListItem item) {
            item.add(new Label(ID_LOG_ITEM, item.getModel()));
        }
    };
    contentsPanel.add(logItemsListView);
    Label executionTime = new Label(ID_EXECUTION_TIME, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (operationDurationTime > 0) {
                return createStringResource("ProgressPanel.ExecutionTimeWhenFinished", operationDurationTime).getString();
            } else if (operationStartTime > 0) {
                return createStringResource("ProgressPanel.ExecutionTimeWhenRunning", (System.currentTimeMillis() - operationStartTime) / 1000).getString();
            } else {
                return null;
            }
        }
    });
    contentsPanel.add(executionTime);
    initButtons(progressForm, page);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) OperationResultStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) ListItem(org.apache.wicket.markup.html.list.ListItem) ResourceOperationResult(com.evolveum.midpoint.web.component.progress.ProgressReportActivityDto.ResourceOperationResult)

Example 38 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class TestSynchronization method test100SyncAddWill.

@Test
public void test100SyncAddWill() throws Exception {
    final String TEST_NAME = "test100SyncAddWill";
    TestUtil.displayTestTile(TEST_NAME);
    final OperationResult result = new OperationResult(TestSynchronization.class.getName() + "." + TEST_NAME);
    Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
    AssertJUnit.assertNotNull(syncTask);
    assertSyncToken(syncTask, 0, result);
    ((SynchornizationServiceMock) syncServiceMock).reset();
    // create add change in embeded LDAP
    LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_WILL_FILE.getPath());
    LDIFReader ldifReader = new LDIFReader(importConfig);
    Entry entry = ldifReader.readEntry();
    display("Entry from LDIF", entry);
    AddOperation addOperation = openDJController.getInternalConnection().processAdd(entry);
    AssertJUnit.assertEquals("LDAP add operation failed", ResultCode.SUCCESS, addOperation.getResultCode());
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(resourceType.getOid(), AbstractOpenDjTest.RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
    // WHEN
    provisioningService.synchronize(coords, syncTask, result);
    // THEN
    SynchornizationServiceMock mock = (SynchornizationServiceMock) syncServiceMock;
    assertEquals("Unexpected number of synchronization service calls", 1, mock.getCallCount());
    ResourceObjectShadowChangeDescription lastChange = mock.getLastChange();
    //			ObjectDelta<? extends ShadowType> objectDelta = lastChange.getObjectDelta();
    //			assertNotNull("Null object delta in change notification", objectDelta);
    //			assertEquals("Wrong change type in delta in change notification", ChangeType.ADD, objectDelta.getChangeType());
    PrismObject<? extends ShadowType> currentShadow = lastChange.getCurrentShadow();
    assertNotNull("No current shadow in change notification", currentShadow);
    assertNotNull("No old shadow in change notification", lastChange.getOldShadow());
    assertEquals("Wrong shadow name", PrismTestUtil.createPolyStringType(ACCOUNT_WILL_NAME), currentShadow.asObjectable().getName());
    assertSyncToken(SYNC_TASK_OID, 1, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) SynchornizationServiceMock(com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) AddOperation(org.opends.server.core.AddOperation) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 39 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class TestSynchronization method test500SyncAddProtected.

@Test
public void test500SyncAddProtected() throws Exception {
    final String TEST_NAME = "test500SyncAddProtected";
    TestUtil.displayTestTile(TEST_NAME);
    final OperationResult result = new OperationResult(TestSynchronization.class.getName() + "." + TEST_NAME);
    Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
    AssertJUnit.assertNotNull(syncTask);
    assertSyncToken(syncTask, 1, result);
    ((SynchornizationServiceMock) syncServiceMock).reset();
    // create add change in embedded LDAP
    LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_CALYPSO_FILE.getPath());
    LDIFReader ldifReader = new LDIFReader(importConfig);
    Entry entry = ldifReader.readEntry();
    ldifReader.close();
    display("Entry from LDIF", entry);
    AddOperation addOperation = openDJController.getInternalConnection().processAdd(entry);
    AssertJUnit.assertEquals("LDAP add operation failed", ResultCode.SUCCESS, addOperation.getResultCode());
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(resourceType.getOid(), AbstractOpenDjTest.RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
    // WHEN
    provisioningService.synchronize(coords, syncTask, result);
    // THEN
    SynchornizationServiceMock mock = (SynchornizationServiceMock) syncServiceMock;
    assertEquals("Unexpected number of synchronization service calls", 0, mock.getCallCount());
    //		ResourceObjectShadowChangeDescription lastChange = mock.getLastChange();
    //		PrismObject<? extends ShadowType> currentShadow = lastChange.getCurrentShadow();
    //		assertNotNull("No current shadow in change notification", currentShadow);
    //		assertNotNull("No old shadow in change notification", lastChange.getOldShadow());
    //		
    //		assertEquals("Wrong shadow name", PrismTestUtil.createPolyStringType(ACCOUNT_CALYPSO_NAME), currentShadow.asObjectable().getName());
    //		
    //		assertNotNull("Calypso is not protected", currentShadow.asObjectable().isProtectedObject());
    //		assertTrue("Calypso is not protected", currentShadow.asObjectable().isProtectedObject());
    assertSyncToken(SYNC_TASK_OID, 2, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) SynchornizationServiceMock(com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) AddOperation(org.opends.server.core.AddOperation) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 40 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class TestOpenDjNegative method test590Synchronize.

@Test
public void test590Synchronize() throws Exception {
    final String TEST_NAME = "test590Synhronize";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_OPENDJ_OID, new QName(RESOURCE_NS, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME));
    try {
        provisioningService.synchronize(coords, task, result);
        AssertJUnit.fail("addObject succeeded unexpectedly");
    } catch (CommunicationException e) {
        // This is expected
        display("Expected exception", e);
    }
    result.computeStatus();
    TestUtil.assertFailure(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) Test(org.testng.annotations.Test)

Aggregations

ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)78 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)41 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)34 Task (com.evolveum.midpoint.task.api.Task)30 Test (org.testng.annotations.Test)30 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)28 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)18 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)17 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)17 ModelProjectionContext (com.evolveum.midpoint.model.api.context.ModelProjectionContext)11 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)10 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)10 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)9 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)9 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)8 MockLensDebugListener (com.evolveum.midpoint.model.impl.util.mock.MockLensDebugListener)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 QName (javax.xml.namespace.QName)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6