use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class TestBrokenResources method test359DeleteResourceWrongConnectorOid.
@Test
public void test359DeleteResourceWrongConnectorOid() throws Exception {
final String TEST_NAME = "test359DeleteResourceWrongConnectorOid";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
ObjectDelta<ResourceType> delta = ObjectDelta.createDeleteDelta(ResourceType.class, RESOURCE_DUMMY_WRONG_CONNECTOR_OID_OID, prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(delta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
display("getObject result", result);
assertEquals("Expected partial errror in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus());
assertNoObject(ResourceType.class, RESOURCE_DUMMY_WRONG_CONNECTOR_OID_OID, task, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createModifyUserUnlinkAccount.
protected ObjectDelta<UserType> createModifyUserUnlinkAccount(String userOid, PrismObject<ResourceType> resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
String accountOid = getLinkRefOid(userOid, resource.getOid());
ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, userOid, prismContext);
PrismReferenceValue accountRefVal = new PrismReferenceValue();
accountRefVal.setOid(accountOid);
ReferenceDelta accountDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
userDelta.addModification(accountDelta);
return userDelta;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createAccountShadowQuery.
protected ObjectQuery createAccountShadowQuery(String username, PrismObject<ResourceType> resource) throws SchemaException {
RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
Collection<? extends ResourceAttributeDefinition> identifierDefs = rAccount.getPrimaryIdentifiers();
assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs;
ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next();
//TODO: set matching rule instead of null
return QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getName()).eq(username).and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()).and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()).build();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createModifyUserAddAccount.
protected ObjectDelta<UserType> createModifyUserAddAccount(String userOid, PrismObject<ResourceType> resource) throws SchemaException {
PrismObject<ShadowType> account = getAccountShadowDefinition().instantiate();
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resource.getOid());
account.asObjectable().setResourceRef(resourceRef);
RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
account.asObjectable().setObjectClass(refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT).getObjectClassDefinition().getTypeName());
ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, userOid, prismContext);
PrismReferenceValue accountRefVal = new PrismReferenceValue();
accountRefVal.setObject(account);
ReferenceDelta accountDelta = ReferenceDelta.createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
userDelta.addModification(accountDelta);
return userDelta;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class TestDummy method test110SeachIterative.
@Test
public void test110SeachIterative() throws Exception {
final String TEST_NAME = "test110SeachIterative";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
// Make sure there is an account on resource that the provisioning has
// never seen before, so there is no shadow
// for it yet.
DummyAccount newAccount = new DummyAccount("meathook");
newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Meathook");
newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey");
newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
newAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 666L);
newAccount.setEnabled(true);
newAccount.setPassword("parrotMonster");
dummyResource.addAccount(newAccount);
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), prismContext);
final XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
final Holder<Boolean> seenMeathookHolder = new Holder<Boolean>(false);
final List<PrismObject<ShadowType>> foundObjects = new ArrayList<PrismObject<ShadowType>>();
ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> object, OperationResult parentResult) {
foundObjects.add(object);
display("Found", object);
XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
assertTrue(object.canRepresent(ShadowType.class));
try {
checkAccountShadow(object, parentResult, true, startTs, endTs);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
assertCachingMetadata(object, false, startTs, endTs);
if (object.asObjectable().getName().getOrig().equals("meathook")) {
meathookAccountOid = object.getOid();
seenMeathookHolder.setValue(true);
try {
Long loot = ShadowUtil.getAttributeValue(object, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME));
assertEquals("Wrong meathook's loot", (Long) 666L, loot);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
}
return true;
}
};
rememberShadowFetchOperationCount();
// WHEN
provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
// THEN
XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
result.computeStatus();
display("searchObjectsIterative result", result);
TestUtil.assertSuccess(result);
assertShadowFetchOperationCountIncrement(1);
assertEquals(4, foundObjects.size());
checkConsistency(foundObjects);
assertProtected(foundObjects, 1);
PrismObject<ShadowType> shadowWillRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
assertRepoShadowCachedAttributeValue(shadowWillRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Flying Dutchman");
checkRepoAccountShadowWill(shadowWillRepo, startTs, endTs);
PrismObject<ShadowType> shadowMeathook = repositoryService.getObject(ShadowType.class, meathookAccountOid, null, result);
display("Meathook shadow", shadowMeathook);
assertRepoShadowCachedAttributeValue(shadowMeathook, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
assertRepoCachingMetadata(shadowMeathook, startTs, endTs);
// And again ...
foundObjects.clear();
rememberShadowFetchOperationCount();
XMLGregorianCalendar startTs2 = clock.currentTimeXMLGregorianCalendar();
// WHEN
provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
// THEN
XMLGregorianCalendar endTs2 = clock.currentTimeXMLGregorianCalendar();
assertShadowFetchOperationCountIncrement(1);
display("Found shadows", foundObjects);
assertEquals(4, foundObjects.size());
checkConsistency(foundObjects);
assertProtected(foundObjects, 1);
shadowWillRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
checkRepoAccountShadowWill(shadowWillRepo, startTs2, endTs2);
shadowMeathook = repositoryService.getObject(ShadowType.class, meathookAccountOid, null, result);
assertRepoShadowCachedAttributeValue(shadowMeathook, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
assertRepoCachingMetadata(shadowMeathook, startTs2, endTs2);
assertSteadyResource();
}
Aggregations