public ShadowAsserter<RA> assertNoLegacyConsistency() { PrismAsserts.assertNoItem(getObject(), ShadowType.F_RESULT); PrismAsserts.assertNoItem(getObject(), ShadowType.F_ATTEMPT_NUMBER); PrismAsserts.assertNoItem(getObject(), ShadowType.F_FAILED_OPERATION_TYPE); PrismAsserts.assertNoItem(getObject(), ShadowType.F_OBJECT_CHANGE); return this; }
protected void assertSituation(PrismObject<ShadowType> shadow, SynchronizationSituationType expectedSituation) { if (expectedSituation == null) { PrismAsserts.assertNoItem(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION); } else { PrismAsserts.assertPropertyValue(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION, expectedSituation); } }
public static <T> void assertNoExtensionProperty(PrismObject<? extends ObjectType> object, QName propertyName) { PrismContainer<?> extension = object.getExtension(); PrismAsserts.assertNoItem(extension, ItemName.fromQName(propertyName)); }
protected void assertUserJackReadSomeModifySome(PrismObject<UserType> userJack, int exprectedJackAssignments) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException { PrismAsserts.assertPropertyValue(userJack, UserType.F_NAME, PrismTestUtil.createPolyString(USER_JACK_USERNAME)); PrismAsserts.assertPropertyValue(userJack, UserType.F_FULL_NAME, PrismTestUtil.createPolyString(USER_JACK_FULL_NAME)); PrismAsserts.assertPropertyValue(userJack, ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), ActivationStatusType.ENABLED); PrismAsserts.assertNoItem(userJack, UserType.F_GIVEN_NAME); PrismAsserts.assertNoItem(userJack, UserType.F_FAMILY_NAME); PrismAsserts.assertNoItem(userJack, UserType.F_ADDITIONAL_NAME); PrismAsserts.assertNoItem(userJack, UserType.F_DESCRIPTION); PrismAsserts.assertNoItem(userJack, ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS)); assertAssignmentsWithTargets(userJack, exprectedJackAssignments); }
protected <T> void assertRepoShadowCachedAttributeValue(PrismObject<ShadowType> shadowRepo, String attrName, T... attrValues) { PrismAsserts.assertNoItem(shadowRepo, ItemPath.create(ShadowType.F_ATTRIBUTES, new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName))); }
@Test public void test170GetAccountUnlocked() throws Exception { final String TEST_NAME = "test170GetAccountUnlocked"; displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN PrismObject<ShadowType> shadow = modelService.getObject(ShadowType.class, accountOid, null, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); PrismAsserts.assertNoItem(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS); PrismObject<UserType> userAfter = getUser(USER_JACK_OID); display("User after", userAfter); checkAdminStatusFor15x(userAfter, true, true, true); }
@Test public void testObjectDeltaApplyToReplaceEmpty() throws Exception { final String TEST_NAME="testObjectDeltaApplyToReplaceEmpty"; displayTestTitle(TEST_NAME); // GIVEN PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta<UserType> userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, UserType.F_ADDITIONAL_NAMES); // WHEN userDelta.applyTo(user); // THEN PrismAsserts.assertNoItem(user, UserType.F_ADDITIONAL_NAMES); user.checkConsistence(); }
@Test public void test163GetAccount() throws Exception { final String TEST_NAME = "test163GetAccount"; displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); display("Retrieved account shadow", shadow); assertNotNull("No dummy account", shadow); if (supportsActivation()) { PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED); PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL); } else { PrismAsserts.assertNoItem(shadow, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS); PrismAsserts.assertNoItem(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS); } checkAccountWill(shadow, result, startTs, endTs); checkUniqueness(shadow); assertSteadyResource(); }
@Test public void test165ModifyUserGivenNameAgainAgain() throws Exception { final String TEST_NAME = "test165ModifyUserGivenNameAgainAgain"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject<UserType> userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User before", userBefore); Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>(); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, new PolyString("jackie")); deltas.add(userDelta); // WHEN modelService.executeChanges(deltas, null, task, result); // THEN PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User after", userJack); result.computeStatus(); TestUtil.assertSuccess(result); // all the values should be gone now, because the corresponding item in user template is marked as non-tolerant PrismAsserts.assertNoItem(userJack, ItemPath.create(UserType.F_EXTENSION, PIRACY_BAD_LUCK)); }
@Test public void test021ModifyUserNoEmpNum() throws Exception { final String TEST_NAME = "test021ModifyUserNoEmpNum"; TestUtil.displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TEST_NAME); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t002a.xml"), ObjectModificationType.COMPLEX_TYPE); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext); delta.setOid(userOid); // WHEN TestUtil.displayWhen(TEST_NAME); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN TestUtil.displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject<UserType> userAfter = repositoryService.getObject(UserType.class, userOid, null, result); PrismAsserts.assertPropertyValue(userAfter, UserType.F_FULL_NAME, PrismTestUtil.createPolyString(USER_FULLNAME)); PrismAsserts.assertNoItem(userAfter, UserType.F_EMPLOYEE_NUMBER); }
@Test public void test950CreateUserJackWithoutTemplate() throws Exception { final String TEST_NAME = "test950CreateUserJackWithoutTemplate"; displayTestTitle(TEST_NAME); // GIVEN setDefaultUserTemplate(null); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN addObject(USER_JACK_FILE, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User after", userJack); PrismAsserts.assertPropertyValue(userJack, UserType.F_DESCRIPTION, "Where's the rum?"); assertAssignments(userJack, 0); UserType userJackType = userJack.asObjectable(); assertEquals("Unexpected number of accountRefs", 0, userJackType.getLinkRef().size()); PrismAsserts.assertNoItem(userJack, UserType.F_ORGANIZATIONAL_UNIT); }
/** * MID-3186 */ @Test public void test204AddUserHerman() throws Exception { final String TEST_NAME = "test204AddUserHerman"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject<UserType> user = PrismTestUtil.parseObject(USER_HERMAN_FILE); Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>(); ObjectDelta<UserType> userDelta = DeltaFactory.Object.createAddDelta(user); deltas.add(userDelta); // WHEN modelService.executeChanges(deltas, null, task, result); // THEN PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_HERMAN_OID, null, task, result); assertUser(userAfter, USER_HERMAN_OID, USER_HERMAN_USERNAME, USER_HERMAN_FULL_NAME, "Herman", "Toothrot"); PrismAsserts.assertNoItem(userAfter, UserType.F_DESCRIPTION); PrismAsserts.assertPropertyValue(userAfter, UserType.F_TIMEZONE, "High Seas/Monkey Island"); assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID); assertAssignedNoRole(userAfter); assertAssignments(userAfter, 1); UserType userAfterType = userAfter.asObjectable(); assertLinks(userAfter, 1); result.computeStatus(); TestUtil.assertSuccess(result); assertEquals("Wrong costCenter", "G001", userAfterType.getCostCenter()); }
@Test public void test200AddUserRapp() throws Exception { final String TEST_NAME = "test200AddUserRapp"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject<UserType> user = PrismTestUtil.parseObject(USER_RAPP_FILE); Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>(); ObjectDelta<UserType> userDelta = DeltaFactory.Object.createAddDelta(user); deltas.add(userDelta); // WHEN modelService.executeChanges(deltas, null, task, result); // THEN PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); assertUser(userAfter, USER_RAPP_OID, "rapp", "Rapp Scallion", "Rapp", "Scallion"); PrismAsserts.assertNoItem(userAfter, UserType.F_DESCRIPTION); assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID); assertAssignedNoRole(userAfter); assertAssignments(userAfter, 1); UserType userAfterType = userAfter.asObjectable(); assertLinks(userAfter, 1); result.computeStatus(); TestUtil.assertSuccess(result); assertEquals("Unexpected value of employeeNumber, maybe it was generated and should not be?", "D3ADB33F", userAfterType.getEmployeeNumber()); assertEquals("Wrong costCenter", "G001", userAfterType.getCostCenter()); }
/** * MID-3692, MID-3700 */ @Test public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { final String TEST_NAME = "test199CModifyUserGuybrushOrganizationCleanup"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject<UserType> userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); // WHEN displayWhen(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result); // THEN displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); display("User after", userAfter); PrismAsserts.assertNoItem(userAfter, UserType.F_ORGANIZATION); assertAssignedNoRole(userAfter); assertRoles(getNumberOfRoles()); }
/** * Rolling back the deltas from the current state. */ @Test public void test252ReconstructHermanMarooned() throws Exception { final String TEST_NAME = "test252ReconstructHermanMarooned"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN displayWhen(TEST_NAME); PrismObject<UserType> hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanMaroonedEid, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); PrismAsserts.assertPropertyValue(hermanReconstructed, UserType.F_TITLE, createPolyString("Marooned")); PrismAsserts.assertPropertyValue(hermanReconstructed, UserType.F_DESCRIPTION, "Marooned on Monkey Island"); PrismAsserts.assertPropertyValue(hermanReconstructed, UserType.F_NICK_NAME, createPolyString("HT")); PrismAsserts.assertPropertyValue(hermanReconstructed, UserType.F_LOCALITY, createPolyString("Monkey Island")); PrismAsserts.assertNoItem(hermanReconstructed, UserType.F_HONORIFIC_PREFIX); assertAssignedAccount(hermanReconstructed, RESOURCE_DUMMY_OID); assertAssignments(hermanReconstructed, 1); }
@Test public void test220AssignRoleSailorToUserRapp() throws Exception { final String TEST_NAME = "test220AssignRoleSailorToUserRapp"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result); // THEN PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); assertUser(userAfter, USER_RAPP_OID, "rapp", "Rapp Scallion", "Rapp", "Scallion"); PrismAsserts.assertNoItem(userAfter, UserType.F_DESCRIPTION); assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID); assertAssignedRole(userAfter, ROLE_SAILOR_OID); assertAssignments(userAfter, 2); UserType userAfterType = userAfter.asObjectable(); assertLinks(userAfter, 2); result.computeStatus(); TestUtil.assertSuccess(result); assertEquals("Unexpected value of employeeNumber", "D3ADB33F", userAfterType.getEmployeeNumber()); assertEquals("Wrong costCenter", "CC-TITANIC", userAfterType.getCostCenter()); }
/** * MID-3028 */ @Test public void test229UnassignRoleSailorFromUserRapp() throws Exception { final String TEST_NAME = "test220AssignRoleSailorToUserRapp"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result); // THEN PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); assertUser(userAfter, USER_RAPP_OID, "rapp", "Rapp Scallion", "Rapp", "Scallion"); PrismAsserts.assertNoItem(userAfter, UserType.F_DESCRIPTION); assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID); assertAssignedNoRole(userAfter); assertAssignments(userAfter, 1); UserType userAfterType = userAfter.asObjectable(); assertLinks(userAfter, 1); result.computeStatus(); TestUtil.assertSuccess(result); assertEquals("Unexpected value of employeeNumber", "D3ADB33F", userAfterType.getEmployeeNumber()); assertEquals("Wrong costCenter", "G001", userAfterType.getCostCenter()); }
/** * Rolling back the deltas from the current state. */ @Test public void test254ReconstructHermanHermit() throws Exception { final String TEST_NAME = "test254ReconstructHermanHermit"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN displayWhen(TEST_NAME); PrismObject<UserType> hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanHermitEid, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); PrismAsserts.assertPropertyValue(hermanReconstructed, UserType.F_TITLE, createPolyString("Hermit")); PrismAsserts.assertPropertyValue(hermanReconstructed, UserType.F_DESCRIPTION, "Hermit on Monkey Island"); PrismAsserts.assertNoItem(hermanReconstructed, UserType.F_NICK_NAME); PrismAsserts.assertPropertyValue(hermanReconstructed, UserType.F_LOCALITY, createPolyString("Monkey Island")); PrismAsserts.assertPropertyValue(hermanReconstructed, UserType.F_HONORIFIC_PREFIX, createPolyString("His Loneliness")); assertAssignedRole(hermanReconstructed, ROLE_RED_SAILOR_OID); assertAssignedRole(hermanReconstructed, ROLE_JUDGE_OID); assertAssignments(hermanReconstructed, 2); }
@Test public void test249UnassignRoleRastamanFromUserRapp() throws Exception { final String TEST_NAME = "test249UnassignRoleRastamanFromUserRapp"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_RASTAMAN_OID, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); assertUser(userAfter, USER_RAPP_OID, "rapp", "Rapp Scallion", "Rapp", "Scallion"); PrismAsserts.assertNoItem(userAfter, UserType.F_DESCRIPTION); assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID); assertAssignedNoRole(userAfter); assertAssignments(userAfter, 1); UserType userAfterType = userAfter.asObjectable(); assertLinks(userAfter, 1); // Role is unassigned. The mapping was authoritative, so it removed the value assertEquals("Wrong timezone", null, userAfterType.getTimezone()); assertEquals("Wrong locale", "MI", userAfterType.getLocale()); assertEquals("Unexpected value of employeeNumber", "D3ADB33F", userAfterType.getEmployeeNumber()); assertEquals("Wrong costCenter", "CC-RAPP", userAfterType.getCostCenter()); }
private void assertAccount(PrismObject<UserType> userJack, String name, String expectedFullName, String shipAttributeName, String expectedShip, boolean expectedEnabled, DummyResourceContoller resourceCtl, Task task) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, SchemaViolationException, ConflictException, ExpressionEvaluationException, InterruptedException { // ship inbound mapping is used, it is strong String accountOid = getSingleLinkOid(userJack); // Check shadow PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, task.getResult()); display("Repo shadow", accountShadow); assertAccountShadowRepo(accountShadow, accountOid, name, resourceCtl.getResource().asObjectable()); // Check account // All the changes should be reflected to the account PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, task.getResult()); display("Model shadow", accountModel); assertAccountShadowModel(accountModel, accountOid, name, resourceCtl.getResource().asObjectable()); PrismAsserts.assertPropertyValue(accountModel, resourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME), expectedFullName); if (shipAttributeName != null) { if (expectedShip == null) { PrismAsserts.assertNoItem(accountModel, resourceCtl.getAttributePath(shipAttributeName)); } else { PrismAsserts.assertPropertyValue(accountModel, resourceCtl.getAttributePath(shipAttributeName), expectedShip); } } // Check account in dummy resource assertDummyAccount(resourceCtl.getName(), name, expectedFullName, expectedEnabled); }