@Test public void test360AssignToJack() throws Exception { final String TEST_NAME = "test360AssignToJack"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); PrismProperty<ScriptingExpressionType> expression = parseAnyData(ASSIGN_TO_JACK_FILE); // WHEN ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression( expression.getAnyValue().getValue(), result); // THEN assertNoOutputData(output); IntegrationTestTools.display("stdout", output.getConsoleOutput()); IntegrationTestTools.display(result); result.computeStatus(); TestUtil.assertSuccess(result); // assertEquals("Recomputed user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n", // output.getConsoleOutput()); PrismObject<UserType> jack = getUser(USER_JACK_OID); IntegrationTestTools.display("jack after assignments creation", jack); assertAssignedAccount(jack, "10000000-0000-0000-0000-000000000104"); assertAssignedRole(jack, "12345678-d34d-b33f-f00d-55555555cccc"); }
@Test public void test340ModifyJackBack() throws Exception { final String TEST_NAME = "test340ModifyJackBack"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); PrismProperty<ScriptingExpressionType> expression = parseAnyData(MODIFY_JACK_BACK_FILE); // WHEN ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression( expression.getAnyValue().getValue(), result); // THEN assertNoOutputData(output); IntegrationTestTools.display("stdout", output.getConsoleOutput()); IntegrationTestTools.display(result); result.computeStatus(); TestUtil.assertSuccess(result); assertEquals( "Modified user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n", output.getConsoleOutput()); assertEquals( "Caribbean", searchObjectByName(UserType.class, "jack").asObjectable().getLocality().getOrig()); }
@Test public void test102GetAccountMurrayRaw() throws Exception { TestUtil.displayTestTile(this, "test102GetAccountMurrayRaw"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test102GetAccountMurrayRaw"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); // WHEN PrismObject<ShadowType> account = modelService.getObject( ShadowType.class, ACCOUNT_SHADOW_MURRAY_CSVFILE_OID, options, task, result); display("getObject account", account); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess("getObject result", result); // TODO: better asserts assertNotNull("Null resource", account); }
@Test public void test120SearchAccountByUsernameJack() throws Exception { TestUtil.displayTestTile(this, "test120SearchAccountByUsernameJack"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test120SearchAccountByUsernameJack"); OperationResult result = task.getResult(); PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_CSVFILE_BROKEN_OID, null, task, result); try { // WHEN PrismObject<ShadowType> account = findAccountByUsername("jack", resource, task, result); AssertJUnit.fail("Expected SystemException but the operation was successful"); } catch (SystemException e) { // This is expected result.computeStatus(); display("findAccountByUsername result", result); TestUtil.assertFailure("findAccountByUsername result", result); } }
@Test public void test020GetResourceBroken() throws Exception { TestUtil.displayTestTile(this, "test020GetResourceBroken"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test020GetResourceBroken"); OperationResult result = task.getResult(); // WHEN PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_CSVFILE_BROKEN_OID, null, task, result); // THEN display("getObject resource", resource); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess("getObject result", result); OperationResultType fetchResult = resource.asObjectable().getFetchResult(); TestUtil.assertSuccess("resource.fetchResult", fetchResult); // TODO: better asserts assertNotNull("Null resource", resource); }
@Test public void test100GetAccountMurray() throws Exception { TestUtil.displayTestTile(this, "test100GetAccountMurray"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test100GetAccountMurray"); OperationResult result = task.getResult(); try { // WHEN PrismObject<ShadowType> account = modelService.getObject( ShadowType.class, ACCOUNT_SHADOW_MURRAY_CSVFILE_OID, null, task, result); AssertJUnit.fail("Expected SystemException but the operation was successful"); } catch (SystemException e) { // This is expected display("Expected exception", e); result.computeStatus(); display("getObject result", result); TestUtil.assertFailure("getObject result", result); } }
@Test public void test380DisableJackInBackgroundSimple() throws Exception { final String TEST_NAME = "test380DisableJackInBackgroundSimple"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); // WHEN Task task = taskManager.createTaskInstance(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); scriptingExpressionEvaluator.evaluateExpressionInBackground( UserType.COMPLEX_TYPE, ObjectQueryUtil.createOrigNameQuery("jack", prismContext).getFilter(), "disable", task, result); waitForTaskFinish(task.getOid(), false); task.refresh(result); // THEN IntegrationTestTools.display(task.getResult()); TestUtil.assertSuccess(task.getResult()); PrismObject<UserType> jack = getUser(USER_JACK_OID); IntegrationTestTools.display("jack after disable script", jack); assertAdministrativeStatusDisabled(jack); }
@Override protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd) throws ObjectNotFoundException, SchemaException { OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken"); Task task = taskManager.getTask(syncTaskOid, result); result.computeStatus(); TestUtil.assertSuccess(result); PrismProperty<String> syncTokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN); assertNotNull("No sync token in " + task, syncTokenProperty); String syncToken = syncTokenProperty.getRealValue(); assertNotNull("No sync token in " + task, syncToken); IntegrationTestTools.display("Sync token", syncToken); GeneralizedTime syncTokenGt; try { syncTokenGt = new GeneralizedTime(syncToken); } catch (ParseException e) { throw new RuntimeException(e.getMessage(), e); } TestUtil.assertBetween( "Wrong time in sync token: " + syncToken, roundTsDown(tsStart), roundTsUp(tsEnd), syncTokenGt.getCalendar().getTimeInMillis()); }
@Test public void test410TestResource() throws Exception { final String TEST_NAME = "test410TestResource"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); PrismProperty<ScriptingExpressionType> expression = parseAnyData(TEST_DUMMY_RESOURCE_FILE); // WHEN ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression( expression.getAnyValue().getValue(), result); // THEN IntegrationTestTools.display("output", output.getFinalOutput()); IntegrationTestTools.display("stdout", output.getConsoleOutput()); ResourceType dummy = modelService .getObject( ResourceType.class, RESOURCE_DUMMY_OID, null, taskManager.createTaskInstance(), result) .asObjectable(); IntegrationTestTools.display("dummy resource after test connection", dummy.asPrismObject()); IntegrationTestTools.display(result); result.computeStatus(); TestUtil.assertSuccess(result); assertEquals(1, output.getFinalOutput().getData().size()); assertEquals( "Tested resource:10000000-0000-0000-0000-000000000004(Dummy Resource): SUCCESS\n", output.getConsoleOutput()); }
@Test public void test100AddUserJack() throws Exception { final String TEST_NAME = "test100AddUserJack"; displayTestTitle(TEST_NAME); LogfileTestTailer tailer = createLogTailer(); UserType userNobody = ModelClientUtil.unmarshallFile(USER_JACK_FILE); XMLGregorianCalendar startTs = TestUtil.currentTime(); // WHEN String oid = addObject(userNobody); // THEN XMLGregorianCalendar endTs = TestUtil.currentTime(); tailer.tail(); displayAudit(tailer); assertAuditLoginLogout(tailer); assertAuditIds(tailer); assertAuditOperation(tailer, "ADD_OBJECT"); tailer.assertAudit(4); // GET user UserType userAfter = getObject(UserType.class, USER_JACK_OID); display(userAfter); assertUser(userAfter, oid, USER_JACK_USERNAME, USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME); assertCreateMetadata(userAfter, USER_ADMINISTRATOR_OID, startTs, endTs); assertPasswordCreateMetadata(userAfter, USER_ADMINISTRATOR_OID, startTs, endTs); }
@Test public void test420NotificationAboutJack() throws Exception { final String TEST_NAME = "test420NotificationAboutJack"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); PrismProperty<ScriptingExpressionType> expression = parseAnyData(NOTIFICATION_ABOUT_JACK_FILE); prepareNotifications(); // WHEN ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression( expression.getAnyValue().getValue(), result); // THEN IntegrationTestTools.display("output", output.getFinalOutput()); IntegrationTestTools.display("stdout", output.getConsoleOutput()); result.computeStatus(); TestUtil.assertSuccess(result); assertEquals(0, output.getFinalOutput().getData().size()); assertEquals("Produced 1 event(s)\n", output.getConsoleOutput()); IntegrationTestTools.display("Dummy transport", dummyTransport); checkDummyTransportMessages("Custom", 1); Message m = dummyTransport.getMessages("dummy:Custom").get(0); assertEquals("Wrong message body", "jack/" + USER_JACK_OID, m.getBody()); assertEquals("Wrong message subject", "Ad hoc notification", m.getSubject()); }
@Test public void test110AssignOpenDJAccountToJack() throws Exception { final String TEST_NAME = "test110AssignOpenDJAccountToJack"; displayTestTitle(TEST_NAME); LogfileTestTailer tailer = createLogTailer(); XMLGregorianCalendar startTs = TestUtil.currentTime(); ObjectDeltaType delta = ModelClientUtil.createConstructionAssignDelta( UserType.class, USER_JACK_OID, RESOURCE_OPENDJ_OID); // WHEN ObjectDeltaOperationListType executedDeltas = modelPort.executeChanges(ModelClientUtil.createDeltaList(delta), null); // THEN XMLGregorianCalendar endTs = TestUtil.currentTime(); assertSuccess(executedDeltas); tailer.tail(); displayAudit(tailer); assertAuditLoginLogout(tailer); assertAuditIds(tailer); assertAuditOperation(tailer, "MODIFY_OBJECT"); tailer.assertAudit(4); // GET user UserType userAfter = getObject(UserType.class, USER_JACK_OID); display(userAfter); assertUser( userAfter, USER_JACK_OID, USER_JACK_USERNAME, USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME); assertModifyMetadata(userAfter, USER_ADMINISTRATOR_OID, startTs, endTs); accountJackOid = getSingleLinkOid(userAfter); assertNotNull(accountJackOid); SearchResultEntry ldapEntry = openDJController.fetchEntry( "uid=" + USER_JACK_USERNAME + "," + openDJController.getSuffixPeople()); display(ldapEntry.toLDIFString()); OpenDJController.assertAttribute(ldapEntry, "uid", "jack"); OpenDJController.assertAttribute(ldapEntry, "givenName", "Jack"); OpenDJController.assertAttribute(ldapEntry, "sn", "Sparrow"); OpenDJController.assertAttribute(ldapEntry, "cn", "Jack Sparrow"); OpenDJController.assertAttribute(ldapEntry, "displayName", "Jack Sparrow"); }
@Test public void test110ChangeModifyObject() throws Exception { final String TEST_NAME = "test110ChangeModifyObject"; TestUtil.displayTestTile(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith"); Set<Operation> changes = new HashSet<Operation>(); changes.add(createAddAttributeChange("employeeNumber", "123123123")); changes.add(createReplaceAttributeChange("sn", "Smith007")); changes.add(createAddAttributeChange("street", "Wall Street")); changes.add(createDeleteAttributeChange("givenName", "John")); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition( ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME); cc.modifyObject(accountDefinition, identifiers, changes, result); ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers); PrismObject<ShadowType> shadow = cc.fetchObject(ShadowType.class, identification, null, result); ResourceAttributeContainer resObj = ShadowUtil.getAttributesContainer(shadow); AssertJUnit.assertNull( resObj.findAttribute( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "givenName"))); String addedEmployeeNumber = resObj .findAttribute( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "employeeNumber")) .getValue(String.class) .getValue(); String changedSn = resObj .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn")) .getValues(String.class) .iterator() .next() .getValue(); String addedStreet = resObj .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "street")) .getValues(String.class) .iterator() .next() .getValue(); System.out.println("changed employee number: " + addedEmployeeNumber); System.out.println("changed sn: " + changedSn); System.out.println("added street: " + addedStreet); AssertJUnit.assertEquals("123123123", addedEmployeeNumber); AssertJUnit.assertEquals("Smith007", changedSn); AssertJUnit.assertEquals("Wall Street", addedStreet); }
@Test public void test010ConnectorSchemaSanity() throws Exception { final String TEST_NAME = "test010ConnectorSchemaSanity"; TestUtil.displayTestTile(TEST_NAME); ProvisioningTestUtil.assertConnectorSchemaSanity(connectorSchema, "LDAP connector"); }
@Test public void test100AddDeleteObject() throws Exception { final String TEST_NAME = "test100AddDeleteObject"; TestUtil.displayTestTile(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith"); String uid = null; for (ResourceAttribute<?> resourceAttribute : identifiers) { if (ConnectorFactoryIcfImpl.ICFS_UID.equals(resourceAttribute.getElementName())) { uid = resourceAttribute.getValue(String.class).getValue(); System.out.println("uuuuid:" + uid); assertNotNull(uid); } } ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition( ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME); cc.deleteObject(accountDefinition, null, identifiers, result); ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers); PrismObject<ShadowType> resObj = null; try { resObj = cc.fetchObject(ShadowType.class, identification, null, result); Assert.fail(); } catch (ObjectNotFoundException ex) { AssertJUnit.assertNull(resObj); } }
protected void setDefaultUserTemplate(String userTemplateOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { PrismObjectDefinition<SystemConfigurationType> objectDefinition = prismContext .getSchemaRegistry() .findObjectDefinitionByCompileTimeClass(SystemConfigurationType.class); Collection<? extends ItemDelta> modifications; if (userTemplateOid == null) { modifications = ReferenceDelta.createModificationReplaceCollection( SystemConfigurationType.F_DEFAULT_USER_TEMPLATE_REF, objectDefinition, null); } else { PrismReferenceValue userTemplateRefVal = new PrismReferenceValue(userTemplateOid); modifications = ReferenceDelta.createModificationReplaceCollection( SystemConfigurationType.F_DEFAULT_USER_TEMPLATE_REF, objectDefinition, userTemplateRefVal); } OperationResult result = new OperationResult("Aplying default user template"); repositoryService.modifyObject( SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, result); display("Aplying default user template result", result); result.computeStatus(); TestUtil.assertSuccess("Aplying default user template failed (result)", result); }
// This obviously does not work with LDAP connector @Test(enabled = false) public void testDisableAccount() throws Exception { TestUtil.displayTestTile(this, "testDisableAccount"); // GIVEN OperationResult result = new OperationResult(this.getClass().getName() + ".testDisableAccount"); Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("blackbeard", "Edward", "Teach"); // Check precondition String entryUuid = getEntryUuid(identifiers); SearchResultEntry ldapEntryBefore = openDJController.searchAndAssertByEntryUuid(entryUuid); assertTrue("The account is not enabled", openDJController.isAccountEnabled(ldapEntryBefore)); // WHEN Set<Operation> changes = new HashSet<Operation>(); changes.add(createActivationChange(ActivationStatusType.DISABLED)); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); cc.modifyObject(accountDefinition, identifiers, changes, result); // THEN SearchResultEntry ldapEntryAfter = openDJController.searchAndAssertByEntryUuid(entryUuid); assertFalse("The account was not disabled", openDJController.isAccountEnabled(ldapEntryAfter)); }
@Test public void test320GetResourceNoJars() throws Exception { TestUtil.displayTestTile(this, "test320GetResourceNoJars"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test320GetResourceNoJars"); OperationResult result = task.getResult(); // WHEN PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_NOJARS_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); }
/** * Simple call to connector test() method. * * @throws Exception */ @Test public void test310TestConnectionNegative() throws Exception { final String TEST_NAME = "test310TestConnectionNegative"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(TEST_NAME); ConnectorInstance badConnector = factory.createConnectorInstance( connectorType, ResourceTypeUtil.getResourceNamespace(badResourceType), "test connector"); badConnector.configure( badResourceType.getConnectorConfiguration().asPrismContainerValue(), result); // WHEN badConnector.test(result); // THEN result.computeStatus("test failed"); display("Test result (FAILURE EXPECTED)", result); AssertJUnit.assertNotNull(result); OperationResult connectorConnectionResult = result.getSubresults().get(1); AssertJUnit.assertNotNull(connectorConnectionResult); System.out.println( "Test \"connector connection\" result: " + connectorConnectionResult + " (FAILURE EXPECTED)"); AssertJUnit.assertTrue( "Unexpected success of bad connector test", !connectorConnectionResult.isSuccess()); AssertJUnit.assertTrue(!result.isSuccess()); }
@Test public void test500FetchObject() throws Exception { final String TEST_NAME = "test500FetchObject"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN ResourceAttributeContainer resourceObject = createResourceObject("uid=Teell,ou=People,dc=example,dc=com", "Teell William", "Teell"); OperationResult addResult = new OperationResult(this.getClass().getName() + "." + TEST_NAME); PrismObject<ShadowType> shadow = wrapInShadow(ShadowType.class, resourceObject); // Add a testing object cc.addObject(shadow, null, addResult); ObjectClassComplexTypeDefinition accountDefinition = resourceObject.getDefinition().getComplexTypeDefinition(); Collection<ResourceAttribute<?>> identifiers = resourceObject.getIdentifiers(); // Determine object class from the schema ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); // WHEN PrismObject<ShadowType> ro = cc.fetchObject(ShadowType.class, identification, null, result); // THEN AssertJUnit.assertNotNull(ro); System.out.println("Fetched object " + ro); System.out.println("Result:"); System.out.println(result.debugDump()); }
@Test public void testAddDeleteObject() throws Exception { TestUtil.displayTestTile(this, "testDeleteObject"); OperationResult result = new OperationResult(this.getClass().getName() + ".testDelete"); Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith"); String uid = null; for (ResourceAttribute<?> resourceAttribute : identifiers) { if (ConnectorFactoryIcfImpl.ICFS_UID.equals(resourceAttribute.getElementName())) { uid = resourceAttribute.getValue(String.class).getValue(); System.out.println("uuuuid:" + uid); assertNotNull(uid); } } ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); cc.deleteObject(accountDefinition, null, identifiers, result); PrismObject<ShadowType> resObj = null; try { resObj = cc.fetchObject(ShadowType.class, accountDefinition, identifiers, null, result); Assert.fail(); } catch (ObjectNotFoundException ex) { AssertJUnit.assertNull(resObj); } }
@Test public void testSearch() throws UcfException, SchemaException, CommunicationException { TestUtil.displayTestTile("testSearch"); // GIVEN ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); // Determine object class from the schema ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() { @Override public boolean handle(PrismObject<ShadowType> object) { System.out.println("Search: found: " + object); return true; } }; OperationResult result = new OperationResult(this.getClass().getName() + ".testSearch"); // WHEN cc.search(accountDefinition, new ObjectQuery(), handler, null, result); // THEN }
/** * 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(TestModelServiceContract.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 = dummyResource.getAccountByUsername(USER_JACK_USERNAME); assertNotNull("No jack dummy account", jackDummyAccount); }
@Test public void test310TestResourceNoJars() throws Exception { TestUtil.displayTestTile(this, "test310TestResourceNoJars"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test310TestResourceNoJars"); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_NOJARS_OID, task); // THEN display("testResource result", testResult); TestUtil.assertFailure("testResource result", testResult); }
@Test public void test510Search() throws Exception { final String TEST_NAME = "test510Search"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition( ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME); // Determine object class from the schema ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() { @Override public boolean handle(PrismObject<ShadowType> object) { System.out.println("Search: found: " + object); return true; } }; OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); // WHEN cc.search(accountDefinition, new ObjectQuery(), handler, null, null, null, result); // THEN }
@Test public void test400PurgeSchema() throws Exception { final String TEST_NAME = "test400PurgeSchema"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); Task task = taskManager.createTaskInstance(); PrismProperty<ScriptingExpressionType> expression = parseAnyData(PURGE_DUMMY_BLACK_SCHEMA_FILE); // ResourceType dummy = modelService.getObject(ResourceType.class, // RESOURCE_DUMMY_BLACK_OID, null, task, result).asObjectable(); // IntegrationTestTools.display("dummy resource before purge schema", // dummy.asPrismObject()); // IntegrationTestTools.display("elements: " + // dummy.getSchema().getDefinition().getAny().get(0).getElementsByTagName("*").getLength()); // IntegrationTestTools.display("schema as XML: " + // DOMUtil.printDom(dummy.getSchema().getDefinition().getAny().get(0))); // WHEN ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression( expression.getAnyValue().getValue(), result); // THEN IntegrationTestTools.display("output", output.getFinalOutput()); IntegrationTestTools.display("stdout", output.getConsoleOutput()); IntegrationTestTools.display(result); result.computeStatus(); TestUtil.assertSuccess(result); assertEquals(1, output.getFinalOutput().getData().size()); // dummy = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_BLACK_OID, // null, result).asObjectable(); // IntegrationTestTools.display("dummy resource from repo", dummy.asPrismObject()); // IntegrationTestTools.display("elements: " + // dummy.getSchema().getDefinition().getAny().get(0).getElementsByTagName("*").getLength()); // IntegrationTestTools.display("schema as XML: " + // DOMUtil.printDom(dummy.getSchema().getDefinition().getAny().get(0))); // AssertJUnit.assertNull("Schema is still present", dummy.getSchema()); // actually, schema gets downloaded just after purging it assertEquals( "Purged schema information from resource:10000000-0000-0000-0000-000000000305(Dummy Resource Black)\n", output.getConsoleOutput()); }
@Test public void test010TestResourceBroken() throws Exception { TestUtil.displayTestTile(this, "test010TestResourceBroken"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test010TestResourceBroken"); OperationResult result = task.getResult(); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_CSVFILE_BROKEN_OID, task); // THEN display("testResource result", testResult); TestUtil.assertSuccess("testResource result", testResult); }
@Test public void test210TestResourceNotFound() throws Exception { TestUtil.displayTestTile(this, "test210TestResourceNotFound"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test210TestResourceNotFound"); OperationResult result = task.getResult(); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_CSVFILE_NOTFOUND_OID, task); // THEN display("testResource result", testResult); TestUtil.assertFailure("testResource result", testResult); }
@Test public void test020AddResourceOpenDj() throws Exception { final String TEST_NAME = "test020AddResourceOpenDj"; displayTestTitle(TEST_NAME); LogfileTestTailer tailer = createLogTailer(); ResourceType resource = ModelClientUtil.unmarshallFile(RESOURCE_OPENDJ_FILE); ObjectDeltaListType deltaList = new ObjectDeltaListType(); ObjectDeltaType delta = new ObjectDeltaType(); delta.setObjectType(getTypeQName(ResourceType.class)); delta.setChangeType(ChangeTypeType.ADD); delta.setObjectToAdd(resource); deltaList.getDelta().add(delta); ModelExecuteOptionsType options = new ModelExecuteOptionsType(); options.setIsImport(Boolean.TRUE); XMLGregorianCalendar startTs = TestUtil.currentTime(); // WHEN ObjectDeltaOperationListType deltaOpList = modelPort.executeChanges(deltaList, options); // THEN assertSuccess(deltaOpList); String oid = deltaOpList.getDeltaOperation().get(0).getObjectDelta().getOid(); XMLGregorianCalendar endTs = TestUtil.currentTime(); tailer.tail(); displayAudit(tailer); assertAuditLoginLogout(tailer); assertAuditIds(tailer); assertAuditOperation(tailer, "ADD_OBJECT"); tailer.assertAudit(4); assertEquals("Wrong OID", RESOURCE_OPENDJ_OID, oid); ResourceType resourceAfter = getObject(ResourceType.class, RESOURCE_OPENDJ_OID); display(resourceAfter); assertEquals("Wrong connector OID", connectorLdapOid, resourceAfter.getConnectorRef().getOid()); assertCreateMetadata(resourceAfter, USER_ADMINISTRATOR_OID, startTs, endTs); }
@Test public void test110EmptyPipeline() throws Exception { final String TEST_NAME = "test110EmptyPipeline"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); ExpressionPipelineType pipeline = new ExpressionPipelineType(); ObjectFactory of = new ObjectFactory(); // WHEN ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(pipeline, result); // THEN assertNoOutputData(output); result.computeStatus(); TestUtil.assertSuccess(result); }