Search in sources :

Example 86 with ResourceType

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

the class TestBrokenResources method test220GetResourceNotFound.

@Test
public void test220GetResourceNotFound() throws Exception {
    final String TEST_NAME = "test220GetResourceNotFound";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_CSVFILE_NOTFOUND_OID, null, task, result);
    // THEN
    display("getObject resource", resource);
    result.computeStatus();
    display("getObject result", result);
    assertEquals("Expected partial errror in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus());
    OperationResultType fetchResult = resource.asObjectable().getFetchResult();
    display("resource.fetchResult", fetchResult);
    assertEquals("Expected partial errror in fetchResult", OperationResultStatusType.PARTIAL_ERROR, fetchResult.getStatus());
    // TODO: better asserts
    assertNotNull("Null resource", resource);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 87 with ResourceType

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

the class TestBrokenResources method test360AddResourceNoConfiguration.

@Test
public void test360AddResourceNoConfiguration() throws Exception {
    final String TEST_NAME = "test360AddResourceNoConfiguration";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_NO_CONFIGURATION_FILE);
    PrismObject<ConnectorType> connectorDummy = findConnectorByTypeAndVersion(CONNECTOR_DUMMY_TYPE, CONNECTOR_DUMMY_VERSION, result);
    resource.asObjectable().getConnectorRef().setOid(connectorDummy.getOid());
    ObjectDelta<ResourceType> delta = ObjectDelta.createAddDelta(resource);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(delta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 88 with ResourceType

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

the class TestBrokenResources method test350AddResourceWrongConnectorOid.

@Test
public void test350AddResourceWrongConnectorOid() throws Exception {
    final String TEST_NAME = "test350AddResourceWrongConnectorOid";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_WRONG_CONNECTOR_OID_FILE);
    ObjectDelta<ResourceType> delta = ObjectDelta.createAddDelta(resource);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(delta);
    try {
        // WHEN
        modelService.executeChanges(deltas, null, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (ObjectNotFoundException e) {
    // This is expected
    }
    // THEN
    result.computeStatus();
    display(result);
    TestUtil.assertFailure(result);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 89 with ResourceType

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

the class TestBrokenResources method test362GetResourceNoConfiguration.

@Test
public void test362GetResourceNoConfiguration() throws Exception {
    final String TEST_NAME = "test362GetResourceNoConfiguration";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_CONFIGURATION_OID, null, task, result);
    // THEN
    display("getObject resource", resource);
    result.computeStatus();
    display("getObject result", result);
    assertEquals("Expected partial errror in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus());
    OperationResultType fetchResult = resource.asObjectable().getFetchResult();
    display("resource.fetchResult", fetchResult);
    assertEquals("Expected partial errror in fetchResult", OperationResultStatusType.PARTIAL_ERROR, fetchResult.getStatus());
    // TODO: better asserts
    assertNotNull("Null resource", resource);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 90 with ResourceType

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

the class ImportTest method test031ReimportResource.

@Test
public void test031ReimportResource() throws Exception {
    final String TEST_NAME = "test031ReimportResource";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(ImportTest.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    FileInputStream stream = new FileInputStream(RESOURCE_DUMMY_CHANGED_FILE);
    ImportOptionsType options = getDefaultImportOptions();
    options.setOverwrite(true);
    IntegrationTestTools.assertNoRepoCache();
    dummyAuditService.clear();
    // WHEN
    modelService.importObjectsFromStream(stream, options, task, result);
    // THEN
    result.computeStatus();
    display("Result after import", result);
    TestUtil.assertSuccess("Import of " + RESOURCE_DUMMY_CHANGED_FILE + " has failed (result)", result, 2);
    IntegrationTestTools.assertNoRepoCache();
    PrismObject<ResourceType> repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result);
    display("Reimported resource (repo)", repoResource);
    assertDummyResource(repoResource, true);
    IntegrationTestTools.assertNoRepoCache();
    MidPointAsserts.assertVersionIncrease(importedRepoResource, repoResource);
    PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
    display("Reimported resource (model)", resource);
    IntegrationTestTools.assertNoRepoCache();
    assertDummyResource(resource, false);
    MidPointAsserts.assertVersionIncrease(importedResource, resource);
    ResourceType resourceType = resource.asObjectable();
    assertNull("Synchronization not gone", resourceType.getSynchronization());
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(1);
    dummyAuditService.assertHasDelta(ChangeType.ADD, ResourceType.class);
    dummyAuditService.assertExecutionSuccess();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ImportOptionsType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) FileInputStream(java.io.FileInputStream) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Aggregations

ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)252 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)199 Test (org.testng.annotations.Test)165 Task (com.evolveum.midpoint.task.api.Task)115 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)58 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)54 PrismObject (com.evolveum.midpoint.prism.PrismObject)50 QName (javax.xml.namespace.QName)45 ArrayList (java.util.ArrayList)37 Element (org.w3c.dom.Element)34 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)33 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)30 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)28 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)27 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)26 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)25 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)24 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)23 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)23