use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestAssignmentErrors method test200UserLemonheadAssignAccountBrokenNetwork.
@Test
public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception {
final String TEST_NAME = "test200UserLemonheadAssignAccountBrokenNetwork";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
PrismObject<UserType> user = createUser(USER_LEMONHEAD_NAME, USER_LEMONHEAD_FULLNAME);
addObject(user);
userLemonheadOid = user.getOid();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(user.getOid(), RESOURCE_DUMMY_OID, null, true);
deltas.add(accountAssignmentUserDelta);
getDummyResource().setBreakMode(BreakMode.NETWORK);
dummyAuditService.clear();
// WHEN
//not expected that it fails, instead the error in the result is expected
modelService.executeChanges(deltas, null, task, result);
result.computeStatus();
display(result);
// This has to be a partial error as some changes were executed (user) and others were not (account)
TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertTarget(user.getOid());
dummyAuditService.assertExecutionOutcome(OperationResultStatus.HANDLED_ERROR);
dummyAuditService.assertExecutionMessage();
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestAssignmentErrors method test100UserJackAssignBlankAccount.
/**
* The "white" resource has no outbound mapping and there is also no mapping in the assignment. Therefore
* this results in account without any attributes. It should fail.
*/
@Test
public void test100UserJackAssignBlankAccount() throws Exception {
final String TEST_NAME = "test100UserJackAssignBlankAccount";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
dummyAuditService.clear();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_WHITE_OID, null, true);
deltas.add(accountAssignmentUserDelta);
dummyAuditService.clear();
// WHEN
//not expected that it fails, insted the fatal error in the result is excpected
modelService.executeChanges(deltas, null, task, result);
result.computeStatus();
display(result);
// This has to be a partial error as some changes were executed (user) and others were not (account)
TestUtil.assertPartialError(result);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionOutcome(OperationResultStatus.PARTIAL_ERROR);
dummyAuditService.assertExecutionMessage();
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType 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.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestBrokenResources method testAssignTwoResoures.
/**
* Assign two resources to a user. One of them is looney, the other is not. The result should be that
* the account on the good resource is created.
*/
private void testAssignTwoResoures(final String TEST_NAME, String badResourceOid) throws Exception {
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE);
ObjectDelta<UserType> userDelta = createAccountAssignmentUserDelta(USER_JACK_OID, badResourceOid, null, true);
userDelta.addModification(createAccountAssignmentModification(RESOURCE_DUMMY_OID, null, true));
display("input delta", userDelta);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
display("executeChanges result", result);
//TODO: ugly hack, see MID-1248
if ("test401AssignTwoResouresBroken".equals(TEST_NAME)) {
assertEquals("Expected partial error in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus());
}
DummyAccount jackDummyAccount = getDummyResource().getAccountByUsername(USER_JACK_USERNAME);
assertNotNull("No jack dummy account", jackDummyAccount);
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestOrgStruct method executeConflictPlusAndMinus.
protected void executeConflictPlusAndMinus(String TEST_NAME) throws Exception {
Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
modifications.add((createAssignmentModification(ORG_MINISTRY_OF_DEFENSE_OID, OrgType.COMPLEX_TYPE, null, null, null, false)));
ObjectDelta<UserType> userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
assertNotAssignedOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, null);
assertHasOrgs(userJack, ORG_MINISTRY_OF_DEFENSE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, null);
// Postcondition
assertMonkeyIslandOrgSanity();
}
Aggregations