use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test080TestAttributesToReturn.
// The account must exist to test this with modify delta. So we postpone the
// test when the account actually exists
@Test
public void test080TestAttributesToReturn() throws Exception {
final String TEST_NAME = "test080TestAttributesToReturn";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance();
OperationResult result = task.getResult();
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ENTITLEMENT, RESOURCE_DUMMY_INTENT_GROUP);
ProvisioningContext ctx = provisioningContextFactory.create(coords, task, result);
// WHEN
AttributesToReturn attributesToReturn = ProvisioningUtil.createAttributesToReturn(ctx);
// THEN
display("attributesToReturn", attributesToReturn);
assertFalse("wrong isReturnDefaultAttributes", attributesToReturn.isReturnDefaultAttributes());
Collection<String> attrs = new ArrayList<>();
for (ResourceAttributeDefinition attributeToReturnDef : attributesToReturn.getAttributesToReturn()) {
attrs.add(attributeToReturnDef.getName().getLocalPart());
}
// No "memebers" attribute here
PrismAsserts.assertSets("Wrong attribute to return", attrs, "uid", "name", "description", "cc");
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class TestDummy method testLiveSyncDeleteCorsairs.
public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass, boolean expectReaction) throws Exception {
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
syncServiceMock.reset();
dummyResource.setSyncStyle(syncStyle);
if (isNameUnique()) {
dummyResource.deleteGroupByName(GROUP_CORSAIRS_NAME);
} else {
dummyResource.deleteGroupById(corsairsIcfUid);
}
display("Resource before sync", dummyResource.debugDump());
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, objectClass);
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.synchronize(coords, syncTokenTask, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display("Synchronization result", result);
TestUtil.assertSuccess("Synchronization result is not OK", result);
if (expectReaction) {
syncServiceMock.assertNotifyChange();
ResourceObjectShadowChangeDescription lastChange = syncServiceMock.getLastChange();
display("The change", lastChange);
PrismObject<? extends ShadowType> oldShadow = lastChange.getOldShadow();
assertNotNull("Old shadow missing", oldShadow);
assertNotNull("Old shadow does not have an OID", oldShadow.getOid());
PrismAsserts.assertClass("old shadow", ShadowType.class, oldShadow);
ShadowType oldShadowType = oldShadow.asObjectable();
ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(oldShadowType);
assertNotNull("No attributes container in old shadow", attributesContainer);
Collection<ResourceAttribute<?>> attributes = attributesContainer.getAttributes();
assertFalse("Attributes container is empty", attributes.isEmpty());
assertEquals("Unexpected number of attributes", 2, attributes.size());
ResourceAttribute<?> icfsNameAttribute = attributesContainer.findAttribute(SchemaConstants.ICFS_NAME);
assertNotNull("No ICF name attribute in old shadow", icfsNameAttribute);
assertEquals("Wrong value of ICF name attribute in old shadow", GROUP_CORSAIRS_NAME, icfsNameAttribute.getRealValue());
ObjectDelta<? extends ShadowType> objectDelta = lastChange.getObjectDelta();
assertNotNull("Delta missing", objectDelta);
assertEquals("Wrong delta changetype", ChangeType.DELETE, objectDelta.getChangeType());
PrismAsserts.assertClass("delta", ShadowType.class, objectDelta);
assertNotNull("No OID in delta", objectDelta.getOid());
assertNull("Unexpected current shadow", lastChange.getCurrentShadow());
try {
// The shadow should be gone
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, corsairsShadowOid, null, result);
AssertJUnit.fail("The shadow " + repoShadow + " is not gone from repo");
} catch (ObjectNotFoundException e) {
// This is expected
}
} else {
syncServiceMock.assertNoNotifyChange();
}
checkAllShadows();
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class TestDummy method testLiveSyncAddCorsairs.
public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass, boolean expectReaction) throws Exception {
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
syncServiceMock.reset();
dummyResource.setSyncStyle(syncStyle);
DummyGroup newGroup = new DummyGroup(GROUP_CORSAIRS_NAME);
newGroup.setEnabled(true);
dummyResource.addGroup(newGroup);
corsairsIcfUid = newGroup.getId();
display("Resource before sync", dummyResource.debugDump());
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, objectClass);
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.synchronize(coords, syncTokenTask, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display("Synchronization result", result);
TestUtil.assertSuccess("Synchronization result is not OK", result);
if (expectReaction) {
syncServiceMock.assertNotifyChange();
ResourceObjectShadowChangeDescription lastChange = syncServiceMock.getLastChange();
display("The change", lastChange);
PrismObject<? extends ShadowType> oldShadow = lastChange.getOldShadow();
assertNotNull("Old shadow missing", oldShadow);
assertNotNull("Old shadow does not have an OID", oldShadow.getOid());
if (syncStyle == DummySyncStyle.DUMB) {
assertNull("Delta present when not expecting it", lastChange.getObjectDelta());
} else {
ObjectDelta<? extends ShadowType> objectDelta = lastChange.getObjectDelta();
assertNotNull("Delta present when not expecting it", objectDelta);
assertTrue("Delta is not add: " + objectDelta, objectDelta.isAdd());
}
ShadowType currentShadowType = lastChange.getCurrentShadow().asObjectable();
assertNotNull("Current shadow missing", lastChange.getCurrentShadow());
PrismAsserts.assertClass("current shadow", ShadowType.class, currentShadowType);
ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(currentShadowType);
assertNotNull("No attributes container in current shadow", attributesContainer);
Collection<ResourceAttribute<?>> attributes = attributesContainer.getAttributes();
assertFalse("Attributes container is empty", attributes.isEmpty());
assertEquals("Unexpected number of attributes", 2, attributes.size());
corsairsShadowOid = currentShadowType.getOid();
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, corsairsShadowOid, null, result);
display("Corsairs repo shadow", repoShadow);
PrismObject<ShadowType> accountRepo = findShadowByName(new QName(RESOURCE_DUMMY_NS, SchemaConstants.GROUP_OBJECT_CLASS_LOCAL_NAME), GROUP_CORSAIRS_NAME, resource, result);
assertNotNull("Shadow was not created in the repository", accountRepo);
display("Repository shadow", accountRepo);
ProvisioningTestUtil.checkRepoShadow(repoShadow, ShadowKindType.ENTITLEMENT);
} else {
syncServiceMock.assertNoNotifyChange();
}
checkAllShadows();
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class TestEditSchema method test263EditShadowSchemaEmpty.
@Test
public void test263EditShadowSchemaEmpty() throws Exception {
final String TEST_NAME = "test263EditShadowSchemaEmpty";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(null, null);
IntegrationTestTools.display("Discr", discr);
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObjectDefinition<ShadowType> editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME);
assertNotNull("No definition for name in shadow", nameDef);
assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName());
assertTrue("additionalName not readable", nameDef.canRead());
PrismPropertyDefinition<Object> attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath());
assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef);
assertSteadyResources();
}
use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class TestEditSchema method test261EditShadowSchemaObjectclass.
@Test
public void test261EditShadowSchemaObjectclass() throws Exception {
final String TEST_NAME = "test261EditShadowSchemaObjectclass";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, dummyResourceCtl.getAccountObjectClassQName());
IntegrationTestTools.display("Discr", discr);
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObjectDefinition<ShadowType> editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME);
assertNotNull("No definition for name in shadow", nameDef);
assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName());
assertTrue("additionalName not readable", nameDef.canRead());
PrismPropertyDefinition<Object> attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath());
assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef);
assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName());
assertTrue("additionalName not readable", attrFullNameDef.canRead());
assertSteadyResources();
}
Aggregations