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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations