diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java index d5286a82407..8014277a4b4 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java @@ -369,7 +369,7 @@ public static void assertUserJackContent(PrismObject user, boolean exp if (withIncomplete) { assertTrue("Assignment is not incomplete", assContainer.isIncomplete()); } - assertEquals("Wrong assignement values", 2, assContainer.getValues().size()); + assertEquals("Wrong assignment values", 2, assContainer.getValues().size()); PrismProperty a2DescProperty = assContainer.getValue(USER_ASSIGNMENT_2_ID).findProperty(descriptionName); assertEquals("Wrong assigment 2 description", "Assignment 2", a2DescProperty.getValue().getValue()); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java index fff0f03b674..58dd11f431d 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java @@ -1167,7 +1167,7 @@ mappingFileName, getTestNameShort(), valuePolicyType, null) .build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN (1) mapping.evaluate(createTask(), opResult); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java index 3670441d781..3a5c8927980 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java @@ -33,8 +33,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; @@ -99,7 +97,7 @@ public void testScriptSystemVariablesConditionModifyObjectTrueGroovyUnrelated() "mapping-script-system-variables-condition-groovy.xml", shortTestName, "title", delta); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -130,7 +128,7 @@ public void testScriptSystemVariablesConditionAddObjectFalse(String filename) th MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -161,7 +159,7 @@ public void testScriptSystemVariablesConditionAddObjectFalseNoVal(String filenam MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -191,7 +189,7 @@ public void testScriptSystemVariablesConditionAddObjectFalseNoProperty(String fi MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -220,7 +218,7 @@ public void testScriptSystemVariablesConditionTrueToTrue(String filename) throws user.asObjectable().getEmployeeType().add("CAPTAIN"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -247,7 +245,7 @@ public void testScriptSystemVariablesConditionFalseToFalse(String filename) thro MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -273,7 +271,7 @@ public void testScriptSystemVariablesConditionFalseToTrue(String filename) throw MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -305,7 +303,7 @@ public void testScriptSystemVariablesConditionTrueToFalse(String filename) throw user.asObjectable().getEmployeeType().add("CAPTAIN"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -357,7 +355,7 @@ public void testScriptSystemVariablesConditionEmptyTrue(final String shortTestNa user.asObjectable().setEmployeeNumber(null); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -381,8 +379,8 @@ public void testScriptSystemVariablesConditionEmptySingleFalseToTrueFunction() t testScriptSystemVariablesConditionEmptyFalseToTrue(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String shortTestName, String filename) throws Exception { - + public void testScriptSystemVariablesConditionEmptyFalseToTrue( + final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -396,7 +394,7 @@ public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String shor user.asObjectable().setEmployeeNumber("666"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -448,7 +446,7 @@ public void testScriptSystemVariablesConditionEmptyFalse(final String shortTestN user.asObjectable().setEmployeeNumber("666"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -470,7 +468,8 @@ public void testScriptSystemVariablesConditionEmptySingleTrueToFalseFunction() t testScriptSystemVariablesConditionEmptyTrueToFalse(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String shortTestName, String filename) throws Exception { + public void testScriptSystemVariablesConditionEmptyTrueToFalse( + final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() @@ -485,7 +484,7 @@ public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String shor user.asObjectable().setEmployeeNumber(null); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -508,7 +507,7 @@ public void testNpeFalseToTrue() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-npe.xml", shortTestName, "title", delta); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -535,7 +534,7 @@ public void testNpeTrueToFalse() throws Exception { user.asObjectable().setAdditionalName(PrismTestUtil.createPolyStringType("Sultan of the Caribbean")); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -558,7 +557,7 @@ public void testPathEnum() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-path-enum.xml", shortTestName, "costCenter", delta); - OperationResult opResult = new OperationResult(shortTestName); + OperationResult opResult = createOperationResult(); // WHEN System.out.println("WHEN"); @@ -708,7 +707,7 @@ public void testEmployeeTypeDeltaAreplaceB() throws Exception { setEmployeeType(user.asObjectable(), "A"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(getTestNameShort()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -736,7 +735,7 @@ public void testEmployeeTypeDeltaNullreplaceB() throws Exception { setEmployeeType(user.asObjectable()); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(getTestNameShort()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -764,7 +763,7 @@ public void testEmployeeTypeDeltaBreplaceB() throws Exception { setEmployeeType(user.asObjectable(), "B"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(getTestNameShort()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -840,7 +839,7 @@ public PrismValueDeltaSetTriple> employeeTypeDeltaABA setEmployeeType(user.asObjectable(), oldVals); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(getTestNameShort()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -920,7 +919,7 @@ public PrismValueDeltaSetTriple> employeeTypeDeltaDel setEmployeeType(user.asObjectable(), oldVals); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(getTestNameShort()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java index 8ddd90e0c7a..c3ba0fda321 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java @@ -30,6 +30,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.test.NullTaskImpl; +import com.evolveum.midpoint.test.util.OperationResultTestMixin; import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.SchemaException; @@ -39,7 +40,8 @@ /** * @author Radovan Semancik */ -public class TestMappingTime extends AbstractUnitTest { +public class TestMappingTime extends AbstractUnitTest + implements OperationResultTestMixin { private static final String MAPPING_TIME_FROM_TO_FILENAME = "mapping-time-from-to.xml"; private static final String MAPPING_TIME_ACTIVATION = "mapping-time-deferred-delete.xml"; @@ -62,7 +64,7 @@ public void setupFactory() throws SAXException, IOException, SchemaException { public void testBeforeTimeFrom() throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "CAPTAIN"); MappingImpl.Builder, PrismPropertyDefinition> builder = @@ -72,7 +74,7 @@ public void testBeforeTimeFrom() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -91,7 +93,7 @@ private Task createTask() { public void testBetweenTimes() throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "CAPTAIN"); MappingImpl.Builder, PrismPropertyDefinition> builder = @@ -101,7 +103,7 @@ public void testBetweenTimes() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -119,7 +121,7 @@ public void testBetweenTimes() throws Exception { public void testAfterTimeTo() throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "CAPTAIN"); MappingImpl.Builder, PrismPropertyDefinition> builder = @@ -129,7 +131,7 @@ public void testAfterTimeTo() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -157,7 +159,7 @@ public void testExistenceBefore() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -185,7 +187,7 @@ public void testExistenceAfter() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -218,7 +220,7 @@ public void testNoReferenceTime() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -238,7 +240,7 @@ public void testSetReferenceTimeBefore() throws Exception { userOld.asObjectable().getActivation().setDisableTimestamp(null); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_DISABLE_TIMESTAMP), disableTimestamp); @@ -255,7 +257,7 @@ public void testSetReferenceTimeBefore() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); @@ -275,7 +277,7 @@ public void testSetReferenceTimeAfter() throws Exception { userOld.asObjectable().getActivation().setDisableTimestamp(null); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_DISABLE_TIMESTAMP), disableTimestamp); @@ -292,7 +294,7 @@ public void testSetReferenceTimeAfter() throws Exception { MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(contextName()); + OperationResult opResult = createOperationResult(); // WHEN mapping.evaluate(createTask(), opResult); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java index 8b1db12081a..2b3c2cc729e 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java @@ -115,7 +115,7 @@ public void test101EntitlementRefinedObjectClassesModel() { @Test public void test110DetermineObjectClassObjectClass() throws Exception { - OperationResult result = new OperationResult(getTestNameShort()); + OperationResult result = createOperationResult(); importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE); @@ -135,7 +135,7 @@ public void test110DetermineObjectClassObjectClass() throws Exception { @Test public void test112DetermineObjectClassKindIntent() throws Exception { - OperationResult result = new OperationResult(getTestNameShort()); + OperationResult result = createOperationResult(); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE); @@ -155,7 +155,7 @@ public void test112DetermineObjectClassKindIntent() throws Exception { @Test public void test114DetermineObjectClassKindIntentObjectClass() throws Exception { - OperationResult result = new OperationResult(getTestNameShort()); + OperationResult result = createOperationResult(); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE); @@ -175,7 +175,7 @@ public void test114DetermineObjectClassKindIntentObjectClass() throws Exception @Test public void test120DetermineObjectClassObjectClassModel() throws Exception { - OperationResult result = new OperationResult(getTestNameShort()); + OperationResult result = createOperationResult(); importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE); @@ -196,7 +196,7 @@ public void test120DetermineObjectClassObjectClassModel() throws Exception { @Test public void test122DetermineObjectClassKindIntentModel() throws Exception { - OperationResult result = new OperationResult(getTestNameShort()); + OperationResult result = createOperationResult(); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE); @@ -218,7 +218,7 @@ public void test122DetermineObjectClassKindIntentModel() throws Exception { @Test public void test124DetermineObjectClassKindIntentObjectClassModel() throws Exception { - OperationResult result = new OperationResult(getTestNameShort()); + OperationResult result = createOperationResult(); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/AbstractLensTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/AbstractLensTest.java index 7c1b51f6d87..9bf9843c602 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/AbstractLensTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/AbstractLensTest.java @@ -6,43 +6,38 @@ */ package com.evolveum.midpoint.model.impl.lens; +import static org.testng.AssertJUnit.*; + import java.io.File; import java.util.*; import java.util.function.Consumer; -import javax.xml.bind.JAXBException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; import com.evolveum.midpoint.model.api.context.AssignmentPath; import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger; +import com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest; +import com.evolveum.midpoint.model.impl.lens.projector.Projector; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.delta.DeltaSetTriple; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.TestResource; +import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; - -import com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest; -import com.evolveum.midpoint.model.impl.lens.projector.Projector; -import com.evolveum.midpoint.task.api.TaskManager; -import com.evolveum.midpoint.test.util.MidPointTestConstants; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractLensTest extends AbstractInternalModelIntegrationTest { @@ -167,11 +162,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // repoAddObjectFromFile(USER_DRAKE_FILE, initResult); } - protected AssignmentType getAssignmentType(File assignmentFile) throws java.io.IOException, JAXBException, SchemaException { - AssignmentType assignmentType = unmarshallValueFromFile(assignmentFile, AssignmentType.class); + protected AssignmentType getAssignmentType(File assignmentFile) throws java.io.IOException, SchemaException { + AssignmentType assignmentType = unmarshalValueFromFile(assignmentFile, AssignmentType.class); // We need to make sure that the assignment has a parent - PrismContainerDefinition assignmentContainerDefinition = userTypeJack.asPrismObject().getDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); + PrismContainerDefinition assignmentContainerDefinition = + userTypeJack.asPrismObject().getDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); PrismContainer assignmentContainer = assignmentContainerDefinition.instantiate(); assignmentContainer.add(assignmentType.asPrismContainerValue().clone()); return assignmentType; @@ -204,7 +200,7 @@ void assertTargetTriggers(LensContext context, PolicyConstr display("Selected trigger", trigger); triggers.add(trigger); }); - assertEquals("Unexpected number of triggers ("+selectedConstraintKind+") in the context", expectedCount, triggers.size()); + assertEquals("Unexpected number of triggers (" + selectedConstraintKind + ") in the context", expectedCount, triggers.size()); } void assertTargetTriggers(LensContext context, PolicyConstraintKindType selectedConstraintKind, String... expectedConstraintNames) { @@ -220,7 +216,7 @@ void assertTargetTriggers(LensContext context, PolicyConstr triggersFound.add(trigger); namesFound.add(trigger.getConstraint().getName()); }); - assertEquals("Unexpected number of triggers ("+selectedConstraintKind+") in the context", expectedConstraintNames.length, triggersFound.size()); + assertEquals("Unexpected number of triggers (" + selectedConstraintKind + ") in the context", expectedConstraintNames.length, triggersFound.size()); assertEquals("Unexpected constraint names", new HashSet<>(expectedNamesList), namesFound); } @@ -234,7 +230,7 @@ void assertFocusTriggers(LensContext context, PolicyConstra display("Selected trigger", trigger); triggers.add(trigger); }); - assertEquals("Unexpected number of focus triggers ("+selectedConstraintKind+") in the context", expectedCount, triggers.size()); + assertEquals("Unexpected number of focus triggers (" + selectedConstraintKind + ") in the context", expectedCount, triggers.size()); } void assertFocusTriggers(LensContext context, PolicyConstraintKindType selectedConstraintKind, String... expectedConstraintNames) { @@ -250,7 +246,7 @@ void assertFocusTriggers(LensContext context, PolicyConstra triggersFound.add(trigger); namesFound.add(trigger.getConstraint().getName()); }); - assertEquals("Unexpected number of triggers ("+selectedConstraintKind+") in the context", expectedConstraintNames.length, triggersFound.size()); + assertEquals("Unexpected number of triggers (" + selectedConstraintKind + ") in the context", expectedConstraintNames.length, triggersFound.size()); assertEquals("Unexpected constraint names", new HashSet<>(expectedNamesList), namesFound); } @@ -264,7 +260,7 @@ protected EvaluatedPolicyRuleTrigger assertTriggeredTargetPolicyRule(LensContext display("Triggered rule", trigger); triggers.add(trigger); if (expectedConstraintKind != null) { - assertEquals("Wrong trigger constraint type in "+trigger, expectedConstraintKind, trigger.getConstraintKind()); + assertEquals("Wrong trigger constraint type in " + trigger, expectedConstraintKind, trigger.getConstraintKind()); } }); assertEquals("Unexpected number of triggered policy rules in the context", expectedCount, triggers.size()); @@ -301,7 +297,7 @@ protected EvaluatedPolicyRule getTriggeredFocusPolicyRule(LensContext context, String targetOid, Consumer handler) { forEvaluatedTargetPolicyRule(context, targetOid, rule -> { Collection> triggers = rule.getTriggers(); - for (EvaluatedPolicyRuleTrigger trigger: triggers) { + for (EvaluatedPolicyRuleTrigger trigger : triggers) { handler.accept(trigger); } }); @@ -310,7 +306,7 @@ protected void forTriggeredTargetPolicyRule(LensContext con protected void forTriggeredFocusPolicyRule(LensContext context, Consumer handler) { forEvaluatedFocusPolicyRule(context, rule -> { Collection> triggers = rule.getTriggers(); - for (EvaluatedPolicyRuleTrigger trigger: triggers) { + for (EvaluatedPolicyRuleTrigger trigger : triggers) { handler.accept(trigger); } }); @@ -319,7 +315,7 @@ protected void forTriggeredFocusPolicyRule(LensContext cont private void forEvaluatedTargetPolicyRule(LensContext context, String targetOid, Consumer handler) { //noinspection unchecked DeltaSetTriple> evaluatedAssignmentTriple = - (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); + (DeltaSetTriple) context.getEvaluatedAssignmentTriple(); evaluatedAssignmentTriple.simpleAccept(assignment -> { if (targetOid == null || assignment.getTarget() != null && targetOid.equals(assignment.getTarget().getOid())) { assignment.getAllTargetsPolicyRules().forEach(handler); @@ -330,7 +326,7 @@ private void forEvaluatedTargetPolicyRule(LensContext conte void forEvaluatedFocusPolicyRule(LensContext context, Consumer handler) { //noinspection unchecked DeltaSetTriple> evaluatedAssignmentTriple = - (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); + (DeltaSetTriple) context.getEvaluatedAssignmentTriple(); evaluatedAssignmentTriple.simpleAccept(assignment -> assignment.getFocusPolicyRules().forEach(handler)); } @@ -356,20 +352,25 @@ protected void assertAssignmentPath(AssignmentPath path, String... targetOids) { for (int i = 0; i < targetOids.length; i++) { ObjectType target = path.getSegments().get(i).getTarget(); if (targetOids[i] == null) { - assertNull("Target #" + (i+1) + " should be null; it is: " + target, target); + assertNull("Target #" + (i + 1) + " should be null; it is: " + target, target); } else { - assertNotNull("Target #" + (i+1) + " should not be null", target); - assertEquals("Wrong OID in target #" + (i+1), targetOids[i], target.getOid()); + assertNotNull("Target #" + (i + 1) + " should not be null", target); + assertEquals("Wrong OID in target #" + (i + 1), targetOids[i], target.getOid()); } } } - protected void assertAssignmentPolicySituation(LensContext context, String roleOid, String... uris) { - AssignmentType assignment = findAssignmentByTargetRequired(context.getFocusContext().getObjectNew(), roleOid); - PrismAsserts.assertEqualsCollectionUnordered("Wrong assignment policy situation", assignment.getPolicySituation(), uris); + protected void assertAssignmentPolicySituation( + LensContext context, String roleOid, String... uris) { + AssignmentType assignment = findAssignmentByTargetRequired( + context.getFocusContext().getObjectNew(), roleOid); + PrismAsserts.assertEqualsCollectionUnordered( + "Wrong assignment policy situation", assignment.getPolicySituation(), uris); } - protected void assertFocusPolicySituation(LensContext context, String... uris) { - PrismAsserts.assertEqualsCollectionUnordered("Wrong focus policy situation", context.getFocusContext().getObjectNew().asObjectable().getPolicySituation(), uris); + protected void assertFocusPolicySituation( + LensContext context, String... uris) { + PrismAsserts.assertEqualsCollectionUnordered("Wrong focus policy situation", + context.getFocusContext().getObjectNew().asObjectable().getPolicySituation(), uris); } } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java index 87ef0879626..816aee847c3 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java @@ -179,7 +179,7 @@ public void test120DirectExpressionReplaceDescription() throws Exception { OperationResult result = task.getResult(); PrismObject user = userTypeJack.asPrismObject().clone(); - AssignmentType assignmentType = unmarshallValueFromFile(ASSIGNMENT_DIRECT_EXPRESSION_FILE, AssignmentType.class); + AssignmentType assignmentType = unmarshalValueFromFile(ASSIGNMENT_DIRECT_EXPRESSION_FILE, AssignmentType.class); user.asObjectable().getAssignment().add(assignmentType.clone()); ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT, 123L, AssignmentType.F_DESCRIPTION); @@ -240,7 +240,7 @@ public void test130DirectExpressionReplaceDescriptionFromNull() throws Exception OperationResult result = task.getResult(); PrismObject user = userTypeJack.asPrismObject().clone(); - AssignmentType assignmentType = unmarshallValueFromFile(ASSIGNMENT_DIRECT_EXPRESSION_FILE, AssignmentType.class); + AssignmentType assignmentType = unmarshalValueFromFile(ASSIGNMENT_DIRECT_EXPRESSION_FILE, AssignmentType.class); assignmentType.setDescription(null); user.asObjectable().getAssignment().add(assignmentType.clone()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java index c7b63870f1e..e847e7da6a1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java @@ -110,7 +110,7 @@ public void test101ModifyUserSubtypePirate() throws Exception { /** * Switch subtype from PIRATE to BUCCANEER. This makes one condition to go false and the other to go - * true. For the same role assignement value. So nothing should be changed. + * true. For the same role assignment value. So nothing should be changed. */ @Test public void test102ModifyUserSubtypeBuccaneer() throws Exception { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java index e7e000251e5..fadbc318e97 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java @@ -346,7 +346,7 @@ public void test014Configuration() throws Exception { PrismContainer configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertNotNull("No configuration container", configurationContainer); - PrismContainerDefinition confContDef = configurationContainer.getDefinition(); + PrismContainerDefinition confContDef = configurationContainer.getDefinition(); assertNotNull("No configuration container definition", confContDef); PrismProperty propDefaultAssignee = configurationContainer.findProperty(CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME); assertNotNull("No defaultAssignee conf prop", propDefaultAssignee); @@ -1702,15 +1702,16 @@ public void test910ConcurrentRolesAssign() throws Exception { // WHEN when(); - + String testName = getTestNameShort(); ParallelTestThread[] threads = multithread( (i) -> { login(userAdministrator); - Task localTask = getTestTask(); + Task localTask = createTask(testName + "-thread-" + i); assignRole(USER_DRAKE_OID, getRoleOid(i), localTask, localTask.getResult()); - - }, getConcurrentTestNumberOfThreads(), getConcurrentTestRandomStartDelayRangeAssign()); + }, + getConcurrentTestNumberOfThreads(), + getConcurrentTestRandomStartDelayRangeAssign()); // THEN then(); @@ -1774,16 +1775,16 @@ public void test919ConcurrentRoleUnassign() throws Exception { display("user before", userBefore); assertAssignments(userBefore, getConcurrentTestNumberOfThreads()); - final long TIMEOUT = 60000L; + final long TIMEOUT = 60_000L; // WHEN when(); - + String testName = getTestNameShort(); ParallelTestThread[] threads = multithread( (i) -> { display("Thread " + Thread.currentThread().getName() + " START"); login(userAdministrator); - Task localTask = getTestTask(); + Task localTask = createTask(testName + "-thread-" + i); OperationResult localResult = localTask.getResult(); unassignRole(USER_DRAKE_OID, getRoleOid(i), localTask, localResult); @@ -1791,8 +1792,9 @@ public void test919ConcurrentRoleUnassign() throws Exception { localResult.computeStatus(); display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); - - }, getConcurrentTestNumberOfThreads(), getConcurrentTestRandomStartDelayRangeUnassign()); + }, + getConcurrentTestNumberOfThreads(), + getConcurrentTestRandomStartDelayRangeUnassign()); // THEN then(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java index 46fa677c7d8..6c27f506818 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java @@ -1547,7 +1547,7 @@ public void test168ModifyUserOrganization() throws Exception { } /** - * Note: red resource disables account on unsassign, does NOT delete it + * Note: red resource disables account on unassign, does NOT delete it */ @Test public void test178ModifyUserUnassignAccountRed() throws Exception { @@ -1602,7 +1602,7 @@ public void test178ModifyUserUnassignAccountRed() throws Exception { } /** - * Note: red resource disables account on unsassign, does NOT delete it + * Note: red resource disables account on unassign, does NOT delete it * So let's delete the account explicitly to make room for the following tests */ @Test diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java index 0ea5a788306..13c83574bc3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java @@ -1180,7 +1180,7 @@ public void test300AddAndAssignRelative() throws Exception { // Add default dummy account to jack without assigning it. // In relative mode this account should shay untouched while we play with assignments and - // unsassignements of other accounts + // unassignments of other accounts PrismObject account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE); ObjectDelta userDelta = prismContext.deltaFactory().object() .createEmptyModifyDelta(UserType.class, USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java index 1d0edaab98b..37bf55015a3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java @@ -1572,7 +1572,7 @@ public void test549JackUnassignRoleWannabe() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertNotAssignedRole(userAfter, ROLE_WANNABE_OID, result); + assertNotAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter); assertDelegatedRef(userAfter); @@ -2655,7 +2655,7 @@ public void test759JackUnassignRoleOmnimanager() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertNotAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID, result); + assertNotAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID); assertHasNoOrg(userAfter); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java index 8b148cdd5bf..23d4e398ebf 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java @@ -2864,7 +2864,7 @@ public void test281AutzJackEndUserSecondTime() throws Exception { } private void assertCredentialsPolicy(PrismObject user) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - OperationResult result = new OperationResult("assertCredentialsPolicy"); + OperationResult result = createOperationResult("assertCredentialsPolicy"); CredentialsPolicyType credentialsPolicy = modelInteractionService.getCredentialsPolicy(user, null, result); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java index 6ccb2337a2e..cc75bbd1946 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java @@ -1376,7 +1376,7 @@ public void test205AccountRedElaineDisable() throws Exception { } /** - * Note: red resource disables account on unsassign, does NOT delete it. + * Note: red resource disables account on unassign, does NOT delete it. * Just the recompute trigger is set */ @Test diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index cc2f5bfca17..d50774ae863 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -164,9 +164,11 @@ public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTe @Autowired protected DashboardService dashboardService; @Autowired protected ModelAuditService modelAuditService; @Autowired protected ModelPortType modelWeb; + @Autowired @Qualifier("cacheRepositoryService") protected RepositoryService repositoryService; + @Autowired @Qualifier("sqlRepositoryServiceImpl") protected RepositoryService plainRepositoryService; @@ -1558,8 +1560,8 @@ protected ObjectDelta createAssignmentDelta(Class ty String resourceOid, ShadowKindType kind, String intent, boolean add) throws SchemaException { Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(resourceOid, kind, intent, add)); - ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type - ); + ObjectDelta userDelta = prismContext.deltaFactory().object() + .createModifyDelta(focusOid, modifications, type); return userDelta; } @@ -1599,7 +1601,7 @@ protected ModelContext previewChanges(ObjectDelta o return modelInteractionService.previewChanges(deltas, options, task, result); } - protected void assignAccountToUser( + protected void assignAccountToUser( String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, @@ -1749,6 +1751,7 @@ protected Collection> listAccounts( RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); Collection identifierDefs = rAccount.getPrimaryIdentifiers(); assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; + // TODO any assert about this unused variable? ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); ObjectQuery query = prismContext.queryFor(ShadowType.class) .item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) @@ -1868,9 +1871,9 @@ protected ShadowAsserter assertShadow(String username, PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, Collection> options, Task task, - OperationResult result) + protected PrismObject findShadowByNameViaModel( + ShadowKindType kind, String intent, String name, PrismObject resource, + Collection> options, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); @@ -2192,11 +2195,6 @@ protected void assertDelegatedRef(PrismObject focus, St PrismAsserts.assertSets("Wrong values in delegatedRef in " + focus, refOids, oids); } - protected void assertNotAssignedRole( - PrismObject focus, String roleOid, OperationResult result) { - MidPointAsserts.assertNotAssignedRole(focus, roleOid); - } - protected void assertNotAssignedRole(String userOid, String roleOid, OperationResult result) throws ObjectNotFoundException, SchemaException { PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); @@ -2807,42 +2805,6 @@ protected ItemPath getIcfsNameAttributePath() { } - private void assertResolvedResourceRefs(ObjectDelta delta, String desc) { - if (delta == null) { - return; - } - if (delta.isAdd()) { - assertResolvedResourceRefs(delta.getObjectToAdd(), desc); - } else if (delta.isModify()) { - ReferenceDelta referenceDelta = delta.findReferenceModification(ShadowType.F_RESOURCE_REF); - if (referenceDelta != null) { - assertResolvedResourceRefs(referenceDelta.getValuesToAdd(), "valuesToAdd in " + desc); - assertResolvedResourceRefs(referenceDelta.getValuesToDelete(), "valuesToDelete in " + desc); - assertResolvedResourceRefs(referenceDelta.getValuesToReplace(), "valuesToReplace in " + desc); - } - } - } - - private void assertResolvedResourceRefs(PrismObject shadow, String desc) { - if (shadow == null) { - return; - } - PrismReference resourceRef = shadow.findReference(ShadowType.F_RESOURCE_REF); - if (resourceRef == null) { - AssertJUnit.fail("No resourceRef in " + desc); - } - assertResolvedResourceRefs(resourceRef.getValues(), desc); - } - - private void assertResolvedResourceRefs(Collection values, String desc) { - if (values == null) { - return; - } - for (PrismReferenceValue pval : values) { - assertNotNull("resourceRef in " + desc + " does not contain object", pval.getObject()); - } - } - /** * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to * existing user values. @@ -3162,8 +3124,8 @@ protected long getTreeRunDurationMillis(String rootTaskOid) throws ObjectNotFoun .max().orElse(0); } - protected void displayOperationStatistics(String label, OperationStatsType statistics) { - display(label, StatisticsUtil.format(statistics)); + protected void displayOperationStatistics(OperationStatsType statistics) { + display("Task operation statistics for " + getTestNameShort(), StatisticsUtil.format(statistics)); } @Nullable @@ -3259,7 +3221,8 @@ public void timeout() { IntegrationTestTools.waitFor("Waiting for task " + taskOid + " start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); } - protected void waitForTaskNextStart(String taskOid, boolean checkSubresult, int timeout, boolean kickTheTask) throws Exception { + protected void waitForTaskNextStart( + String taskOid, boolean checkSubresult, int timeout, boolean kickTheTask) throws Exception { OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskNextStart"); Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); @@ -5831,9 +5794,10 @@ protected TaskAsserter assertTask(TaskType task, String message) { return TaskAsserter.forTask(task.asPrismObject(), message); } - protected RepoOpAsserter createRepoOpAsserter(String details) { - PerformanceInformation repoPerformanceInformation = repositoryService.getPerformanceMonitor().getThreadLocalPerformanceInformation(); - return new RepoOpAsserter(repoPerformanceInformation, details); + protected RepoOpAsserter createRepoOpAsserter() { + PerformanceInformation repoPerformanceInformation = + repositoryService.getPerformanceMonitor().getThreadLocalPerformanceInformation(); + return new RepoOpAsserter(repoPerformanceInformation, getTestNameShort()); } protected UserAsserter assertUser(PrismObject user, String message) { diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java index 407f63dc4c7..fd9c82344aa 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java @@ -168,7 +168,7 @@ public void test020DeleteRole1Assignment() throws Exception { assertEquals("Wrong context state", ModelState.FINAL, context.getState()); result.computeStatusIfUnknown(); TestUtil.assertSuccess(result); - assertNotAssignedRole(getUser(userJackOid), getRoleOid(1), result); + assertNotAssignedRole(getUser(userJackOid), getRoleOid(1)); } /** diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java index 7e1a7842108..5f523444062 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java @@ -1226,6 +1226,8 @@ private void previewAssignRolesToJack(boolean immediate, boolean also24) throws result.tracingProfile(tracer.compileProfile(addWorkflowLogging(createModelLoggingTracingProfile()), result)); } + setGlobalTracingOverride(createModelAndProvisioningLoggingTracingProfile()); + List assignmentsToAdd = new ArrayList<>(); assignmentsToAdd.add(createAssignmentTo(roleRole21Oid, ObjectTypes.ROLE, prismContext)); assignmentsToAdd.add(createAssignmentTo(roleRole22Oid, ObjectTypes.ROLE, prismContext)); @@ -1303,7 +1305,7 @@ private void assertApprovalInfo(List inf ApprovalSchemaExecutionInformationType found = null; for (ApprovalSchemaExecutionInformationType info : infos) { assertNotNull("No taskRef", info.getCaseRef()); - PrismObject object = info.getCaseRef().asReferenceValue().getObject(); + PrismObject object = info.getCaseRef().asReferenceValue().getObject(); assertNotNull("No case in caseRef", object); CaseType aCase = (CaseType) object.asObjectable(); ApprovalContextType wfc = aCase.getApprovalContext(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java index c99f5912652..5fb99ea76d3 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java @@ -837,7 +837,6 @@ public void test032ResourceAndConnectorCaching() throws Exception { @Test public void test034ResourceAndConnectorCachingForceFresh() throws Exception { - // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + ".test011ResourceAndConnectorCachingForceFresh"); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index 5a2120dec17..01fdb1d842e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -1114,7 +1114,7 @@ public void test131AddScript() throws Exception { ShadowType account = parseObjectType(ACCOUNT_SCRIPT_FILE, ShadowType.class); display("Account before add", account); - OperationProvisioningScriptsType scriptsType = unmarshallValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); + OperationProvisioningScriptsType scriptsType = unmarshalValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); display("Provisioning scripts", PrismTestUtil.serializeAnyDataWrapped(scriptsType)); // WHEN @@ -1163,7 +1163,7 @@ public void test132ModifyScript() throws Exception { syncServiceMock.reset(); dummyResource.purgeScriptHistory(); - OperationProvisioningScriptsType scriptsType = unmarshallValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); + OperationProvisioningScriptsType scriptsType = unmarshalValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); display("Provisioning scripts", PrismTestUtil.serializeAnyDataWrapped(scriptsType)); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -1207,7 +1207,7 @@ public void test133ModifyScriptNoExec() throws Exception { syncServiceMock.reset(); dummyResource.purgeScriptHistory(); - OperationProvisioningScriptsType scriptsType = unmarshallValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); + OperationProvisioningScriptsType scriptsType = unmarshalValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); display("Provisioning scripts", PrismTestUtil.serializeAnyDataWrapped(scriptsType)); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -1246,7 +1246,7 @@ public void test134DeleteScript() throws Exception { syncServiceMock.reset(); dummyResource.purgeScriptHistory(); - OperationProvisioningScriptsType scriptsType = unmarshallValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); + OperationProvisioningScriptsType scriptsType = unmarshalValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); display("Provisioning scripts", PrismTestUtil.serializeAnyDataWrapped(scriptsType)); // WHEN @@ -1280,7 +1280,7 @@ public void test135ExecuteScript() throws Exception { syncServiceMock.reset(); dummyResource.purgeScriptHistory(); - OperationProvisioningScriptsType scriptsType = unmarshallValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); + OperationProvisioningScriptsType scriptsType = unmarshalValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class); display("Provisioning scripts", PrismTestUtil.serializeAnyDataWrapped(scriptsType)); ProvisioningScriptType script = scriptsType.getScript().get(0); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java index 14bb5b5ff9d..ad675ad07d8 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java @@ -905,7 +905,7 @@ public void test140AddAndModifyAccountJack() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); - ShadowType object = unmarshallValueFromFile(ACCOUNT_JACK_FILE, ShadowType.class); + ShadowType object = unmarshalValueFromFile(ACCOUNT_JACK_FILE, ShadowType.class); System.out.println(SchemaDebugUtil.prettyPrint(object)); System.out.println(object.asPrismObject().debugDump()); diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java index 408d9659723..e3a40d2369e 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java @@ -27,7 +27,6 @@ import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; @@ -606,32 +605,35 @@ protected T parseObjectType(File file, Class clazz) th return prismObject.asObjectable(); } - protected static T unmarshallValueFromFile(File file, Class clazz) - throws IOException, JAXBException, SchemaException { + protected static T unmarshalValueFromFile(File file, Class clazz) + throws IOException, SchemaException { return PrismTestUtil.parseAnyValue(file); } - protected static T unmarshallValueFromFile(String filePath, Class clazz) - throws IOException, JAXBException, SchemaException { + protected static T unmarshalValueFromFile(String filePath, Class clazz) + throws IOException, SchemaException { return PrismTestUtil.parseAnyValue(new File(filePath)); } - protected static ObjectType unmarshallValueFromFile(String filePath) throws IOException, - JAXBException, SchemaException { - return unmarshallValueFromFile(filePath, ObjectType.class); + protected static ObjectType unmarshalValueFromFile(String filePath) + throws IOException, SchemaException { + return unmarshalValueFromFile(filePath, ObjectType.class); } - protected PrismObject addResourceFromFile(File file, String connectorType, OperationResult result) - throws JAXBException, SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + protected PrismObject addResourceFromFile( + File file, String connectorType, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { return addResourceFromFile(file, connectorType, false, result); } - protected PrismObject addResourceFromFile(File file, String connectorType, boolean overwrite, OperationResult result) - throws JAXBException, SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + protected PrismObject addResourceFromFile( + File file, String connectorType, boolean overwrite, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { return addResourceFromFile(file, Collections.singletonList(connectorType), overwrite, result); } - protected PrismObject addResourceFromFile(File file, List connectorTypes, boolean overwrite, OperationResult result) + protected PrismObject addResourceFromFile( + File file, List connectorTypes, boolean overwrite, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { logger.trace("addObjectFromFile: {}, connector types {}", file, connectorTypes); PrismObject resource = prismContext.parseObject(file); @@ -699,7 +701,8 @@ protected void fillInConnectorRef(PrismObject resource, String con resourceType.getConnectorRef().setType(ObjectTypes.CONNECTOR.getTypeQName()); } - protected void fillInAdditionalConnectorRef(PrismObject resource, String connectorName, String connectorType, OperationResult result) + protected void fillInAdditionalConnectorRef(PrismObject resource, + String connectorName, String connectorType, OperationResult result) throws SchemaException { ResourceType resourceType = resource.asObjectable(); PrismObject connectorPrism = findConnectorByType(connectorType, result); @@ -791,14 +794,18 @@ protected void assumeConflictResolutionAction(ConflictResolutionActionType actio } } - protected void assumeResourceAssigmentPolicy(String resourceOid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + protected void assumeResourceAssigmentPolicy( + String resourceOid, AssignmentPolicyEnforcementType policy, boolean legalize) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ProjectionPolicyType syncSettings = new ProjectionPolicyType(); syncSettings.setAssignmentPolicyEnforcement(policy); syncSettings.setLegalize(legalize); applySyncSettings(ResourceType.class, resourceOid, ResourceType.F_PROJECTION, syncSettings); } - protected void deleteResourceAssigmentPolicy(String oid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + protected void deleteResourceAssigmentPolicy( + String oid, AssignmentPolicyEnforcementType policy, boolean legalize) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ProjectionPolicyType syncSettings = new ProjectionPolicyType(); syncSettings.setAssignmentPolicyEnforcement(policy); syncSettings.setLegalize(legalize); @@ -809,12 +816,12 @@ protected void deleteResourceAssigmentPolicy(String oid, AssignmentPolicyEnforce Collection> modifications = new ArrayList<>(); modifications.add(deleteAssigmentEnforcement); - OperationResult result = new OperationResult("Aplying sync settings"); + OperationResult result = createOperationResult("Applying sync settings"); repositoryService.modifyObject(ResourceType.class, oid, modifications, result); - display("Aplying sync settings result", result); + display("Applying sync settings result", result); result.computeStatus(); - TestUtil.assertSuccess("Aplying sync settings failed (result)", result); + TestUtil.assertSuccess("Applying sync settings failed (result)", result); } protected AssignmentPolicyEnforcementType getAssignmentPolicyEnforcementType(SystemConfigurationType systemConfiguration) { @@ -834,13 +841,13 @@ protected void applySyncSettings(Class clazz, String oid, ItemName itemName, Pro Collection modifications = prismContext.deltaFactory().container() .createModificationReplaceContainerCollection(itemName, objectDefinition, syncSettings.asPrismContainerValue()); - OperationResult result = new OperationResult("Aplying sync settings"); + OperationResult result = new OperationResult("Applying sync settings"); repositoryService.modifyObject(clazz, oid, modifications, result); invalidateSystemObjectsCache(); - display("Aplying sync settings result", result); + display("Applying sync settings result", result); result.computeStatus(); - TestUtil.assertSuccess("Aplying sync settings failed (result)", result); + TestUtil.assertSuccess("Applying sync settings failed (result)", result); } protected void invalidateSystemObjectsCache() { @@ -2052,6 +2059,10 @@ protected TracingProfileType createPerformanceTracingProfile() { .fileNamePattern(DEFAULT_TRACING_FILENAME_PATTERN); } + protected Task createTracedTask() { + return createTracedTask(null); + } + protected Task createTracedTask(String operationName) { Task task = createTask(operationName); task.addTracingRequest(TracingRootType.CLOCKWORK_RUN); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java index 6b3545cab30..d4b3276ba8f 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java @@ -140,7 +140,7 @@ protected PrismObject unmarshallJaxbFromFile(String fi protected PrismObject addObjectFromFile(String filePath) throws Exception { PrismObject object = unmarshallJaxbFromFile(filePath); - OperationResult result = new OperationResult(TestTaskManagerContract.class.getName() + ".addObjectFromFile"); + OperationResult result = createOperationResult("addObjectFromFile"); try { add(object, result); } catch (ObjectAlreadyExistsException e) { diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestTaskManagerContract.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestTaskManagerContract.java index d78fc29ff7d..4f09c3ea90f 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestTaskManagerContract.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestTaskManagerContract.java @@ -6,11 +6,10 @@ */ package com.evolveum.midpoint.task.quartzimpl; -import static com.evolveum.midpoint.util.MiscUtil.extractSingleton; - import static org.testng.AssertJUnit.*; import static com.evolveum.midpoint.test.IntegrationTestTools.waitFor; +import static com.evolveum.midpoint.util.MiscUtil.extractSingleton; import java.io.IOException; import java.util.ArrayList; @@ -19,9 +18,6 @@ import java.util.List; import javax.annotation.PostConstruct; -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.schema.util.TaskTypeUtil; - import org.quartz.JobExecutionContext; import org.quartz.JobKey; import org.quartz.SchedulerException; @@ -38,6 +34,7 @@ import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.query.ObjectFilter; +import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.SelectorOptions; @@ -45,6 +42,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; +import com.evolveum.midpoint.schema.util.TaskTypeUtil; import com.evolveum.midpoint.task.api.RunningTask; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskConstants; @@ -150,10 +148,12 @@ public void test004TaskBigProperty() throws Exception { // property definition ItemName shipStateQName = new ItemName("http://myself.me/schemas/whatever", "shipState"); - PrismPropertyDefinition shipStateDefinition = prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(shipStateQName); + //noinspection unchecked + PrismPropertyDefinition shipStateDefinition = (PrismPropertyDefinition) + prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(shipStateQName); assertNotNull("Cannot find property definition for shipState", shipStateDefinition); - PrismProperty shipStateProperty = (PrismProperty) shipStateDefinition.instantiate(); + PrismProperty shipStateProperty = shipStateDefinition.instantiate(); shipStateProperty.setRealValue(string300); task.setExtensionProperty(shipStateProperty); @@ -1314,9 +1314,9 @@ public void test999CheckingLeftovers() throws Exception { checkLeftover(leftovers, "test108", "b", result); checkLeftover(leftovers, "test110", result); checkLeftover(leftovers, "test110", "a", result); - checkLeftover(leftovers, "test120", result); - checkLeftover(leftovers, "test130", result); - checkLeftover(leftovers, "test200", result); + checkLeftover(leftovers, "test120", result); + checkLeftover(leftovers, "test130", result); + checkLeftover(leftovers, "test200", result); StringBuilder message = new StringBuilder("Leftover task(s) found:"); for (String leftover : leftovers) { diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index 9236eef7cc3..ebbbc76f8a4 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -912,7 +912,7 @@ public void test013AddOpenDjAccountToUser() throws Exception { // This is not redundant. It checks that the previous command set the policy correctly assertSyncSettingsAssignmentPolicyEnforcement(AssignmentPolicyEnforcementType.NONE); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_ADD_ACCOUNT_OPENDJ_FILENAME, ObjectDeltaType.class); // WHEN @@ -1044,7 +1044,7 @@ public void test014AddDerbyAccountToUser() throws IOException, JAXBException, Fa checkRepoDerbyResource(); assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_ADD_ACCOUNT_DERBY_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -1234,7 +1234,7 @@ public void test020ModifyUser() throws Exception { assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_FULLNAME_LOCALITY_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -1328,7 +1328,7 @@ private Entry assertOpenDJAccountJack(Entry entry, String uid, String givenName) public void test022ChangeUserPassword() throws Exception { // GIVEN - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_PASSWORD_FILENAME, ObjectDeltaType.class); System.out.println("In modification: " + objectChange.getItemDelta().get(0).getValue().get(0)); @@ -1438,7 +1438,7 @@ public void testModifyAccountDjRoomNumber(File reqFile, String expectedVal) thro // GIVEN assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile(reqFile, ObjectDeltaType.class); + ObjectDeltaType objectChange = unmarshalValueFromFile(reqFile, ObjectDeltaType.class); objectChange.setOid(accountShadowOidOpendj); // WHEN @@ -1472,7 +1472,7 @@ public void test029ModifyAccountDjBadPath() throws Exception { // GIVEN assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_ACCOUNT_MODIFY_BAD_PATH_FILE, ObjectDeltaType.class); objectChange.setOid(accountShadowOidOpendj); @@ -1517,7 +1517,7 @@ public void test029ModifyAccountDjBadPath() throws Exception { @Test public void test030DisableUser() throws Exception { // GIVEN - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_ACTIVATION_DISABLE_FILENAME, ObjectDeltaType.class); Entry entry = openDJController.searchByUid("jack"); @@ -1627,7 +1627,7 @@ public void test030DisableUser() throws Exception { @Test public void test031EnableUser() throws Exception { // GIVEN - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_ACTIVATION_ENABLE_FILENAME, ObjectDeltaType.class); assertNoRepoCache(); @@ -1826,7 +1826,7 @@ public void test047RenameUser() throws Exception { // GIVEN assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_NAME_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -1884,7 +1884,7 @@ public void test047RenameUser() throws Exception { public void test048ModifyUserRemoveGivenName() throws Exception { // GIVEN assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_GIVENNAME_FILENAME, ObjectDeltaType.class); displayJaxb("objectChange:", objectChange, SchemaConstants.T_OBJECT_DELTA); @@ -2005,7 +2005,7 @@ public void test100AssignRolePirate() throws Exception { assertNoRepoCache(); TestUtil.assertSuccess("addObject has failed", resultHolder.value); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_ADD_ROLE_PIRATE_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -2100,7 +2100,7 @@ public void test101AccountOwnerAfterRole() throws Exception { public void test102AssignRoleCaptain() throws Exception { // GIVEN - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_ADD_ROLE_CAPTAIN_1_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -2178,7 +2178,7 @@ public void test102AssignRoleCaptain() throws Exception { public void test103AssignRoleCaptainAgain() throws Exception { // GIVEN - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_ADD_ROLE_CAPTAIN_2_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -2252,7 +2252,7 @@ public void test103AssignRoleCaptainAgain() throws Exception { @Test public void test105ModifyAccount() throws Exception { // GIVEN - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_ACCOUNT_MODIFY_ATTRS_FILE, ObjectDeltaType.class); objectChange.setOid(accountShadowOidGuybrushOpendj); @@ -2337,7 +2337,7 @@ public void test104AssignRoleJudge() throws Exception { Holder oidHolder = new Holder<>(); assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_ADD_ROLE_JUDGE_FILENAME, ObjectDeltaType.class); try { @@ -2374,7 +2374,7 @@ public void test107UnassignRolePirate() throws Exception { // GIVEN assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_DELETE_ROLE_PIRATE_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -2450,7 +2450,7 @@ public void test108UnassignRoleCaptain() throws Exception { // GIVEN assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_DELETE_ROLE_CAPTAIN_1_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -2532,7 +2532,7 @@ public void test109UnassignRoleCaptainAgain() throws Exception { assertNoRepoCache(); - ObjectDeltaType objectChange = unmarshallValueFromFile( + ObjectDeltaType objectChange = unmarshalValueFromFile( REQUEST_USER_MODIFY_DELETE_ROLE_CAPTAIN_2_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), @@ -3115,7 +3115,7 @@ public void test420RecomputeUsers() throws Exception { // Assign role to a user, but we do this using a repository instead of model. // The role assignment will not be executed and this created an inconsistent state. - ObjectDeltaType changeAddRoleCaptain = unmarshallValueFromFile( + ObjectDeltaType changeAddRoleCaptain = unmarshalValueFromFile( REQUEST_USER_MODIFY_ADD_ROLE_CAPTAIN_1_FILENAME, ObjectDeltaType.class); Collection modifications = DeltaConvertor.toModifications(changeAddRoleCaptain.getItemDelta(), getUserDefinition()); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/AbstractStoryTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/AbstractStoryTest.java index 46baa1fd494..7fdfcd23ba6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/AbstractStoryTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/AbstractStoryTest.java @@ -6,8 +6,24 @@ */ package com.evolveum.midpoint.testing.story; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.*; +import javax.xml.namespace.QName; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; + import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; -import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.PrismConstants; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismReference; +import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.match.MatchingRule; import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; import com.evolveum.midpoint.prism.path.ItemPath; @@ -23,41 +39,24 @@ import com.evolveum.midpoint.schema.statistics.RepositoryPerformanceInformationUtil; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.tools.testng.UnusedTestElement; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.caching.CachePerformanceCollector; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; - -import javax.xml.namespace.QName; - -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.*; /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class AbstractStoryTest extends AbstractModelIntegrationTest { public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); - public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); protected static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; - protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; protected static final File USER_JACK_FILE = new File(COMMON_DIR, "user-jack.xml"); protected static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111"; @@ -65,7 +64,6 @@ public class AbstractStoryTest extends AbstractModelIntegrationTest { protected static final String USER_JACK_FULL_NAME = "Jack Sparrow"; protected static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); - protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; protected static final File TASK_TRIGGER_SCANNER_FILE = new File(COMMON_DIR, "task-trigger-scanner.xml"); protected static final String TASK_TRIGGER_SCANNER_OID = "00000000-0000-0000-0000-000000000007"; @@ -133,7 +131,6 @@ protected void importSystemTasks(OperationResult initResult) throws FileNotFound importObjectFromFile(TASK_VALIDITY_SCANNER_FILE, initResult); } - protected void assertUserJack(PrismObject userJack) { assertUser(userJack, USER_JACK_OID, USER_JACK_USERNAME, "Jack Sparrow", "Jack", "Sparrow"); } @@ -163,10 +160,12 @@ protected SearchResultList getWorkItems(Task task, OperationRe return modelService.searchContainers(CaseWorkItemType.class, query, null, task, result); } + @UnusedTestElement // TODO: used on demand/temporarily? then mark with suppress warning + comment protected ObjectReferenceType ort(String oid) { return ObjectTypeUtil.createObjectRef(oid, ObjectTypes.USER); } + @UnusedTestElement // TODO: used on demand/temporarily? then mark with suppress warning + comment protected PrismReferenceValue prv(String oid) { return ObjectTypeUtil.createObjectRef(oid, ObjectTypes.USER).asReferenceValue(); } @@ -200,12 +199,14 @@ protected void resetGlobalCachePerformanceCollector() { CachePerformanceCollector.INSTANCE.clear(); } - protected void dumpGlobalCachePerformanceData(String testName) { - display("Cache performance data for " + testName + " (got from cache performance collector)", CachePerformanceCollector.INSTANCE); + protected void dumpGlobalCachePerformanceData() { + display("Cache performance data for " + getTestNameShort() + + " (got from cache performance collector)", CachePerformanceCollector.INSTANCE); } - protected void dumpThreadLocalCachePerformanceData(String testName) { - dumpCachePerformanceData(testName, CachePerformanceCollector.INSTANCE.getThreadLocalPerformanceMap()); + protected void dumpThreadLocalCachePerformanceData() { + dumpCachePerformanceData(getTestNameShort(), + CachePerformanceCollector.INSTANCE.getThreadLocalPerformanceMap()); } protected void resetThreadLocalPerformanceData() { @@ -213,6 +214,7 @@ protected void resetThreadLocalPerformanceData() { CachePerformanceCollector.INSTANCE.startThreadLocalPerformanceInformationCollection(); } + @UnusedTestElement // TODO: used on demand/temporarily? then mark with suppress warning + comment protected PerformanceInformation dumpThreadLocalPerformanceData(String testName) { PerformanceInformation performanceInformation = getRepoPerformanceMonitor().getThreadLocalPerformanceInformation(); dumpRepoPerformanceData("Repo operations for " + testName, performanceInformation); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java index a111fc2782a..4db1b1c81b0 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java @@ -2888,7 +2888,7 @@ private ShadowType checkPostponedAccountBasic(String accountOid, boolean modify, private Collection> createDeltas(Class type, File requestFile, String objectOid) throws IOException, SchemaException, JAXBException { try { - ObjectDeltaType objectChange = unmarshallValueFromFile(requestFile, ObjectDeltaType.class); + ObjectDeltaType objectChange = unmarshalValueFromFile(requestFile, ObjectDeltaType.class); objectChange.setOid(objectOid); ObjectDelta delta = DeltaConvertor.createObjectDelta(objectChange, prismContext); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java index 851a47337c9..62a5414ff9c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java @@ -6,6 +6,16 @@ * and European Union Public License. See LICENSE file for details. */ +import static org.testng.AssertJUnit.assertNotNull; + +import java.io.File; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; @@ -16,19 +26,9 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import java.io.File; - -import static org.testng.AssertJUnit.assertNotNull; /** * @author Radovan Semancik - * */ @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @@ -110,8 +110,6 @@ public void test000Sanity() throws Exception { TestUtil.assertSuccess(testResultOpenDj); } - - @Test public void test100AddUserHerman() throws Exception { Task task = getTestTask(); @@ -140,7 +138,6 @@ public void test100AddUserHerman() throws Exception { assertNoAssignments(userAfter); } - @Test public void test110HermanAssignRoleBasic() throws Exception { Task task = getTestTask(); @@ -176,8 +173,7 @@ public void test110HermanAssignRoleBasic() throws Exception { @Test public void test112HermanRename() throws Exception { - final String TEST_NAME = "test112HermanRename"; - Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -210,8 +206,7 @@ public void test112HermanRename() throws Exception { @Test public void test120AddUserCapsizeWithBasicRole() throws Exception { - final String TEST_NAME = "test120AddUserCapsizeWithBasicRole"; - Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUserDefinition().instantiate(); @@ -248,7 +243,6 @@ public void test120AddUserCapsizeWithBasicRole() throws Exception { assertShadowSecondaryIdentifier(shadowOpenDj, openDJController.getAccountDn(USER_CAPSIZE_USERNAME_FINAL), resourceOpenDjType, caseIgnoreMatchingRule); } - protected void assertUserHerman(PrismObject user, String username) { assertUser(user, username, USER_HERMAN_GIVEN_NAME, USER_HERMAN_FAMILY_NAME); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java index ce008f700cc..c401aa209fe 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java @@ -6,10 +6,8 @@ */ package com.evolveum.midpoint.testing.story; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; import java.io.File; import java.util.Collection; @@ -26,21 +24,12 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestEntertainment extends AbstractStoryTest { - public static final Trace LOGGER = TraceManager.getTrace(TestEntertainment.class); - public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "entertainment"); private static final File RESOURCE_OPENDJ_FILE = new File(TEST_DIR, "resource-opendj.xml"); @@ -65,7 +54,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -81,14 +70,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti importObjectFromFile(ROLE_META_CREATE_ORG_GROUPS_FILE); - - } @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -108,8 +94,7 @@ public void test000Sanity() throws Exception { @Test public void test001AddParentOrg() throws Exception { - final String TEST_NAME = "test001AddParentOrg"; - Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -139,8 +124,7 @@ public void test001AddParentOrg() throws Exception { @Test public void test002AddChildOrg() throws Exception { - final String TEST_NAME = "test002AddChildOrg"; - Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -199,5 +183,4 @@ private void assertIntents(ShadowType shadowType1, ShadowType shadowType2) { + intentShadow1 + ", " + intentShadow2); } } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java index da29dec8b14..bc25655feac 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java @@ -22,7 +22,7 @@ /** * Tests for weird activation existence mappings, delayed deletes and similar existential issues. - * + *

* MID-4564 * * @author Radovan Semancik @@ -42,8 +42,6 @@ public class TestExistentialIssues extends AbstractStoryTest { protected static final String USER_DESCARTES_USERNAME = "descartes"; protected static final String USER_DESCARTES_FULL_NAME = "René Descartes"; - protected PrismObject userAdministrator; - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -59,7 +57,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti */ @Test public void test100DisableUserDescartes() throws Exception { - final String TEST_NAME = "test100DisableUserDescartes"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -87,7 +84,6 @@ public void test100DisableUserDescartes() throws Exception { */ @Test public void test110DescartesAssignLazyAccount() throws Exception { - final String TEST_NAME = "test110DescartesAssignLazyAccount"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -115,7 +111,6 @@ public void test110DescartesAssignLazyAccount() throws Exception { */ @Test public void test112EnableDescartes() throws Exception { - final String TEST_NAME = "test112EnableDescartes"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -143,7 +138,6 @@ public void test112EnableDescartes() throws Exception { */ @Test public void test114DisableDescartes() throws Exception { - final String TEST_NAME = "test112EnableDescartes"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -171,7 +165,6 @@ public void test114DisableDescartes() throws Exception { */ @Test public void test116ReenableDescartes() throws Exception { - final String TEST_NAME = "test116ReenableDescartes"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -199,7 +192,6 @@ public void test116ReenableDescartes() throws Exception { */ @Test public void test120DescartesUnassignLazyAccount() throws Exception { - final String TEST_NAME = "test120DescartesUnassignLazyAccount"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -227,7 +219,6 @@ public void test120DescartesUnassignLazyAccount() throws Exception { */ @Test public void test129DeleteDescartes() throws Exception { - final String TEST_NAME = "test129DeleteDescartes"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -244,5 +235,4 @@ public void test129DeleteDescartes() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_LAZY_NAME, USER_DESCARTES_USERNAME); } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java index caee18d43ec..d122449618d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java @@ -7,8 +7,6 @@ package com.evolveum.midpoint.testing.story; import java.io.File; -import java.util.function.Consumer; - import javax.xml.namespace.QName; import org.springframework.test.annotation.DirtiesContext; @@ -28,20 +26,14 @@ import com.evolveum.midpoint.test.asserter.RoleAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.util.exception.CommonException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * Tests for bi-directional entitlement association synchronization. * * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestInboundOutboundAssociation extends AbstractStoryTest { @@ -66,9 +58,6 @@ public class TestInboundOutboundAssociation extends AbstractStoryTest { public static final String SUBTYPE_GROUP = "group"; - private static final String ACCOUNT_GUYBRUSH_USERNAME = "guybrush"; - private static final String ACCOUNT_GUYBRUSH_FULLNAME = "Guybrush Threepwood"; - private static final String GROUP_PIRATES_NAME = "pirates"; private static final QName ASSOCIATION_GROUP_QNAME = new QName(MidPointConstants.NS_RI, "group"); @@ -97,7 +86,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportGroupPirates() throws Exception { - final String TEST_NAME = "test100ImportGroupPirates"; DummyGroup group = new DummyGroup(GROUP_PIRATES_NAME); getDummyResourceDir().addGroup(group); @@ -114,9 +102,9 @@ public void test100ImportGroupPirates() throws Exception { RoleAsserter rolePiratesAsserter = assertRoleAfterByName(groupRoleName(GROUP_PIRATES_NAME)); rolePiratesAsserter - .assertSubtype(SUBTYPE_GROUP) - .assertIdentifier(GROUP_PIRATES_NAME) - .assignments() + .assertSubtype(SUBTYPE_GROUP) + .assertIdentifier(GROUP_PIRATES_NAME) + .assignments() .assertAssignments(1) .assertRole(ROLE_META_GROUP_OID) .end(); @@ -125,14 +113,12 @@ public void test100ImportGroupPirates() throws Exception { shadowGroupPiratesOid = rolePiratesAsserter .links() - .single() - .getOid(); + .single() + .getOid(); } @Test public void test110AssignJackDirAccount() throws Exception { - final String TEST_NAME = "test110AssignJackDirAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -147,14 +133,14 @@ public void test110AssignJackDirAccount() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(1); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertNoMembers(); + .assertNoMembers(); } /** @@ -162,8 +148,6 @@ public void test110AssignJackDirAccount() throws Exception { */ @Test public void test115Stability() throws Exception { - final String TEST_NAME = "test110AssignJackDirAccount"; - // WHEN when(); liveSyncDir(); @@ -174,26 +158,24 @@ public void test115Stability() throws Exception { display("dir after", getDummyResourceDir()); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertNoMembers(); + .assertNoMembers(); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(1); } @Test public void test120AddJackToGroupPirates() throws Exception { - final String TEST_NAME = "test120AddJackToGroupPirates"; - getDummyResourceDir().getGroupByName(GROUP_PIRATES_NAME) - .addMember(USER_JACK_USERNAME); + .addMember(USER_JACK_USERNAME); // "fake" modification of jack's account. Just to "motivate" it to be synchronized getDummyResourceDir().getAccountByUsername(USER_JACK_USERNAME) - .replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum"); + .replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum"); // WHEN when(); @@ -206,15 +188,15 @@ public void test120AddJackToGroupPirates() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(2) .assertRole(rolePiratesOid); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertMembers(USER_JACK_USERNAME); + .assertMembers(USER_JACK_USERNAME); } /** @@ -222,8 +204,6 @@ public void test120AddJackToGroupPirates() throws Exception { */ @Test public void test130JackUnassignRolePirates() throws Exception { - final String TEST_NAME = "test120AddJackToGroupPirates"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -238,21 +218,19 @@ public void test130JackUnassignRolePirates() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(1) .assertNoRole(rolePiratesOid); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertNoMembers(); + .assertNoMembers(); } @Test public void test140JackAssignRolePirates() throws Exception { - final String TEST_NAME = "test140JackAssignRolePirates"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -267,29 +245,26 @@ public void test140JackAssignRolePirates() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(2) .assertRole(rolePiratesOid); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertMembers(USER_JACK_USERNAME); + .assertMembers(USER_JACK_USERNAME); } /** * Unassign dir account. But there is still pirates group assignment, * therefore the account should be kept. - * @throws Exception */ @Test public void test142JackUnAssignDirAccount() throws Exception { - final String TEST_NAME = "test140JackAssignRolePirates"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -304,18 +279,18 @@ public void test142JackUnAssignDirAccount() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(1) .assertRole(rolePiratesOid); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertMembers(USER_JACK_USERNAME); + .assertMembers(USER_JACK_USERNAME); } /** @@ -323,8 +298,6 @@ public void test142JackUnAssignDirAccount() throws Exception { */ @Test public void test149JackUnassignRolePirates() throws Exception { - final String TEST_NAME = "test149JackUnassignRolePirates"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -339,19 +312,17 @@ public void test149JackUnassignRolePirates() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(0); assertNoDummyAccount(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertNoMembers(); + .assertNoMembers(); } @Test public void test150AssignJackDirAccount() throws Exception { - final String TEST_NAME = "test150AssignJackDirAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -366,20 +337,18 @@ public void test150AssignJackDirAccount() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(1); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertNoMembers(); + .assertNoMembers(); } @Test public void test152JackAssignRolePirates() throws Exception { - final String TEST_NAME = "test152JackAssignRolePirates"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -394,18 +363,18 @@ public void test152JackAssignRolePirates() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(2) .assertRole(rolePiratesOid); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertMembers(USER_JACK_USERNAME); + .assertMembers(USER_JACK_USERNAME); } /** @@ -413,8 +382,6 @@ public void test152JackAssignRolePirates() throws Exception { */ @Test public void test153JackUnassignRolePiratesPreview() throws Exception { - final String TEST_NAME = "test153JackUnassignRolePiratesPreview"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -422,7 +389,7 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { UserType.class, USER_JACK_OID, FocusType.F_ASSIGNMENT, rolePiratesOid, RoleType.COMPLEX_TYPE, - null, (Consumer)null, false); + null, null, false); // WHEN when(); @@ -433,26 +400,26 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { assertSuccess(result); assertPreviewContext(previewContext) - .projectionContexts() + .projectionContexts() + .single() + .assertNoPrimaryDelta() + .secondaryDelta() + .display() + .assertModify() + .container(ShadowType.F_ASSOCIATION) + .assertNoValuesToAdd() + .assertNoValuesToReplace() + .valuesToDelete() .single() - .assertNoPrimaryDelta() - .secondaryDelta() - .display() - .assertModify() - .container(ShadowType.F_ASSOCIATION) - .assertNoValuesToAdd() - .assertNoValuesToReplace() - .valuesToDelete() - .single() - .assertPropertyEquals(ShadowAssociationType.F_NAME, ASSOCIATION_GROUP_QNAME) - .assertRefEquals(ShadowAssociationType.F_SHADOW_REF, shadowGroupPiratesOid) - .end() - .end() - .end() - .end() - .objectNew() - .display() - .assertNoItem(ShadowType.F_ASSOCIATION); + .assertPropertyEquals(ShadowAssociationType.F_NAME, ASSOCIATION_GROUP_QNAME) + .assertRefEquals(ShadowAssociationType.F_SHADOW_REF, shadowGroupPiratesOid) + .end() + .end() + .end() + .end() + .objectNew() + .display() + .assertNoItem(ShadowType.F_ASSOCIATION); } @@ -461,8 +428,6 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { */ @Test public void test154JackUnassignRolePirates() throws Exception { - final String TEST_NAME = "test154JackUnassignRolePirates"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -477,24 +442,22 @@ public void test154JackUnassignRolePirates() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(1) .assertNoRole(rolePiratesOid); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyAccountByUsername(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertNoMembers(); + .assertNoMembers(); } @Test public void test159JackUnassignDirAccount() throws Exception { - final String TEST_NAME = "test159JackUnassignDirAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -509,13 +472,13 @@ public void test159JackUnassignDirAccount() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_JACK_OID) - .assignments() + .assignments() .assertAssignments(0); assertNoDummyAccount(RESOURCE_DUMMY_DIR_NAME, USER_JACK_USERNAME); assertDummyGroupByName(RESOURCE_DUMMY_DIR_NAME, GROUP_PIRATES_NAME) - .assertNoMembers(); + .assertNoMembers(); } /** @@ -523,8 +486,6 @@ public void test159JackUnassignDirAccount() throws Exception { */ @Test public void test200MancombAssignAccount() throws Exception { - final String TEST_NAME = "test200MancombAssignAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -539,22 +500,20 @@ public void test200MancombAssignAccount() throws Exception { display("dir after", getDummyResourceDir()); assertUserAfter(USER_MANCOMB_OID) .assignments() - .assertAssignments(1); + .assertAssignments(1); assertDummyAccount(RESOURCE_DUMMY_DIR_NAME, USER_MANCOMB_USERNAME); } private String groupRoleName(String groupName) { - return "group:"+groupName; + return "group:" + groupName; } - private void liveSyncDir() throws CommonException { rerunTask(TASK_DUMMY_DIR_LIVESYNC_OID); } - private DummyResource getDummyResourceDir() { return getDummyResource(RESOURCE_DUMMY_DIR_NAME); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java index bc7a26d397a..b2b9754dbbc 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java @@ -20,16 +20,14 @@ import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; - /** * testing inducements, no resources, no accounts in use. * role "processor" is assigned to user, it contains inducements for role1, role2, role3 having following conditions - * + *

* role1: no condition * role2: should not be induced when description of user equals "NO" * role3: should not be induced when user is member of role named "lock" (directly or indirectly, therefore condition runs against roleMembershipRef) */ - @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestInducement extends AbstractStoryTest { @@ -72,7 +70,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; //no resource, no extension definition //anything to check? @@ -84,8 +81,6 @@ public void test000Sanity() throws Exception { */ @Test public void test010InducementConditionsTrue() throws Exception { - final String TEST_NAME = "test010InducementConditionsTrue"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -114,8 +109,6 @@ public void test010InducementConditionsTrue() throws Exception { */ @Test public void test020InducementRole2ConditionFalse() throws Exception { - final String TEST_NAME = "test020InducementRole2ConditionFalse"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -141,12 +134,10 @@ public void test020InducementRole2ConditionFalse() throws Exception { /** * assign role "lock" to user - * condition in "processor" for inducing role3 returns false if lock is contained in rolemembership + * condition in "processor" for inducing role3 returns false if lock is contained in role membership */ @Test public void test030InducementRole3ConditionFalse() throws Exception { - final String TEST_NAME = "test030InducementRole3ConditionFalse"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -155,7 +146,6 @@ public void test030InducementRole3ConditionFalse() throws Exception { // WHEN assignRole(USER_SIMPLE_OID, ROLE_LOCK_OID, task, result); - // THEN assertSuccess(result); @@ -175,8 +165,6 @@ public void test030InducementRole3ConditionFalse() throws Exception { */ @Test public void test040Recomputed() throws Exception { - final String TEST_NAME = "test040Recomputed"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -204,8 +192,6 @@ public void test040Recomputed() throws Exception { */ @Test public void test050InducementRole3ConditionTrue() throws Exception { - final String TEST_NAME = "test050InducementRole3ConditionTrue"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -233,8 +219,6 @@ public void test050InducementRole3ConditionTrue() throws Exception { */ @Test public void test060Recomputed() throws Exception { - final String TEST_NAME = "test060Recomputed"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -259,8 +243,6 @@ public void test060Recomputed() throws Exception { @Test public void test070DeleteUser() throws Exception { - final String TEST_NAME = "test070DeleteUser"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java index c03a84eec7f..188afa0aa8a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java @@ -67,8 +67,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -90,8 +88,6 @@ public void test000Sanity() throws Exception { @Test public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { - final String TEST_NAME = "test100AssignJackAccountNoAttributeAddDelete"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -112,8 +108,6 @@ public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { @Test public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { - final String TEST_NAME = "test102AddJackOrganizationalUnitTreasureHunt"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -135,8 +129,6 @@ public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { @Test public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { - final String TEST_NAME = "test104AddJackOrganizationalUnitLootingSailing"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -158,8 +150,6 @@ public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { @Test public void test106DeleteJackOrganizationalUnitLooting() throws Exception { - final String TEST_NAME = "test106DeleteJackOrganizationalUnitLooting"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -184,8 +174,6 @@ public void test106DeleteJackOrganizationalUnitLooting() throws Exception { */ @Test public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exception { - final String TEST_NAME = "test108DeleteJackOrganizationalUnitTreasureHuntSailing"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -207,8 +195,6 @@ public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exce @Test public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { - final String TEST_NAME = "test109UnassignJackAccountNoAttributeAddDelete"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -233,8 +219,6 @@ public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { */ @Test public void test110AssignJackAccountNoCreate() throws Exception { - final String TEST_NAME = "test110AssignJackAccountNoCreate"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -256,8 +240,6 @@ public void test110AssignJackAccountNoCreate() throws Exception { @Test public void test119UnassignJackAccountNoCreate() throws Exception { - final String TEST_NAME = "test119UnassignJackAccountNoCreate"; - Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java index d00dec1ef17..687db05ae28 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java @@ -21,13 +21,10 @@ import java.io.File; -import static org.testng.AssertJUnit.assertNotNull; - /** * Test for various livesync scenarios and corner cases. * * @author semancik - * */ @ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @@ -96,7 +93,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; Task task = getTestTask(); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); @@ -112,8 +108,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddHrAccountHerman() throws Exception { - final String TEST_NAME = "test100AddHrAccountHerman"; - dummyAuditService.clear(); DummyAccount newAccount = new DummyAccount(ACCOUNT_HERMAN_USERNAME); @@ -151,8 +145,6 @@ public void test100AddHrAccountHerman() throws Exception { @Test public void test110RenameHrAccountHerman() throws Exception { - final String TEST_NAME = "test110RenameHrAccountHerman"; - dummyAuditService.clear(); DummyAccount account = dummyResourceHr.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -193,7 +185,6 @@ public void test110RenameHrAccountHerman() throws Exception { */ @Test public void test112HrAccountHermanEmptyDelta() throws Exception { - final String TEST_NAME = "test112HrAccountHermanEmptyDelta"; dummyAuditService.clear(); dummyResourceHr.recordEmptyDeltaForAccountByUsername(ACCOUNT_HERMAN_USERNAME, DummyDeltaType.MODIFY); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java index 97e1a8bb4ce..1503a5fa3fb 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java @@ -6,20 +6,14 @@ */ package com.evolveum.midpoint.testing.story; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.*; import java.io.File; import java.io.FileInputStream; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.prism.path.ItemPath; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -27,8 +21,10 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; +import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.SearchResultList; @@ -39,23 +35,12 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.ClassPathUtil; import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; - -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestMachineIntelligence extends AbstractStoryTest { - public static final Trace LOGGER = TraceManager.getTrace(TestMachineIntelligence.class); - public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "machineintelligence"); private static final File RESOURCE_HR_FILE = new File(TEST_DIR, "resource-csv-HR.xml"); @@ -73,7 +58,7 @@ public class TestMachineIntelligence extends AbstractStoryTest { private static final String NS_RESOURCE_CSV = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector"; @Autowired - MidpointConfiguration midPointConfig; + private MidpointConfiguration midPointConfig; @Override protected File getSystemConfigurationFile() { @@ -86,11 +71,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti File resourceDir = new File(home, "machineintelligence"); resourceDir.mkdir(); - LOGGER.info("Start copying HR.csv from {} to {}", RESOURCE_CSV_CONTENT_FILE.getAbsolutePath(), resourceDir.getAbsolutePath()); + logger.info("Start copying HR.csv from {} to {}", RESOURCE_CSV_CONTENT_FILE.getAbsolutePath(), resourceDir.getAbsolutePath()); File desticationFile = new File(resourceDir, "HR.csv"); ClassPathUtil.copyFile(new FileInputStream(RESOURCE_CSV_CONTENT_FILE), "HR.csv", desticationFile); - if (!desticationFile.exists()){ + if (!desticationFile.exists()) { throw new SystemException("Source file for HR resource was not created"); } @@ -99,12 +84,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti super.initSystem(initTask, initResult); importObjectFromFile(RESOURCE_HR_FILE); - } @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; Task task = getTestTask(); OperationResult result = task.getResult(); Object[] newRealValue = { sourceFilePath }; @@ -129,16 +112,14 @@ SchemaConstants.ICF_CONFIGURATION_PROPERTIES, new QName(NS_RESOURCE_CSV, "filePa } /** - * * WHEN: Create account in the HR, import this acount to the midPoint * THEN: User is imported to midPoint, new Organization is created, - * user is assigned to the organization, assignment is active/inactive - * according to the setting in the resource + * user is assigned to the organization, assignment is active/inactive + * according to the setting in the resource */ @Test public void test010importActiveUserRUR() throws Exception { - final String TEST_NAME = "test010importActiveUserRUR"; - Task task = taskManager.createTaskInstance(TestMachineIntelligence.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -169,8 +150,7 @@ public void test010importActiveUserRUR() throws Exception { @Test public void test011importInactiveUserChappie() throws Exception { - final String TEST_NAME = "test011importInactiveUserChappie"; - Task task = taskManager.createTaskInstance(TestMachineIntelligence.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -203,15 +183,17 @@ public void test011importInactiveUserChappie() throws Exception { } - private PrismObject assertShadowOwner(String shadowOid, String userName, String userGivenName, String userFamilyName, String userFullName, Task task, OperationResult result) throws Exception{ + private PrismObject assertShadowOwner( + String shadowOid, String userName, String userGivenName, String userFamilyName, + String userFullName, Task task, OperationResult result) throws Exception { PrismObject userRur = (PrismObject) modelService.searchShadowOwner(shadowOid, null, task, result); assertNotNull("Owner must not be null", userRur); UserType userType = userRur.asObjectable(); - assertEquals("Unexpected name in the user", PrismTestUtil.createPolyStringType(userName) , userType.getName()); - assertEquals("Unexpected givenName in the user", PrismTestUtil.createPolyStringType(userGivenName) , userType.getGivenName()); - assertEquals("Unexpected familyName in the user", PrismTestUtil.createPolyStringType(userFamilyName) , userType.getFamilyName()); - assertEquals("Unexpected fullName in the user", PrismTestUtil.createPolyStringType(userFullName) , userType.getFullName()); + assertEquals("Unexpected name in the user", PrismTestUtil.createPolyStringType(userName), userType.getName()); + assertEquals("Unexpected givenName in the user", PrismTestUtil.createPolyStringType(userGivenName), userType.getGivenName()); + assertEquals("Unexpected familyName in the user", PrismTestUtil.createPolyStringType(userFamilyName), userType.getFamilyName()); + assertEquals("Unexpected fullName in the user", PrismTestUtil.createPolyStringType(userFullName), userType.getFullName()); return userRur; } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java index 2282610f438..0969273cba3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java @@ -6,21 +6,15 @@ */ package com.evolveum.midpoint.testing.story; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.testng.Assert.*; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; import java.io.File; import java.util.Collection; import java.util.List; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; import org.apache.commons.lang3.BooleanUtils; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -33,6 +27,7 @@ import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismReference; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.processor.ResourceAttribute; import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; @@ -41,26 +36,15 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteCredentialResetRequestType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestMapleLeaf extends AbstractStoryTest { public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "mapleLeaf"); - public static final String NS_EXT = "http://midpoint.evolveum.com/xml/ns/story/mapleLeaf/ext"; - private static final File SYSTEM_CONFIGURATION_FILE = new File(TEST_DIR, "system-configuration.xml"); private static final File SECURITY_POLICY_FILE = new File(TEST_DIR, "security-policy.xml"); @@ -74,24 +58,19 @@ public class TestMapleLeaf extends AbstractStoryTest { private static final File ROLE_META_MONKEY_DONKEY = new File(TEST_DIR, "meta-role-monkey-donkey.xml"); private static final File ROLE_MAPLE_LEAF_FACULTY_LICENSE = new File(TEST_DIR, "role-maple-leaf-faculty-license.xml"); - private static final String ROLE_MAPLE_LEAF_FACULTY_LICENSE_OID = "00000000-role-meta-0000-000011112222"; private static final File ROLE_MAPLE_LEAF_FACULTY = new File(TEST_DIR, "role-maple-leaf-faculty.xml"); private static final String ROLE_MAPLE_LEAF_FACULTY_OID = "00000000-role-0000-0000-000011112222"; private static final File ROLE_MAPLE_LEAF_GRADUATE_LICENSE = new File(TEST_DIR, "role-maple-leaf-graduate-license.xml"); - private static final String ROLE_MAPLE_LEAF_GRADUATE_LICENSE_OID = "00000000-role-meta-0000-000011113333"; private static final File ROLE_MAPLE_LEAF_GRADUATE = new File(TEST_DIR, "role-maple-leaf-graduate.xml"); private static final String ROLE_MAPLE_LEAF_GRADUATE_OID = "00000000-role-0000-0000-000011113333"; private static final File OBJECT_TEMPLATE_USER = new File(TEST_DIR, "object-template-user.xml"); - private static final String OBJECT_TEMPLATE_USER_OID = "10000000-0000-0000-0000-000000000222"; - private static final String LDIF_GROUPS = TEST_DIR + "/mapleLeafGroups.ldif"; + private static final String LDIF_GROUPS = TEST_DIR + "/mapleLeafGroups.ldif"; private static final String NS_RESOURCE = "http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"; - protected static final ItemPath ACTIVATION_EFFECTIVE_STATUS_PATH = SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS; - protected ResourceType resourceOpenDjType; protected PrismObject resourceOpenDj; @@ -101,7 +80,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -134,8 +113,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestMapleLeaf.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -155,8 +133,6 @@ public void test000Sanity() throws Exception { @Test public void test001addUser() throws Exception { - final String TEST_NAME = "test001addUser"; - //when when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, "default"); @@ -186,8 +162,6 @@ public void test001addUser() throws Exception { @Test public void test002assignRoleSquirrel() throws Exception { - final String TEST_NAME = "test002assignRoleSquirrel"; - //when when(); assignRole(USER_JACK_OID, ROLE_SQUIRREL_OID); @@ -217,8 +191,6 @@ public void test002assignRoleSquirrel() throws Exception { @Test public void test003unassignRoleSquirrel() throws Exception { - final String TEST_NAME = "test003unassignRoleSquirrel"; - //when when(); unassignRole(USER_JACK_OID, ROLE_SQUIRREL_OID); @@ -246,11 +218,8 @@ public void test003unassignRoleSquirrel() throws Exception { assertTrue(values.contains("mcconkey"), "No mcconkey found among values"); } - @Test public void test004assignRoleMapleLeafFaculty() throws Exception { - final String TEST_NAME = "test004assignRoleMapleLeafFaculty"; - //when when(); assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID); @@ -278,19 +247,8 @@ public void test004assignRoleMapleLeafFaculty() throws Exception { } - private boolean containRoleMemebrShip(List roleMemberships, String roleId) { - for (ObjectReferenceType ref : roleMemberships) { - if (ref.getOid().equals(roleId)) { - return true; - } - } - return false; - } - @Test public void test005assignRoleMapleLeafGraduate() throws Exception { - final String TEST_NAME = "test005assignRoleMapleLeafGraduate"; - //when when(); assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_GRADUATE_OID); @@ -321,8 +279,6 @@ public void test005assignRoleMapleLeafGraduate() throws Exception { @Test public void test006unassignRoleMapleLeafFaculty() throws Exception { - final String TEST_NAME = "test006unassignRoleMapleLeafFaculty"; - //when when(); unassignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID); @@ -349,13 +305,9 @@ public void test006unassignRoleMapleLeafFaculty() throws Exception { openDJController.assertUniqueMember("cn=mapleLeafGraduateLicense,ou=groups,dc=example,dc=com", "uid=jack,ou=People,dc=example,dc=com"); } - - @Test public void test100changePasswordForceChange() throws Exception { - final String TEST_NAME = "test100changePasswordForceChange"; - - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); //given @@ -389,9 +341,9 @@ public void test100changePasswordForceChange() throws Exception { UserType userTypeAfter = userAfter.asObjectable(); CredentialsType credentials = userTypeAfter.getCredentials(); - assertNotNull("Oooops, something unexpected happenned - no credentials found in user " + userAfter, credentials); + assertNotNull("Oooops, something unexpected happened - no credentials found in user " + userAfter, credentials); PasswordType password = credentials.getPassword(); - assertNotNull("Oooops, something unexpected happenned - no password defined for user " + userAfter, password); + assertNotNull("Oooops, something unexpected happened - no password defined for user " + userAfter, password); String clearTextValue = protector.decryptString(password.getValue()); assertEquals(clearTextValue, "somenewValue", "Passwords don't match"); @@ -408,9 +360,7 @@ public void test100changePasswordForceChange() throws Exception { @Test public void test101resetPassword() throws Exception { - final String TEST_NAME = "test101resetPassword"; - - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.assertPassword("uid=jack,ou=People,dc=example,dc=com", "oldValue"); @@ -429,9 +379,9 @@ public void test101resetPassword() throws Exception { UserType userTypeAfter = userAfter.asObjectable(); CredentialsType credentials = userTypeAfter.getCredentials(); - assertNotNull("Oooops, something unexpected happenned - no credentials found in user " + userAfter, credentials); + assertNotNull("Oooops, something unexpected happened - no credentials found in user " + userAfter, credentials); PasswordType password = credentials.getPassword(); - assertNotNull("Oooops, something unexpected happenned - no password defined for user " + userAfter, password); + assertNotNull("Oooops, something unexpected happened - no password defined for user " + userAfter, password); String clearTextValue = protector.decryptString(password.getValue()); assertEquals(clearTextValue, "123passwd456", "Passwords don't match"); @@ -442,9 +392,7 @@ public void test101resetPassword() throws Exception { @Test public void test200setArchivedAdministrativeStatus() throws Exception { - final String TEST_NAME = "test200setArchivedAdministrativeStatus"; - - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, null, task, result, ActivationStatusType.ARCHIVED); @@ -461,9 +409,7 @@ public void test200setArchivedAdministrativeStatus() throws Exception { @Test public void test201SetUndefinedAdministrativeStatus() throws Exception { - final String TEST_NAME = "test201SetUndefinedAdministrativeStatus"; - - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); //WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java index 3498d4e043d..7c19b8bd1ef 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java @@ -82,8 +82,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti */ @Test public void test100AssignJackDummyAccounts() throws Exception { - final String TEST_NAME = "test100AssignJackDummyAccounts"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -111,8 +109,6 @@ public void test100AssignJackDummyAccounts() throws Exception { */ @Test public void test105ModifyJackTitleCaptain() throws Exception { - final String TEST_NAME = "test105ModifyJackTitleCaptain"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -183,8 +179,6 @@ public void test105ModifyJackTitleCaptain() throws Exception { */ @Test public void test110ModifyJackTitleWhatever() throws Exception { - final String TEST_NAME = "test110ModifyJackTitleWhatever"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -256,8 +250,6 @@ private void assertNoAttributes(DummyAccountAsserter asserter) { */ @Test public void test112ReconcileJackWhatever() throws Exception { - final String TEST_NAME = "test112ReconcileJackWhatever"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -311,8 +303,6 @@ public void test112ReconcileJackWhatever() throws Exception { */ @Test public void test120MadJack() throws Exception { - final String TEST_NAME = "test120MadJack"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -349,8 +339,6 @@ public void test120MadJack() throws Exception { */ @Test public void test130ModifyJackTitleWhateverLower() throws Exception { - final String TEST_NAME = "test130ModifyJackTitleWhateverLower"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -379,8 +367,6 @@ public void test130ModifyJackTitleWhateverLower() throws Exception { */ @Test public void test140ModifyJackTitleEmpty() throws Exception { - final String TEST_NAME = "test140ModifyJackTitleEmpty"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -414,8 +400,6 @@ public void test140ModifyJackTitleEmpty() throws Exception { @Test public void test199UnassignJackDummyAccount() throws Exception { - final String TEST_NAME = "test199UnassignJackDummyAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -505,5 +489,4 @@ private String locationize(String title) { private String drinkize(String title) { return "Drink like a " + title; } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java index ebc1092b601..68cb4dd0950 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java @@ -6,14 +6,6 @@ */ package com.evolveum.midpoint.testing.story; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; - import java.io.File; import org.springframework.test.annotation.DirtiesContext; @@ -30,9 +22,8 @@ * Test for various resource-side errors, strange situations, timeouts * * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestMisbehavingResources extends AbstractStoryTest { @@ -52,8 +43,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010SanityAssignJackDummyAccount() throws Exception { - final String TEST_NAME = "test010SanityAssignJackDummyAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -67,13 +56,11 @@ public void test010SanityAssignJackDummyAccount() throws Exception { assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); } @Test public void test019SanityUnassignJackDummyAccount() throws Exception { - final String TEST_NAME = "test010SanityAssignJackDummyAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -94,8 +81,6 @@ public void test019SanityUnassignJackDummyAccount() throws Exception { */ @Test public void test100AssignJackDummyAccountTimeout() throws Exception { - final String TEST_NAME = "test100AssignJackDummyAccountTimeout"; - getDummyResource().setOperationDelayOffset(3000); Task task = getTestTask(); @@ -114,9 +99,7 @@ public void test100AssignJackDummyAccountTimeout() throws Exception { } @Test - public void test102AssignJackDummyAccounRetry() throws Exception { - final String TEST_NAME = "test102AssignJackDummyAccounRetry"; - + public void test102AssignJackDummyAccountRetry() throws Exception { getDummyResource().setOperationDelayOffset(0); clockForward("P1D"); @@ -133,7 +116,7 @@ public void test102AssignJackDummyAccounRetry() throws Exception { assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME); + .assertFullName(USER_JACK_FULL_NAME); } /** @@ -141,8 +124,6 @@ public void test102AssignJackDummyAccounRetry() throws Exception { */ @Test public void test110ModifyJackDummyAccountTimeout() throws Exception { - final String TEST_NAME = "test110ModifyJackDummyAccountTimeout"; - getDummyResource().setOperationDelayOffset(3000); Task task = getTestTask(); @@ -158,14 +139,12 @@ public void test110ModifyJackDummyAccountTimeout() throws Exception { assertInProgress(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) - // operation timed out, data not updated - .assertFullName(USER_JACK_FULL_NAME); + // operation timed out, data not updated + .assertFullName(USER_JACK_FULL_NAME); } @Test - public void test112ModifyJackDummyAccounRetry() throws Exception { - final String TEST_NAME = "test112ModifyJackDummyAccounRetry"; - + public void test112ModifyJackDummyAccountRetry() throws Exception { getDummyResource().setOperationDelayOffset(0); clockForward("P1D"); @@ -182,6 +161,6 @@ public void test112ModifyJackDummyAccounRetry() throws Exception { assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME_CAPTAIN); + .assertFullName(USER_JACK_FULL_NAME_CAPTAIN); } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java index 1b2ffc68d07..c21f6ae4ba7 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java @@ -6,14 +6,11 @@ * and European Union Public License. See LICENSE file for details. */ -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -23,18 +20,17 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.impl.polystring.Ascii7PolyStringNormalizer; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.polystring.PolyStringNormalizer; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * @author Radovan Semancik - * */ @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @@ -43,7 +39,6 @@ public class TestNormalizers extends AbstractModelIntegrationTest { public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "normalizers"); public static final File SYSTEM_CONFIGURATION_NORMALIZER_ASCII7_FILE = new File(TEST_DIR, "system-configuration-normalizer-ascii7.xml"); - public static final String SYSTEM_CONFIGURATION_NORMALIZER_ASCII7_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); protected static final File USER_TELEKE_FILE = new File(TEST_DIR, "user-teleke.xml"); protected static final String USER_TELEKE_OID = "e1b0b0a4-17c6-11e8-bfc9-efaa710b614a"; @@ -77,16 +72,13 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - PolyStringNormalizer prismNormalizer = prismContext.getDefaultPolyStringNormalizer(); - assertTrue("Wrong normalizer class, expected Ascii7PolyStringNormalizer, but was "+prismNormalizer.getClass(), + assertTrue("Wrong normalizer class, expected Ascii7PolyStringNormalizer, but was " + prismNormalizer.getClass(), prismNormalizer instanceof Ascii7PolyStringNormalizer); } @Test public void test100AddUserJack() throws Exception { - final String TEST_NAME = "test100AddUserJack"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -106,7 +98,6 @@ public void test100AddUserJack() throws Exception { @Test public void test110AddUserTeleke() throws Exception { - final String TEST_NAME = "test110AddUserTeleke"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -129,7 +120,8 @@ public void test110AddUserTeleke() throws Exception { private void assertPolyString(PrismObject user, QName propName, String expectedOrig, String expectedNorm) { PrismProperty prop = user.findProperty(ItemName.fromQName(propName)); PolyString polyString = prop.getRealValue(); - assertEquals("Wrong user "+propName.getLocalPart()+".orig", expectedOrig, polyString.getOrig()); + assertNotNull(polyString); + assertEquals("Wrong user " + propName.getLocalPart() + ".orig", expectedOrig, polyString.getOrig()); assertEquals("Wrong user \"+propName.getLocalPart()+\".norm", expectedNorm, polyString.getNorm()); } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java index 3dc48c61c9f..0d8b179f746 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java @@ -8,11 +8,8 @@ import java.io.File; import java.util.Collection; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -20,10 +17,12 @@ import com.evolveum.icf.dummy.resource.DummyObjectClass; import com.evolveum.icf.dummy.resource.DummyResource; -import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismContainerDefinition; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismObjectDefinition; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; @@ -31,13 +30,7 @@ import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; - +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @@ -50,15 +43,12 @@ public class TestNullAttribute extends AbstractStoryTest { protected static final File RESOURCE_DUMMY_FILE = new File(TEST_DIR, "resource-dummy.xml"); //see - protected static final String RESOURCE_DUMMY_ID = "DUMMY"; protected static final String RESOURCE_DUMMY_OID = "10000000-0000-0000-0000-000000000001"; - protected static final String RESOURCE_DUMMY_NAMESPACE = MidPointConstants.NS_RI; private static final String DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME = "fullname"; private static final String DUMMY_ACCOUNT_ATTRIBUTE_SHIP = "ship"; private static final String DUMMY_ACCOUNT_ATTRIBUTE_WEAPON = "weapon"; - public static final File ORG_TOP_FILE = new File(TEST_DIR, "org-top.xml"); public static final String ORG_TOP_OID = "00000000-8888-6666-0000-100000000001"; public static final File ROLE_ACCOUNTONLY_FILE = new File(TEST_DIR, "role-accountonly.xml"); @@ -70,19 +60,14 @@ public class TestNullAttribute extends AbstractStoryTest { public static final File USER_SMACK_FILE = new File(TEST_DIR, "user-smack.xml"); public static final String USER_SMACK_OID = "c0c010c0-d34d-b33f-f00d-111111111112"; - @Autowired private ReconciliationTaskHandler reconciliationTaskHandler; - protected static DummyResource dummyResource; protected static DummyResourceContoller dummyResourceCtl; - protected ResourceType resourceDummyType; protected PrismObject resourceDummy; - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - // Resources //default instance, no instance id //when id is set it is required to be present in resource.xml (I guess) @@ -103,28 +88,25 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - // Object Templates importObjectFromFile(OBJECT_TEMPLATE_USER_FILE, initResult); setDefaultUserTemplate(OBJECT_TEMPLATE_USER_OID); - // Role importObjectFromFile(ROLE_ACCOUNTONLY_FILE, initResult); importObjectFromFile(ROLE_SHIPNWEAPON_FILE, initResult); PrismObject rolesw = getRole(ROLE_SHIPNWEAPON_OID); - display("role shipNWeapon initial", rolesw); + display("role shipNWeapon initial", rolesw); //User - importObjectFromFile(USER_SMACK_FILE, initResult); + importObjectFromFile(USER_SMACK_FILE, initResult); } @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestNullAttribute.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OID, task); TestUtil.assertSuccess(testResult); @@ -135,7 +117,6 @@ public void test000Sanity() throws Exception { PrismAsserts.assertPropertyDefinition(userExtensionDef, new QName(NS_PIRACY, "ship"), DOMUtil.XSD_STRING, 0, 1); - } /** @@ -144,8 +125,6 @@ public void test000Sanity() throws Exception { */ @Test public void test010UserSmackAssignAccountOnlyRole() throws Exception { - final String TEST_NAME = "test010UserSmackAssignAccountOnlyRole"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -173,11 +152,10 @@ public void test010UserSmackAssignAccountOnlyRole() throws Exception { PrismObject accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result); display("accountModel jack after role account only assignment", accountModel); - PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath( DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME),"Smack Sparrow"); + PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME), "Smack Sparrow"); PrismAsserts.assertNoItem(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_SHIP)); PrismAsserts.assertNoItem(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_WEAPON)); - } /** @@ -187,23 +165,20 @@ public void test010UserSmackAssignAccountOnlyRole() throws Exception { */ @Test public void test020UserSmackSetAttribute() throws Exception { - final String TEST_NAME = "test020UserSmackSetAttribute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); PrismObject smack = getUser(USER_SMACK_OID); - display("smack initial: "+smack.debugDump()); + display("smack initial: " + smack.debugDump()); - - // WHEN + // WHEN @SuppressWarnings("unchecked, raw") Collection> deltas = (Collection) prismContext.deltaFor(UserType.class) - .item(UserType.F_EXTENSION, new QName(NS_PIRACY, "ship")).add("Black Pearl") - .asObjectDeltas(USER_SMACK_OID); + .item(UserType.F_EXTENSION, new QName(NS_PIRACY, "ship")).add("Black Pearl") + .asObjectDeltas(USER_SMACK_OID); modelService.executeChanges(deltas, null, task, result); // THEN @@ -225,8 +200,8 @@ public void test020UserSmackSetAttribute() throws Exception { PrismObject accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result); display("accountModel jack after role shipnweapon assignment", accountModel); - PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath( DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME),"Smack Sparrow"); - PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath( DUMMY_ACCOUNT_ATTRIBUTE_SHIP),"Black Pearl"); + PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME), "Smack Sparrow"); + PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_SHIP), "Black Pearl"); // weapon is not in user's extension (MID-3326) //PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_WEAPON),"pistol"); @@ -240,20 +215,17 @@ public void test020UserSmackSetAttribute() throws Exception { */ @Test // MID-3325 public void test030UserSmackRemoveAttribute() throws Exception { - final String TEST_NAME = "test030UserSmackRemoveAttribute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); - //TODO: best way to set extension properties? PrismObject userBefore = getUser(USER_SMACK_OID); display("User before", userBefore); PrismObject userNewPrism = userBefore.clone(); prismContext.adopt(userNewPrism); - if (userNewPrism.getExtension()==null)userNewPrism.createExtension(); + if (userNewPrism.getExtension() == null) { userNewPrism.createExtension(); } PrismContainer ext = userNewPrism.getExtension(); ext.setPropertyRealValue(PIRACY_SHIP_QNAME, null); @@ -266,7 +238,6 @@ public void test030UserSmackRemoveAttribute() throws Exception { when(); modelService.executeChanges(deltas, null, task, result); - // THEN then(); assertSuccess(result); @@ -287,11 +258,10 @@ public void test030UserSmackRemoveAttribute() throws Exception { PrismObject accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result); display("accountModel jack after attribute deletion", accountModel); - PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath( DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME),"Smack Sparrow"); + PrismAsserts.assertPropertyValue(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME), "Smack Sparrow"); PrismAsserts.assertNoItem(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_WEAPON)); PrismAsserts.assertNoItem(accountModel, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_SHIP)); - } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java index e6311798ce6..4488e935166 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java @@ -59,13 +59,10 @@ public class TestOperationCounts extends AbstractStoryTest { private static final String RESOURCE_DUMMY_THREE_OID = "f0c6cff1-30f6-46ca-b5a1-88c2dc47862c"; private static final File ROLE_ONE_FILE = new File(TEST_DIR, "role-one.xml"); - private static final String ROLE_ONE_OID = "369d1192-cb12-4cf9-90ea-0111895e9cb5"; private static final File ROLE_TWO_FILE = new File(TEST_DIR, "role-two.xml"); - private static final String ROLE_TWO_OID = "8a1e3f58-1fb8-451e-a251-126385ddfa0a"; private static final File ROLE_THREE_FILE = new File(TEST_DIR, "role-three.xml"); - private static final String ROLE_THREE_OID = "ce741b1a-0181-4c99-aaad-3d3a5f9eb48b"; private static final File USER_ALICE_FILE = new File(TEST_DIR, "user-alice.xml"); private static final String USER_ALICE_OID = "84851118-7579-46aa-a1c7-5b22eec1e443"; @@ -111,8 +108,7 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestOperationCounts.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult testResultOne = modelService.testResource(RESOURCE_DUMMY_ONE_OID, task); TestUtil.assertSuccess(testResultOne); @@ -124,8 +120,7 @@ public void test000Sanity() throws Exception { @Test public void test100AddAlice() throws Exception { - final String TEST_NAME = "test100AddAlice"; - Task task = createTracedTask(TEST_NAME); + Task task = createTracedTask(); OperationResult result = task.getResult(); // GIVEN @@ -141,8 +136,8 @@ public void test100AddAlice() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - RepoOpAsserter repoOpAsserter = createRepoOpAsserter(TEST_NAME).display(); - dumpThreadLocalCachePerformanceData(TEST_NAME); + RepoOpAsserter repoOpAsserter = createRepoOpAsserter().display(); + dumpThreadLocalCachePerformanceData(); assertUser(USER_ALICE_OID, "alice") .assertFullName("Alice White") @@ -171,8 +166,7 @@ public void test100AddAlice() throws Exception { // Some objects should be cached now @Test public void test110AddBob() throws Exception { - final String TEST_NAME = "test110AddBob"; - Task task = createTracedTask(TEST_NAME); + Task task = createTracedTask(); OperationResult result = task.getResult(); // GIVEN @@ -188,8 +182,8 @@ public void test110AddBob() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - RepoOpAsserter repoOpAsserter = createRepoOpAsserter(TEST_NAME).display(); - dumpThreadLocalCachePerformanceData(TEST_NAME); + RepoOpAsserter repoOpAsserter = createRepoOpAsserter().display(); + dumpThreadLocalCachePerformanceData(); assertUser(USER_BOB_OID, "bob") .assertFullName("Bob Black") @@ -215,8 +209,7 @@ public void test110AddBob() throws Exception { @Test public void test120ModifyBob() throws Exception { - final String TEST_NAME = "test120ModifyBob"; - Task task = createTracedTask(TEST_NAME); + Task task = createTracedTask(); OperationResult result = task.getResult(); // GIVEN @@ -236,8 +229,8 @@ public void test120ModifyBob() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - RepoOpAsserter repoOpAsserter = createRepoOpAsserter(TEST_NAME).display(); - dumpThreadLocalCachePerformanceData(TEST_NAME); + RepoOpAsserter repoOpAsserter = createRepoOpAsserter().display(); + dumpThreadLocalCachePerformanceData(); assertUser(USER_BOB_OID, "bob") .assertFullName("Bob Brown") diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java index 47276fc6d25..d9787cf755d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java @@ -88,8 +88,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - assertObjects(RoleType.class, NUMBER_OF_GENERATED_EMPTY_ROLES + NUMBER_OF_ORDINARY_ROLES); display("Repo reads", InternalMonitor.getCount(InternalCounters.REPOSITORY_READ_COUNT)); @@ -98,17 +96,15 @@ public void test000Sanity() throws Exception { @Test public void test100AddAlice() throws Exception { - final String TEST_NAME = "test100AddAlice"; - testAddUser(TEST_NAME, USER_ALICE_FILE, USER_ALICE_OID, 1); + testAddUser(USER_ALICE_FILE, USER_ALICE_OID, 1); } @Test public void test110AddBob() throws Exception { - final String TEST_NAME = "test110AddBob"; - testAddUser(TEST_NAME, USER_BOB_FILE, USER_BOB_OID, 1); + testAddUser(USER_BOB_FILE, USER_BOB_OID, 1); } - public void testAddUser(final String TEST_NAME, File userFile, String userOid, int roles) throws Exception { + public void testAddUser(File userFile, String userOid, int roles) throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java index 4c6145ede8f..abb64503e46 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java @@ -6,16 +6,11 @@ * and European Union Public License. See LICENSE file for details. */ -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.util.Collection; import java.util.List; - import javax.xml.namespace.QName; import org.opends.server.types.DirectoryException; @@ -40,26 +35,14 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author Radovan Semancik - * */ @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @@ -79,13 +62,12 @@ public class TestOrgSync extends AbstractStoryTest { protected static final File RESOURCE_DUMMY_HR_FILE = new File(TEST_DIR, "resource-dummy-hr.xml"); protected static final String RESOURCE_DUMMY_HR_ID = "HR"; protected static final String RESOURCE_DUMMY_HR_OID = "10000000-0000-0000-0000-000000000001"; - protected static final String RESOURCE_DUMMY_HR_NAMESPACE = MidPointConstants.NS_RI; protected static final File RESOURCE_OPENDJ_FILE = new File(TEST_DIR, "resource-opendj.xml"); protected static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; protected static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; - protected static final QName OPENDJ_ASSOCIATION_GROUP_NAME = new QName(RESOURCE_OPENDJ_NAMESPACE, - "group"); + protected static final QName OPENDJ_ASSOCIATION_GROUP_NAME = + new QName(RESOURCE_OPENDJ_NAMESPACE, "group"); private static final String DUMMY_ACCOUNT_ATTRIBUTE_HR_ORGPATH = "orgpath"; private static final String DUMMY_ACCOUNT_ATTRIBUTE_HR_RESPONSIBILITIES = "responsibilities"; @@ -102,8 +84,6 @@ public class TestOrgSync extends AbstractStoryTest { public static final File ROLE_META_RESPONSIBILITY_FILE = new File(TEST_DIR, "role-meta-responsibility.xml"); - public static final String ROLE_META_RESPONSIBILITY_OID = "10000000-0000-0000-0000-000000006602"; - protected static final File TASK_LIVE_SYNC_DUMMY_HR_FILE = new File(TEST_DIR, "task-dumy-hr-livesync.xml"); protected static final String TASK_LIVE_SYNC_DUMMY_HR_OID = "10000000-0000-0000-5555-555500000001"; @@ -198,7 +178,7 @@ public class TestOrgSync extends AbstractStoryTest { protected static final int TASK_WAIT_TIMEOUT = 40000; - @Autowired(required = true) + @Autowired private ReconciliationTaskHandler reconciliationTaskHandler; private DebugReconciliationTaskResultListener reconciliationTaskResultListener; @@ -225,7 +205,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -238,17 +218,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // Resources initDummyResource(RESOURCE_DUMMY_HR_ID, RESOURCE_DUMMY_HR_FILE, RESOURCE_DUMMY_HR_OID, c -> { - DummyObjectClass dummyAdAccountObjectClass = c.getDummyResource().getAccountObjectClass(); - c.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, - String.class, false, false); - c.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, - String.class, false, false); - c.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_HR_ORGPATH, - String.class, false, false); - c.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_HR_RESPONSIBILITIES, - String.class, false, true); - c.getDummyResource().setSyncStyle(DummySyncStyle.SMART); - } , initTask, initResult); + DummyObjectClass dummyAdAccountObjectClass = c.getDummyResource().getAccountObjectClass(); + c.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, + String.class, false, false); + c.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, + String.class, false, false); + c.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_HR_ORGPATH, + String.class, false, false); + c.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_HR_RESPONSIBILITIES, + String.class, false, true); + c.getDummyResource().setSyncStyle(DummySyncStyle.SMART); + }, initTask, initResult); dummyResourceHr = getDummyResource(RESOURCE_DUMMY_HR_ID); resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, @@ -286,7 +266,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; Task task = getTestTask(); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); @@ -307,9 +286,6 @@ public void test000Sanity() throws Exception { */ @Test public void test100AddHrAccountHerman() throws Exception { - final String TEST_NAME = "test100AddHrAccountHerman"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_HERMAN_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_HERMAN_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_HERMAN_LAST_NAME); @@ -346,9 +322,6 @@ public void test100AddHrAccountHerman() throws Exception { */ @Test public void test105AddHrAccountLemonhead() throws Exception { - final String TEST_NAME = "test105AddHrAccountLemonhead"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_LEMONHEAD_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_LEMONHEAD_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_LEMONHEAD_LAST_NAME); @@ -390,9 +363,6 @@ public void test105AddHrAccountLemonhead() throws Exception { */ @Test public void test106AddHrAccountSharptooth() throws Exception { - final String TEST_NAME = "test106AddHrAccountSharptooth"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_SHARPTOOTH_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_SHARPTOOTH_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_SHARPTOOTH_LAST_NAME); @@ -433,9 +403,6 @@ public void test106AddHrAccountSharptooth() throws Exception { */ @Test public void test107AddHrAccountRedskull() throws Exception { - final String TEST_NAME = "test107AddHrAccountRedskull"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_REDSKULL_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_REDSKULL_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_REDSKULL_LAST_NAME); @@ -475,9 +442,6 @@ public void test107AddHrAccountRedskull() throws Exception { */ @Test public void test108RedskullGoesVegetarian() throws Exception { - final String TEST_NAME = "test108RedskullGoesVegetarian"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount account = dummyResourceHr.getAccountByUsername(ACCOUNT_REDSKULL_USERNAME); // WHEN @@ -515,9 +479,6 @@ public void test108RedskullGoesVegetarian() throws Exception { */ @Test public void test109HrDeleteRedskull() throws Exception { - final String TEST_NAME = "test109HrDeleteRedskull"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - // WHEN when(); dummyResourceHr.deleteAccountByName(ACCOUNT_REDSKULL_USERNAME); @@ -544,9 +505,6 @@ public void test109HrDeleteRedskull() throws Exception { */ @Test public void test110AddHrAccountGuybrush() throws Exception { - final String TEST_NAME = "test110AddHrAccountGuybrush"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_GUYBRUSH_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_GUYBRUSH_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_GUYBRUSH_LAST_NAME); @@ -589,9 +547,6 @@ public void test110AddHrAccountGuybrush() throws Exception { */ @Test public void test115AddHrAccountMancomb() throws Exception { - final String TEST_NAME = "test115AddHrAccountMancomb"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_MANCOMB_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_MANCOMB_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_MANCOMB_LAST_NAME); @@ -635,9 +590,6 @@ public void test115AddHrAccountMancomb() throws Exception { */ @Test public void test117AddHrAccountCobb() throws Exception { - final String TEST_NAME = "test117AddHrAccountCobb"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_COBB_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_COBB_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_COBB_LAST_NAME); @@ -681,9 +633,6 @@ public void test117AddHrAccountCobb() throws Exception { */ @Test public void test130AddHrAccountLargo() throws Exception { - final String TEST_NAME = "test130AddHrAccountLargo"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_LARGO_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_LARGO_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_LARGO_LAST_NAME); @@ -733,9 +682,6 @@ public void test130AddHrAccountLargo() throws Exception { */ @Test public void test140AddHrAccountWally() throws Exception { - final String TEST_NAME = "test140AddHrAccountWally"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_WALLY_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_WALLY_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_WALLY_LAST_NAME); @@ -776,9 +722,6 @@ public void test140AddHrAccountWally() throws Exception { */ @Test public void test142AddHrAccountAugustus() throws Exception { - final String TEST_NAME = "test142AddHrAccountAugustus"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_AUGUSTUS_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_AUGUSTUS_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_AUGUSTUS_LAST_NAME); @@ -819,9 +762,6 @@ public void test142AddHrAccountAugustus() throws Exception { */ @Test public void test185AddHrAccountStan() throws Exception { - final String TEST_NAME = "test185AddHrAccountStan"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_STAN_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_STAN_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_STAN_LAST_NAME); @@ -864,9 +804,6 @@ public void test185AddHrAccountStan() throws Exception { */ @Test public void test186AddHrAccountCapsize() throws Exception { - final String TEST_NAME = "test186AddHrAccountCapsize"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_CAPSIZE_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_CAPSIZE_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_CAPSIZE_LAST_NAME); @@ -909,9 +846,6 @@ public void test186AddHrAccountCapsize() throws Exception { */ @Test public void test187AddHrAccountRogersSr() throws Exception { - final String TEST_NAME = "test187AddHrAccountRogersSr"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_ROGERSSR_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_ROGERSSR_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_ROGERSSR_LAST_NAME); @@ -955,9 +889,6 @@ public void test187AddHrAccountRogersSr() throws Exception { */ @Test public void test190AddHrAccountTeleke() throws Exception { - final String TEST_NAME = "test190AddHrAccountTeleke"; - Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_TELEKE_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_TELEKE_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_TELEKE_LAST_NAME); @@ -997,8 +928,6 @@ public void test190AddHrAccountTeleke() throws Exception { @Test public void test500ReconcileOpenDJDefault() throws Exception { - final String TEST_NAME = "test500ReconcileOpenDJDefault"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1041,11 +970,8 @@ public void test500ReconcileOpenDJDefault() throws Exception { @Test public void test502ReconcileOpenDJDefaultAgain() throws Exception { - final String TEST_NAME = "test502ReconcileOpenDJDefaultAgain"; // GIVEN - Task task = getTestTask(); - OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); assertUsers(18); @@ -1077,8 +1003,6 @@ public void test502ReconcileOpenDJDefaultAgain() throws Exception { @Test public void test510ReconcileOpenDJLdapGroup() throws Exception { - final String TEST_NAME = "test510ReconcileOpenDJLdapGroup"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1120,14 +1044,10 @@ public void test510ReconcileOpenDJLdapGroup() throws Exception { @Test public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { - final String TEST_NAME = "test550ReconcileOpenDJAfterMembershipChange"; - // We manually remove Lemonhead from R_canibalism group // And check whether reconciliation re-adds him again // GIVEN - Task task = getTestTask(); - OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Collection membersBeforeTest = openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN); @@ -1194,9 +1114,9 @@ private PrismObject getAndAssertReplicatedOrg(String orgName) // TODO assert shadow content Entry ouEntry = openDJController.searchSingle("ou=" + orgName); - assertNotNull("No ou LDAP entry for " + orgName); + assertNotNull("No ou LDAP entry for " + orgName, ouEntry); display("OU entry", ouEntry); - openDJController.assertObjectClass(ouEntry, "organizationalUnit"); + OpenDJController.assertObjectClass(ouEntry, "organizationalUnit"); return org; } @@ -1215,7 +1135,7 @@ private String assertResponsibility(PrismObject user, String respName) CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException { String respRoleName = "R_" + respName; PrismObject respRole = searchObjectByName(RoleType.class, respRoleName); - assertNotNull("No role for responsibility " + respName); + assertNotNull("No role for responsibility " + respName, respRole); display("Responsibility role for " + respName, respRole); assertAssignedRole(user, respRole.getOid()); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java index 0d5f862cc95..6f7a0b3574e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java @@ -146,8 +146,6 @@ private String formatGroupName(int num) { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - assertObjects(RoleType.class, NUMBER_OF_GENERATED_EMPTY_ROLES + NUMBER_OF_GENERATED_DUMMY_ROLES + NUMBER_OF_ORDINARY_ROLES); display("Repo reads", InternalMonitor.getCount(InternalCounters.REPOSITORY_READ_COUNT)); @@ -156,8 +154,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddCheese() throws Exception { - final String TEST_NAME = "test100AddCheese"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -198,8 +194,6 @@ public void test100AddCheese() throws Exception { @Test public void test110RecomputeCheese() throws Exception { - final String TEST_NAME = "test110RecomputeCheese"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -239,8 +233,6 @@ public void test110RecomputeCheese() throws Exception { @Test public void test120CheesePreviewChanges() throws Exception { - final String TEST_NAME = "test120CheesePreviewChanges"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -306,8 +298,6 @@ private void assertCheeseRoleMembershipRef(PrismObject cheese) { */ @Test public void test200DummyGroups() throws Exception { - final String TEST_NAME = "test200DummyGroups"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -380,8 +370,6 @@ public void test200DummyGroups() throws Exception { */ @Test public void test210AddBob() throws Exception { - final String TEST_NAME = "test210AddBob"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -428,8 +416,6 @@ public void test210AddBob() throws Exception { */ @Test public void test212RecomputeBob() throws Exception { - final String TEST_NAME = "test212RecomputeBob"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -472,8 +458,6 @@ public void test212RecomputeBob() throws Exception { */ @Test public void test2124ReconcileBob() throws Exception { - final String TEST_NAME = "test212RecomputeBob"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -534,8 +518,6 @@ private void assertBobDummy(int expectedBottlesOfRum) throws Exception { */ @Test public void test220AddAlice() throws Exception { - final String TEST_NAME = "test220AddAlice"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -584,8 +566,6 @@ public void test220AddAlice() throws Exception { */ @Test public void test222RecomputeAlice() throws Exception { - final String TEST_NAME = "test222RecomputeAlice"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -628,8 +608,6 @@ public void test222RecomputeAlice() throws Exception { */ @Test public void test224ReconcileAlice() throws Exception { - final String TEST_NAME = "test224ReconcileAlice"; - Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java index f8b782b990d..acec70abe03 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java @@ -11,11 +11,7 @@ import static org.testng.AssertJUnit.assertNotNull; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.*; import org.opends.server.types.DirectoryException; import org.springframework.test.annotation.DirtiesContext; @@ -28,50 +24,36 @@ import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.processor.ResourceAttribute; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** - * * Recon should delete resourceAttributes - * + *

* resourceAttributes title and givenName have strong mappings * title has source honorificPrefix * givenName has source givenName - * + *

* focus attributes honorificPrefix and/or givenName do not exist and resourceAttributes title and givenName are added manually * -> reconcile should remove resourceAtributes * as of git-v3.7.1-57-gc5757c3b0d this seems to work for honorificPrefix/title but not for givenName/givenName * * @author michael gruber - * */ @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestReconNullValue extends AbstractStoryTest { - public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "recon-null-value"); private static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; - private static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; public static final String ORG_TOP_OID = "00000000-8888-6666-0000-100000000001"; public static final String OBJECT_TEMPLATE_USER_OID = "10000000-0000-0000-0000-000000000222"; @@ -83,10 +65,6 @@ public class TestReconNullValue extends AbstractStoryTest { private static final String ACCOUNT_ATTRIBUTE_TITLE = "title"; private static final String ACCOUNT_ATTRIBUTE_GIVENNAME = "givenName"; - - private ResourceType resourceOpenDjType; - private PrismObject resourceOpenDj; - @Override protected String getTopOrgOid() { return ORG_TOP_OID; @@ -96,14 +74,13 @@ private File getTestDir() { return TEST_DIR; } - @Override protected void startResources() throws Exception { openDJController.startCleanServerRI(); } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -112,8 +89,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti super.initSystem(initTask, initResult); //Resources - resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, new File(getTestDir(), "resource-opendj.xml"), RESOURCE_OPENDJ_OID, initTask, initResult); - resourceOpenDjType = resourceOpenDj.asObjectable(); + PrismObject resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, new File(getTestDir(), "resource-opendj.xml"), RESOURCE_OPENDJ_OID, initTask, initResult); openDJController.setResource(resourceOpenDj); //org @@ -129,8 +105,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestReconNullValue.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -140,17 +115,13 @@ public void test000Sanity() throws Exception { display("FINISHED: test000Sanity"); } - - @Test public void test100CreateUsers() throws Exception { - final String TEST_NAME = "test200CreateUsers"; - Task task = taskManager.createTaskInstance(TestReconNullValue.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user0Before = createUser(USER_0_NAME, "givenName0", "familyName0", true); - // WHEN when(); display("Adding user0", user0Before); @@ -166,27 +137,22 @@ public void test100CreateUsers() throws Exception { dumpOrgTree(); - assertShadowAttribute(user0After, ShadowKindType.ACCOUNT, LDAP_INTENT_DEFAULT, ACCOUNT_ATTRIBUTE_GIVENNAME, "givenName0"); - + assertShadowAttribute(user0After, ShadowKindType.ACCOUNT, LDAP_INTENT_DEFAULT, ACCOUNT_ATTRIBUTE_GIVENNAME, "givenName0"); } /** * add honorificPrefix - * + *

* in resource account value for title should have been added - * */ @Test public void test130AddHonorificPrefix() throws Exception { - final String TEST_NAME = "test140AddHonorificPrefix"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); - //TODO: best way to set extension properties? PrismObject userBefore = getObjectByName(UserType.class, USER_0_NAME); display("User before", userBefore); @@ -204,7 +170,6 @@ public void test130AddHonorificPrefix() throws Exception { when(); modelService.executeChanges(deltas, null, task, result); - // THEN then(); assertSuccess(result); @@ -222,27 +187,23 @@ public void test130AddHonorificPrefix() throws Exception { PrismObject accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result); display("accountModel after attribute deletion", accountModel); - assertShadowAttribute(userAfter, ShadowKindType.ACCOUNT, LDAP_INTENT_DEFAULT, ACCOUNT_ATTRIBUTE_GIVENNAME, "givenName0"); - assertShadowAttribute(userAfter, ShadowKindType.ACCOUNT, LDAP_INTENT_DEFAULT, ACCOUNT_ATTRIBUTE_TITLE, "Princess"); + assertShadowAttribute(userAfter, ShadowKindType.ACCOUNT, LDAP_INTENT_DEFAULT, ACCOUNT_ATTRIBUTE_GIVENNAME, "givenName0"); + assertShadowAttribute(userAfter, ShadowKindType.ACCOUNT, LDAP_INTENT_DEFAULT, ACCOUNT_ATTRIBUTE_TITLE, "Princess"); } /** * delete honorificPrefix and givenName - * + *

* in resource account value for title and givenName should have been deleted - * */ @Test public void test140dDeleteHonorificPrefixGivenName() throws Exception { - final String TEST_NAME = "test140dDeleteHonorificPrefixGivenName"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); - //TODO: best way to set extension properties? PrismObject userBefore = getObjectByName(UserType.class, USER_0_NAME); display("User before", userBefore); @@ -261,7 +222,6 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { when(); modelService.executeChanges(deltas, null, task, result); - // THEN then(); assertSuccess(result); @@ -269,7 +229,6 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); display("User after deleting attribute honorificPrefix", userAfter); - String accountOid = getLinkRefOid(userAfter, RESOURCE_OPENDJ_OID); // Check shadow @@ -285,31 +244,25 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { } - /** * add title in resource account (not using midpoint) * do recompute * in resource account value for title should have been removed again - * */ @Test public void test150RemoveTitleRA() throws Exception { - final String TEST_NAME = "test150RemoveTitleRA"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); - //TODO: best way to set extension properties? PrismObject userBefore = getObjectByName(UserType.class, USER_0_NAME); display("User before", userBefore); - - openDJController.executeLdifChange("dn: uid="+USER_0_NAME+",ou=people,dc=example,dc=com\n"+ - "changetype: modify\n"+ - "add: title\n"+ + openDJController.executeLdifChange("dn: uid=" + USER_0_NAME + ",ou=people,dc=example,dc=com\n" + + "changetype: modify\n" + + "add: title\n" + "title: Earl"); display("LDAP after addition"); @@ -329,7 +282,6 @@ public void test150RemoveTitleRA() throws Exception { PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); display("User smack after adding attribute title", userAfter); - String accountOid = getLinkRefOid(userAfter, RESOURCE_OPENDJ_OID); // Check shadow @@ -340,7 +292,7 @@ public void test150RemoveTitleRA() throws Exception { PrismObject accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result); display("accountModel after attribute addition", accountModel); - PrismAsserts.assertNoItem(accountModel, openDJController.getAttributePath( ACCOUNT_ATTRIBUTE_TITLE)); + PrismAsserts.assertNoItem(accountModel, openDJController.getAttributePath(ACCOUNT_ATTRIBUTE_TITLE)); } @@ -349,26 +301,21 @@ public void test150RemoveTitleRA() throws Exception { * do recompute * in resource account value for givenName should have been removed again * See also https://wiki.evolveum.com/display/midPoint/Resource+Schema+Handling#ResourceSchemaHandling-AttributeTolerance - * */ @Test //MID-4567 public void test160SetGivenNameAttributeAndReconcile() throws Exception { - final String TEST_NAME = "test160SetGivenNameAttributeAndReconcile"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); - //TODO: best way to set extension properties? PrismObject userBefore = getObjectByName(UserType.class, USER_0_NAME); display("User before", userBefore); - - openDJController.executeLdifChange("dn: uid="+USER_0_NAME+",ou=people,dc=example,dc=com\n"+ - "changetype: modify\n"+ - "replace: givenName\n"+ + openDJController.executeLdifChange("dn: uid=" + USER_0_NAME + ",ou=people,dc=example,dc=com\n" + + "changetype: modify\n" + + "replace: givenName\n" + "givenName: given0again"); display("LDAP after addition"); @@ -388,7 +335,6 @@ public void test160SetGivenNameAttributeAndReconcile() throws Exception { PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); display("User smack after adding attribute title", userAfter); - String accountOid = getLinkRefOid(userAfter, RESOURCE_OPENDJ_OID); // Check shadow @@ -408,8 +354,6 @@ public void test160SetGivenNameAttributeAndReconcile() throws Exception { */ @Test //MID-4567 public void test170ReplaceGivenNameEmpty() throws Exception { - final String TEST_NAME = "test170ReplaceGivenNameEmpty"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -418,9 +362,9 @@ public void test170ReplaceGivenNameEmpty() throws Exception { PrismObject userBefore = getObjectByName(UserType.class, USER_0_NAME); display("User before", userBefore); - openDJController.executeLdifChange("dn: uid="+USER_0_NAME+",ou=people,dc=example,dc=com\n"+ - "changetype: modify\n"+ - "replace: givenName\n"+ + openDJController.executeLdifChange("dn: uid=" + USER_0_NAME + ",ou=people,dc=example,dc=com\n" + + "changetype: modify\n" + + "replace: givenName\n" + "givenName: given1again"); display("LDAP after addition"); @@ -440,7 +384,6 @@ public void test170ReplaceGivenNameEmpty() throws Exception { PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); display("User smack after adding attribute title", userAfter); - String accountOid = getLinkRefOid(userAfter, RESOURCE_OPENDJ_OID); // Check shadow @@ -460,9 +403,8 @@ private void dumpLdap() throws DirectoryException { display("LDAP server content", openDJController.dumpEntries()); } - - protected PrismObject getObjectByName( - Class clazz, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, + protected PrismObject getObjectByName(Class clazz, String name) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject object = (PrismObject) findObjectByName(clazz, name); assertNotNull("The object " + name + " of type " + clazz + " is missing!", object); @@ -471,9 +413,10 @@ protected objShadow = getShadowModel(objOid); display("Focus " + focusName + " kind " + kind + " intent " + intent + " shadow", objShadow); - List valuesList = new ArrayList(Arrays.asList(values)); + List valuesList = new ArrayList<>(Arrays.asList(values)); for (Object att : objShadow.asObjectable().getAttributes().asPrismContainerValue().getItems()) { if (att instanceof ResourceAttribute) { @@ -489,7 +432,7 @@ private void assertShadowAttribute(PrismObject focus, ShadowKindType kind, Strin if (attribute.equals(((ResourceAttribute) att).getNativeAttributeName())) { - List propValsString = new ArrayList(propVals.size()); + List propValsString = new ArrayList<>(propVals.size()); for (Object pval : propVals) { propValsString.add(pval.toString()); } @@ -503,5 +446,4 @@ private void assertShadowAttribute(PrismObject focus, ShadowKindType kind, Strin } } } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java index 16995a607a3..57c8bacaac8 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java @@ -7,18 +7,12 @@ package com.evolveum.midpoint.testing.story; - -import static com.evolveum.midpoint.test.IntegrationTestTools.assertAttribute; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import java.io.File; import java.util.ArrayList; import java.util.Collection; -import javax.xml.namespace.QName; - import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.springframework.test.annotation.DirtiesContext; @@ -32,40 +26,22 @@ import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.ResultHandler; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommonException; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestRetirement extends AbstractStoryTest { @@ -74,23 +50,19 @@ public class TestRetirement extends AbstractStoryTest { protected static final File RESOURCE_OPENDJ_FILE = new File(TEST_DIR, "resource-opendj.xml"); protected static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; protected static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; - protected static final QName OPENDJ_ASSOCIATION_GROUP_NAME = new QName(RESOURCE_OPENDJ_NAMESPACE, "group"); public static final File ORG_TOP_FILE = new File(TEST_DIR, "org-top.xml"); public static final String ORG_TOP_OID = "00000000-8888-6666-0000-100000000001"; public static final File ORG_RETIRED_FILE = new File(TEST_DIR, "org-retired.xml"); public static final String ORG_RETIRED_OID = "00000000-8888-6666-0000-100000ffffff"; - public static final String ORG_RETIRED_NAME = "RETIRED"; public static final File ROLE_META_ORG_FILE = new File(TEST_DIR, "role-meta-org.xml"); public static final String ROLE_META_ORG_OID = "10000000-0000-0000-0000-000000006601"; protected static final String ORG_ROYULA_CARPATHIA_NAME = "Royula Carpathia"; protected static final String ORG_CORTUV_HRAD_NAME = "Čortův hrád"; - protected static final String ORG_CORTUV_HRAD_NAME2 = "ani zblo"; protected static final String ORG_VYSNE_VLKODLAKY_NAME = "Vyšné Vlkodlaky"; - protected static final String ORG_ROYULA_DIABOLICA_NAME = "Royula Diábolica"; protected static final String ORG_TYPE_FUNCTIONAL = "functional"; @@ -102,7 +74,6 @@ public class TestRetirement extends AbstractStoryTest { protected static final String USER_TELEKE_FAMILY_NAME = "Teleke z Tölökö"; protected static final String USER_GORC_USERNAME = "gorc"; - protected static final String USER_GORC_USERNAME2 = "obluda"; protected static final String USER_GORC_GIVEN_NAME = "Robert"; protected static final String USER_GORC_FAMILY_NAME = "Gorc z Gorců"; @@ -116,7 +87,6 @@ public class TestRetirement extends AbstractStoryTest { protected String orgRolyulaCarpathiaOid; protected String orgCortuvHradOid; protected String orgVysneVlkodlakyOid; - protected String orgRolyulaDiabolicaOid; protected String userGorcOid; @Override @@ -130,7 +100,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -138,7 +108,6 @@ public static void stopResources() throws Exception { public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - // Resources resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult); resourceOpenDjType = resourceOpenDj.asObjectable(); @@ -153,8 +122,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -165,8 +133,7 @@ public void test000Sanity() throws Exception { @Test public void test050AddOrgRetired() throws Exception { - final String TEST_NAME = "test050AddOrgRetired"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = PrismTestUtil.parseObject(ORG_RETIRED_FILE); @@ -194,17 +161,16 @@ public void test050AddOrgRetired() throws Exception { // TODO assert shadow content Entry ouEntry = openDJController.fetchEntry(ouShadow.getName().getOrig()); - assertNotNull("No ou LDAP entry for retirement ("+ouShadow.getName().getOrig()+")", ouEntry); + assertNotNull("No ou LDAP entry for retirement (" + ouShadow.getName().getOrig() + ")", ouEntry); display("OU retirement entry", openDJController.toHumanReadableLdifoid(ouEntry)); - openDJController.assertObjectClass(ouEntry, "organizationalUnit"); + OpenDJController.assertObjectClass(ouEntry, "organizationalUnit"); assertSubOrgs(org, 0); } @Test public void test100AddOrgRoyulaCarpathia() throws Exception { - final String TEST_NAME = "test100AddOrgRoyulaCarpathia"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID); @@ -231,8 +197,7 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { @Test public void test110AddUserTeleke() throws Exception { - final String TEST_NAME = "test110AddUserTeleke"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_TELEKE_USERNAME, @@ -248,7 +213,7 @@ public void test110AddUserTeleke() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - PrismObject userAfter = getAndAssertUser(USER_TELEKE_USERNAME, ORG_ROYULA_CARPATHIA_NAME); + getAndAssertUser(USER_TELEKE_USERNAME); PrismObject orgAfter = getAndAssertFunctionalOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID); @@ -261,8 +226,7 @@ public void test110AddUserTeleke() throws Exception { @Test public void test200AddOrgCortuvHrad() throws Exception { - final String TEST_NAME = "test200AddOrgCortuvHrad"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); @@ -290,8 +254,7 @@ public void test200AddOrgCortuvHrad() throws Exception { @Test public void test210AddUserGorc() throws Exception { - final String TEST_NAME = "test210AddUserGorc"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_GORC_USERNAME, @@ -307,7 +270,7 @@ public void test210AddUserGorc() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - PrismObject userAfter = getAndAssertUser(USER_GORC_USERNAME, ORG_CORTUV_HRAD_NAME, ORG_ROYULA_CARPATHIA_NAME); + PrismObject userAfter = getAndAssertUser(USER_GORC_USERNAME); userGorcOid = userAfter.getOid(); dumpOrgTree(); @@ -316,8 +279,7 @@ public void test210AddUserGorc() throws Exception { @Test public void test220AddOrgVysneVlkodlaky() throws Exception { - final String TEST_NAME = "test220AddOrgVysneVlkodlaky"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_VYSNE_VLKODLAKY_NAME, orgCortuvHradOid); @@ -345,8 +307,7 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { @Test public void test230AddUserViljaDezi() throws Exception { - final String TEST_NAME = "test230AddUserViljaDezi"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_DEZI_USERNAME, @@ -362,7 +323,7 @@ public void test230AddUserViljaDezi() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - PrismObject userAfter = getAndAssertUser(USER_DEZI_USERNAME, ORG_VYSNE_VLKODLAKY_NAME, ORG_CORTUV_HRAD_NAME, ORG_ROYULA_CARPATHIA_NAME); + getAndAssertUser(USER_DEZI_USERNAME); dumpOrgTree(); dumpLdap(); @@ -370,11 +331,10 @@ public void test230AddUserViljaDezi() throws Exception { @Test public void test300RetireUserGorc() throws Exception { - final String TEST_NAME = "test300RetireUserGorc"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(orgCortuvHradOid, OrgType.COMPLEX_TYPE, null, null, null, false)); modifications.add(createAssignmentModification(ORG_RETIRED_OID, OrgType.COMPLEX_TYPE, null, null, null, true)); ObjectDelta userDelta = prismContext.deltaFactory().object() @@ -399,8 +359,7 @@ public void test300RetireUserGorc() throws Exception { @Test public void test302ReconcileUserGorc() throws Exception { - final String TEST_NAME = "test302ReconcileUserGorc"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -421,8 +380,7 @@ public void test302ReconcileUserGorc() throws Exception { @Test public void test303ReconcileUserGorcAgain() throws Exception { - final String TEST_NAME = "test303ReconcileUserGorcAgain"; - Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -482,37 +440,38 @@ private PrismObject createOrg(String name, String parentOrgOid) throws return org; } - private PrismObject getAndAssertUser(String username, String directOrgGroupname, String... indirectGroupNames) throws SchemaException, CommonException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException { + private PrismObject getAndAssertUser(String username) + throws CommonException, DirectoryException { PrismObject user = findUserByUsername(username); display("user", user); String shadowOid = getLinkRefOid(user, RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT); PrismObject accountShadow = getShadowModel(shadowOid); - display("Account "+username+" shadow", accountShadow); + display("Account " + username + " shadow", accountShadow); // TODO assert shadow content - Entry accountEntry = openDJController.searchSingle("uid="+username); - assertNotNull("No account LDAP entry for "+username, accountEntry); + Entry accountEntry = openDJController.searchSingle("uid=" + username); + assertNotNull("No account LDAP entry for " + username, accountEntry); display("account entry", openDJController.toHumanReadableLdifoid(accountEntry)); - openDJController.assertObjectClass(accountEntry, "inetOrgPerson"); + OpenDJController.assertObjectClass(accountEntry, "inetOrgPerson"); return user; } - private PrismObject getAndAssertRetiredUser(String username) throws SchemaException, CommonException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException { + private PrismObject getAndAssertRetiredUser(String username) throws CommonException, DirectoryException { PrismObject user = findUserByUsername(username); display("user", user); String shadowOid = getLinkRefOid(user, RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT); PrismObject accountShadow = getShadowModel(shadowOid); - display("Account "+username+" shadow", accountShadow); + display("Account " + username + " shadow", accountShadow); // TODO assert shadow content - String dn = "uid=RRR-"+username+",ou=RETIRED,dc=example,dc=com"; + String dn = "uid=RRR-" + username + ",ou=RETIRED,dc=example,dc=com"; Entry accountEntry = openDJController.fetchEntry(dn); - assertNotNull("No account LDAP entry for "+username+" ("+dn+")", accountEntry); + assertNotNull("No account LDAP entry for " + username + " (" + dn + ")", accountEntry); display("account entry", openDJController.toHumanReadableLdifoid(accountEntry)); - openDJController.assertObjectClass(accountEntry, "inetOrgPerson"); + OpenDJController.assertObjectClass(accountEntry, "inetOrgPerson"); return user; } @@ -525,13 +484,13 @@ private PrismObject getAndAssertFunctionalOrg(String orgName, String di String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, LDAP_GROUP_INTENT); PrismObject groupShadow = getShadowModel(groupOid); - display("Org "+orgName+" group shadow", groupShadow); + display("Org " + orgName + " group shadow", groupShadow); // TODO assert shadow content - Entry groupEntry = openDJController.searchSingle("cn="+orgName); - assertNotNull("No group LDAP entry for "+orgName, groupEntry); + Entry groupEntry = openDJController.searchSingle("cn=" + orgName); + assertNotNull("No group LDAP entry for " + orgName, groupEntry); display("OU GROUP entry", openDJController.toHumanReadableLdifoid(groupEntry)); - openDJController.assertObjectClass(groupEntry, "groupOfUniqueNames"); + OpenDJController.assertObjectClass(groupEntry, "groupOfUniqueNames"); assertHasOrg(org, directParentOrgOid); assertAssignedOrg(org, directParentOrgOid); @@ -543,59 +502,4 @@ private void dumpLdap() throws DirectoryException { display("LDAP server tree", openDJController.dumpTree()); display("LDAP server content", openDJController.dumpEntries()); } - - private void assertGroupMembers(PrismObject org, String... members) throws Exception { - String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, "org-group"); - PrismObject groupShadow = getShadowModel(groupOid); - assertAttribute(groupShadow.asObjectable(), new QName(MidPointConstants.NS_RI, "uniqueMember"), members); - } - - private void assertNoGroupMembers(PrismObject org) throws Exception { - String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, "org-group"); - PrismObject groupShadow = getShadowModel(groupOid); - assertNoAttribute(groupShadow.asObjectable(), new QName(MidPointConstants.NS_RI, "uniqueMember")); - } - - private void reconcileAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = getTestTask(); - OperationResult result = task.getResult(); - ResultHandler handler = new ResultHandler() { - @Override - public boolean handle(PrismObject object, OperationResult parentResult) { - try { - display("reconciling "+object); - reconcileUser(object.getOid(), task, parentResult); - } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException - | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException - | ConfigurationException | SecurityViolationException e) { - throw new SystemException(e.getMessage(), e); - } - return true; - } - }; - display("Reconciling all users"); - modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); - } - - private void reconcileAllOrgs() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = getTestTask(); - OperationResult result = task.getResult(); - ResultHandler handler = new ResultHandler() { - @Override - public boolean handle(PrismObject object, OperationResult parentResult) { - try { - display("reconciling "+object); - reconcileOrg(object.getOid(), task, parentResult); - } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException - | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException - | ConfigurationException | SecurityViolationException e) { - throw new SystemException(e.getMessage(), e); - } - return true; - } - }; - display("Reconciling all orgs"); - modelService.searchObjectsIterative(OrgType.class, null, handler, null, task, result); - } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java index f2a5018b26a..d5c31e577f2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java @@ -39,12 +39,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -/** - * - * @author Katarina Valalikova - * - */ - @ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestScience extends AbstractStoryTest { @@ -57,9 +51,6 @@ public class TestScience extends AbstractStoryTest { private static final File ROLE_STATISTICS_FILE = new File(TEST_DIR, "role-statistics.xml"); private static final String ROLE_STATISTICS_OID = "23d90f70-1924-419e-9beb-78a8bde6d261"; - private static final File ROLE_MATH_FILE = new File(TEST_DIR, "role-math.xml"); - private static final String ROLE_MATH_OID = ""; - private static final File GROUP_STATS_USERS_LDIF_FILE = new File(TEST_DIR, "group-stats.ldif"); private static final File RESOURCE_OPENDJ_AD_SIMULATION_FILE = new File(TEST_DIR, "resource-opendj-ad-simulation.xml"); @@ -105,7 +96,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -152,7 +143,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; Task task = getTestTask(); OperationResult testResultStats = modelService.testResource(RESOURCE_DUMMY_STATS_OID, task); @@ -170,7 +160,6 @@ public void test000Sanity() throws Exception { @Test public void test100JackAssignRoleStatistics() throws Exception { - final String TEST_NAME = "test100JackAssignRoleStatistics"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -218,7 +207,6 @@ public void test100JackAssignRoleStatistics() throws Exception { @Test public void test101UnassignRoleStats() throws Exception{ - final String TEST_NAME = "test101UnassignRoleStats"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -269,7 +257,6 @@ public void test101UnassignRoleStats() throws Exception{ @Test public void test102AssignRoleStats() throws Exception{ - final String TEST_NAME = "test102AssignRoleStats"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -316,7 +303,6 @@ public void test102AssignRoleStats() throws Exception{ @Test public void test200DelteUserJack() throws Exception { - final String TEST_NAME = "test200DelteUserJack"; Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java index faadfa0a273..aa7f246ef52 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java @@ -7,17 +7,9 @@ package com.evolveum.midpoint.testing.story; import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; import java.io.File; -import com.evolveum.midpoint.prism.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -25,20 +17,22 @@ import com.evolveum.icf.dummy.resource.DummyAccount; import com.evolveum.icf.dummy.resource.DummySyncStyle; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.ReferenceDelta; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskExecutionStatus; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.MidPointTestConstants; +import com.evolveum.midpoint.tools.testng.UnusedTestElement; import com.evolveum.midpoint.xml.ns._public.common.common_3.ServiceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestServiceAccounts extends AbstractStoryTest { @@ -46,7 +40,6 @@ public class TestServiceAccounts extends AbstractStoryTest { protected static final File RESOURCE_DUMMY_FILE = new File(TEST_DIR, "resource-dummy.xml"); protected static final String RESOURCE_DUMMY_OID = "0069ac14-8377-11e8-b404-5b5a1a8af0db"; - private static final String RESOURCE_DUMMY_NS = MidPointConstants.NS_RI; protected static final String RESOURCE_DUMMY_INTENT_SERVICE = "service"; private static final String ACCOUNT_RUM_STORAGE_DUMMY_USERNAME = "rum-storage"; @@ -58,9 +51,7 @@ public class TestServiceAccounts extends AbstractStoryTest { private static final String SERVICE_BARELLIUM_DESCRIPTION = "Barellium Superiorum"; private static final File ACCOUNT_BARELLIUM_DUMMY_FILE = new File(TEST_DIR, "account-barellium-dummy.xml"); - private static final String ACCOUNT_BARELLIUM_DUMMY_OID = "fe0d6d9a-a77d-11e8-a144-0bbeb63fd26b"; private static final String ACCOUNT_BARELLIUM_DUMMY_USERNAME = "barellium"; - private static final String ACCOUNT_BARELLIUM_DUMMY_FULLNAME = "Barellium Magnum"; private static final String ACCOUNT_MAGAZINE_DUMMY_USERNAME = "magazine"; private static final String ACCOUNT_MAGAZINE_DUMMY_FULLNAME = "Gunpowder magazine"; @@ -83,8 +74,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100StartSyncTask() throws Exception { - final String TEST_NAME = "test100StartSyncTask"; - assertUsers(getNumberOfUsers()); assertServices(0); @@ -104,8 +93,6 @@ public void test100StartSyncTask() throws Exception { @Test public void test101AddServiceAccountSync() throws Exception { - final String TEST_NAME = "test101AddServiceAccountSync"; - // Preconditions assertServices(0); @@ -127,17 +114,17 @@ public void test101AddServiceAccountSync() throws Exception { assertServices(1); serviceAccountShadowOid = assertServiceAfterByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME) - .assertDescription(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME) - .links() + .assertDescription(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME) + .links() .single() - .resolveTarget() - .assertLife() - .assertKind(ShadowKindType.ACCOUNT) - .assertIntent(RESOURCE_DUMMY_INTENT_SERVICE) - .getOid(); + .resolveTarget() + .assertLife() + .assertKind(ShadowKindType.ACCOUNT) + .assertIntent(RESOURCE_DUMMY_INTENT_SERVICE) + .getOid(); assertDummyAccountByUsername(null, ACCOUNT_RUM_STORAGE_DUMMY_USERNAME) - .assertFullName(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); + .assertFullName(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); } /** @@ -147,8 +134,6 @@ public void test101AddServiceAccountSync() throws Exception { */ @Test public void test102ModifyServiceAccount() throws Exception { - final String TEST_NAME = "test102ModifyServiceAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -175,17 +160,17 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() assertServices(1); assertServiceAfterByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME) - .assertDescription(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME) - .links() + .assertDescription(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME) + .links() .single() - .resolveTarget() - .assertLife() - .assertKind(ShadowKindType.ACCOUNT) - .assertIntent(RESOURCE_DUMMY_INTENT_SERVICE) - .getOid(); + .resolveTarget() + .assertLife() + .assertKind(ShadowKindType.ACCOUNT) + .assertIntent(RESOURCE_DUMMY_INTENT_SERVICE) + .getOid(); assertDummyAccountByUsername(null, ACCOUNT_RUM_STORAGE_DUMMY_USERNAME) - .assertFullName(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); + .assertFullName(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); } /** @@ -195,8 +180,6 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() */ @Test public void test104DeleteServiceAccount() throws Exception { - final String TEST_NAME = "test104DeleteServiceAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -222,17 +205,17 @@ public void test104DeleteServiceAccount() throws Exception { assertServices(1); assertServiceAfterByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME) - .assertDescription(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME) - .links() + .assertDescription(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME) + .links() .single() - .resolveTarget() - .assertLife() - .assertKind(ShadowKindType.ACCOUNT) - .assertIntent(RESOURCE_DUMMY_INTENT_SERVICE) - .getOid(); + .resolveTarget() + .assertLife() + .assertKind(ShadowKindType.ACCOUNT) + .assertIntent(RESOURCE_DUMMY_INTENT_SERVICE) + .getOid(); assertDummyAccountByUsername(null, ACCOUNT_RUM_STORAGE_DUMMY_USERNAME) - .assertFullName(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); + .assertFullName(ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); } // TODO: account modifications, check that the changes are synced to service @@ -242,8 +225,6 @@ public void test104DeleteServiceAccount() throws Exception { */ @Test public void test108DeleteServiceAccountSync() throws Exception { - final String TEST_NAME = "test108DeleteServiceAccountSync"; - // Preconditions assertServices(1); @@ -263,8 +244,6 @@ public void test108DeleteServiceAccountSync() throws Exception { @Test public void test109StopLivesyncTask() throws Exception { - final String TEST_NAME = "test109StopLivesyncTask"; - // Preconditions assertServices(0); @@ -280,8 +259,6 @@ public void test109StopLivesyncTask() throws Exception { @Test public void test120StartReconTask() throws Exception { - final String TEST_NAME = "test120StartReconTask"; - assertUsers(getNumberOfUsers()); assertServices(0); @@ -301,8 +278,6 @@ public void test120StartReconTask() throws Exception { @Test public void test121AddServiceAccountRecon() throws Exception { - final String TEST_NAME = "test121AddServiceAccountRecon"; - // Preconditions assertServices(0); @@ -324,7 +299,7 @@ public void test121AddServiceAccountRecon() throws Exception { assertServices(1); assertServiceAfterByName(ACCOUNT_MAGAZINE_DUMMY_USERNAME) - .assertDescription(ACCOUNT_MAGAZINE_DUMMY_FULLNAME); + .assertDescription(ACCOUNT_MAGAZINE_DUMMY_FULLNAME); } /** @@ -332,8 +307,6 @@ public void test121AddServiceAccountRecon() throws Exception { */ @Test public void test128DeleteServiceAccountRecon() throws Exception { - final String TEST_NAME = "test128DeleteServiceAccountRecon"; - // Preconditions assertServices(1); @@ -351,9 +324,8 @@ public void test128DeleteServiceAccountRecon() throws Exception { assertServices(0); } + @UnusedTestElement public void test129StopReconTask() throws Exception { - final String TEST_NAME = "test129StopReconTask"; - // Preconditions assertServices(1); @@ -364,6 +336,7 @@ public void test129StopReconTask() throws Exception { // THEN then(); + assertTaskExecutionStatus(TASK_RECONCILE_DUMMY_OID, TaskExecutionStatus.SUSPENDED); } @@ -374,8 +347,6 @@ public void test129StopReconTask() throws Exception { */ @Test public void test140CreateServiceAccount() throws Exception { - final String TEST_NAME = "test140CreateServiceAccount"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -410,9 +381,9 @@ public void test140CreateServiceAccount() throws Exception { assertServices(1); assertServiceAfter(SERVICE_BARELLIUM_OID) - .assertName(SERVICE_BARELLIUM_NAME) - .assertDescription(SERVICE_BARELLIUM_DESCRIPTION) - .assertLinks(0); + .assertName(SERVICE_BARELLIUM_NAME) + .assertDescription(SERVICE_BARELLIUM_DESCRIPTION) + .assertLinks(0); assertNoDummyAccount(ACCOUNT_BARELLIUM_DUMMY_USERNAME); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java index cfbea40d5c6..de3cf868dcd 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java @@ -10,10 +10,8 @@ import static org.testng.AssertJUnit.assertNotNull; import java.io.File; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -22,8 +20,8 @@ import com.evolveum.icf.dummy.resource.DummyAccount; import com.evolveum.icf.dummy.resource.DummySyncStyle; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.asserter.ShadowAsserter; @@ -32,7 +30,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestServiceAccountsClassifier extends AbstractStoryTest { @@ -40,7 +38,6 @@ public class TestServiceAccountsClassifier extends AbstractStoryTest { protected static final File RESOURCE_DUMMY_CLASSIFIER_FILE = new File(TEST_DIR, "resource-dummy-classifier.xml"); protected static final String RESOURCE_DUMMY_CLASSIFIER_OID = "1169ac14-8377-11e8-b404-5b5a1a8af0db"; - private static final String RESOURCE_DUMMY_CLASSIFIER_NS = MidPointConstants.NS_RI; private static final File ROLE_EMPLOYEE_FILE = new File(TEST_DIR, "role-employee.xml"); private static final String ROLE_EMPLOYEE_OID = "23d90f70-1924-419e-9beb-78a8bde6d261"; @@ -77,9 +74,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti } @Test - public void test001assigneJackEmployeeRole() throws Exception { - final String TEST_NAME = "test001assigneJackEmployeeRole"; - + public void test001assignJackEmployeeRole() throws Exception { //WHEN when(); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_OID); @@ -93,8 +88,6 @@ public void test001assigneJackEmployeeRole() throws Exception { @Test public void test100createServiceJira() throws Exception { - final String TEST_NAME = "test100createServiceJira"; - //WHEN addObject(SERVICE_JIRA_FILE); @@ -109,7 +102,6 @@ public void test100createServiceJira() throws Exception { @Test public void test101jiraAssignResourceNoneEnforcement() throws Exception { - final String TEST_NAME = "test101jiraAssignResourceNoneEnforcement"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -131,8 +123,6 @@ public void test101jiraAssignResourceNoneEnforcement() throws Exception { @Test public void test150StartReconTask() throws Exception { - final String TEST_NAME = "test150StartReconTask"; - assertUsers(getNumberOfUsers()); assertServices(1); @@ -152,8 +142,6 @@ public void test150StartReconTask() throws Exception { @Test public void test151LinkServiceAccountRecon() throws Exception { - final String TEST_NAME = "test151LinkServiceAccountRecon"; - // Preconditions assertServices(1); @@ -171,18 +159,17 @@ public void test151LinkServiceAccountRecon() throws Exception { then(); assertServices(1); - PrismObject serviceJirafter = getObject(ServiceType.class, SERVICE_JIRA_OID); - display("Service magazine after", serviceJirafter); - assertNotNull("No magazine service", serviceJirafter); - PrismAsserts.assertPropertyValue(serviceJirafter, ItemPath.create(ServiceType.F_EXTENSION, F_ACCOUNT_NAME), ACCOUNT_DUMMY_JIRA_USERNAME); - assertLinks(serviceJirafter, 1); + PrismObject serviceJiraAfter = getObject(ServiceType.class, SERVICE_JIRA_OID); + display("Service magazine after", serviceJiraAfter); + assertNotNull("No magazine service", serviceJiraAfter); + PrismAsserts.assertPropertyValue(serviceJiraAfter, + ItemPath.create(ServiceType.F_EXTENSION, F_ACCOUNT_NAME), ACCOUNT_DUMMY_JIRA_USERNAME); + assertLinks(serviceJiraAfter, 1); } @Test public void test152InactivateUnmatchedAccountRecon() throws Exception { - final String TEST_NAME = "test152InactivateUnmatchedAccountRecon"; - // Preconditions assertServices(1); @@ -207,8 +194,6 @@ public void test152InactivateUnmatchedAccountRecon() throws Exception { @Test public void test200createServiceGithub() throws Exception { - final String TEST_NAME = "test200createServiceGithub"; - //WHEN addObject(SERVICE_GITHUB_FILE); @@ -223,8 +208,6 @@ public void test200createServiceGithub() throws Exception { @Test public void test210createAccountGithub() throws Exception { - final String TEST_NAME = "test210createAccountGithub"; - //WHEN when(); addObject(SHADOW_GITHUB_FILE); @@ -242,7 +225,6 @@ public void test210createAccountGithub() throws Exception { @Test public void test215githubAssignResourceNoneEnforcement() throws Exception { - final String TEST_NAME = "test101jiraAssignResourceNoneEnforcement"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -264,7 +246,6 @@ public void test215githubAssignResourceNoneEnforcement() throws Exception { @Test public void test220linkAccountGithubAndFixIntent() throws Exception { - final String TEST_NAME = "test220linkAccountGithubAndFixIntent"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -296,6 +277,4 @@ public void test220linkAccountGithubAndFixIntent() throws Exception { ShadowAsserter.forShadow(shadowGithub).assertIntent("service"); } - - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java index c4d16a6485b..a105b9b609b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java @@ -27,12 +27,14 @@ import com.evolveum.midpoint.test.DummyAuditService; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.MidPointTestConstants; +import com.evolveum.midpoint.tools.testng.UnusedTestElement; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationStatsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; /** * Tests creation and deletion of shadows. */ +@UnusedTestElement("Not in suite, test210 fails") @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestShadowsPerformance extends AbstractStoryTest { @@ -97,8 +99,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010Sanity() throws Exception { - final String TEST_NAME = "test010Sanity"; - Task task = getTestTask(); // WHEN @@ -113,8 +113,6 @@ public void test010Sanity() throws Exception { @Test public void test100ImportAccounts() throws Exception { - final String TEST_NAME = "test100ImportAccounts"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -135,7 +133,7 @@ public void test100ImportAccounts() throws Exception { display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); OperationStatsType statistics = getTaskTreeOperationStatistics(TASK_IMPORT_OID); - displayOperationStatistics("Task operation statistics for " + TEST_NAME, statistics); + displayOperationStatistics(statistics); assertNotNull(statistics); int shadows = repositoryService.countObjects(ShadowType.class, null, null, result); @@ -144,8 +142,6 @@ public void test100ImportAccounts() throws Exception { @Test(enabled = false) public void test200DeleteAccountsAndReconcile() throws Exception { - final String TEST_NAME = "test200DeleteAccountsAndReconcile"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -165,7 +161,7 @@ public void test200DeleteAccountsAndReconcile() throws Exception { display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); OperationStatsType statistics = getTaskTreeOperationStatistics(TASK_RECONCILIATION_OID); - displayOperationStatistics("Task operation statistics for " + TEST_NAME, statistics); + displayOperationStatistics(statistics); assertNotNull(statistics); int shadows = repositoryService.countObjects(ShadowType.class, null, null, result); @@ -174,8 +170,6 @@ public void test200DeleteAccountsAndReconcile() throws Exception { @Test public void test210DeleteShadows() throws Exception { - final String TEST_NAME = "test210DeleteShadows"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -195,7 +189,7 @@ public void test210DeleteShadows() throws Exception { display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); OperationStatsType statistics = getTaskTreeOperationStatistics(TASK_BULK_DELETE_OID); - displayOperationStatistics("Task operation statistics for " + TEST_NAME, statistics); + displayOperationStatistics(statistics); assertNotNull(statistics); int shadows = repositoryService.countObjects(ShadowType.class, null, null, result); @@ -204,11 +198,6 @@ public void test210DeleteShadows() throws Exception { @Test public void test900Summarize() { - final String TEST_NAME = "test900Summarize"; - - Task task = getTestTask(); - OperationResult result = task.getResult(); - StringBuilder sb = new StringBuilder(); for (Map.Entry entry : durations.entrySet()) { sb.append(summary(entry.getKey(), entry.getValue())); @@ -222,6 +211,7 @@ public void test900Summarize() { } + // TODO use it or let it go :-) private long recordDuration(String label, long duration) { durations.put(label, duration); return duration; @@ -230,5 +220,4 @@ private long recordDuration(String label, long duration) { private Object summary(String label, long duration) { return String.format(SUMMARY_LINE_FORMAT, label, duration, duration / NUMBER_OF_GENERATED_USERS); } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java index c96f660fc57..955708958b4 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java @@ -51,16 +51,9 @@ import com.evolveum.midpoint.schema.util.ApprovalContextUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.wf.util.ApprovalUtils; -/** - * - * @author mederly - * - */ - @SuppressWarnings("FieldCanBeLocal") @ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @@ -129,11 +122,8 @@ public class TestStrings extends AbstractStoryTest { private static final File CONFIG_WITH_GLOBAL_RULES_FILE = new File(ROLES_DIR, "global-policy-rules.xml"); - public static final String NS_STRINGS_EXT = "http://midpoint.evolveum.com/xml/ns/strings"; - private static final String DUMMY_WORK_ITEM_LIFECYCLE = "dummy:workItemLifecycle"; private static final String DUMMY_WORK_ITEM_ALLOCATION = "dummy:workItemAllocation"; - private static final String DUMMY_WORK_ITEM_CUSTOM = "dummy:workItemCustom"; private static final String DUMMY_PROCESS = "dummy:process"; protected static final int CASE_WAIT_TIMEOUT = 40000; @@ -196,16 +186,12 @@ protected PrismObject getDefaultActor() { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = getTestTask(); - // TODO } //region Basic approval @Test public void test100SimpleAssignmentStart() throws Exception { - final String TEST_NAME = "test100SimpleAssignmentStart"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -270,7 +256,6 @@ public void test100SimpleAssignmentStart() throws Exception { @Test public void test102SimpleAssignmentApproveByLechuck() throws Exception { - final String TEST_NAME = "test102SimpleAssignmentApproveByLechuck"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -351,14 +336,13 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { // events List events = assertEvents(aCase, 2); - assertCompletionEvent(events.get(1), userLechuckOid, userLechuckOid, 1, "Line managers", WorkItemOutcomeType.APPROVE, "OK. LeChuck"); + assertCompletionEvent(events.get(1), userLechuckOid, userLechuckOid, 1, WorkItemOutcomeType.APPROVE, "OK. LeChuck"); display("audit", dummyAuditService); } @Test public void test104SimpleAssignmentApproveByAdministrator() throws Exception { - final String TEST_NAME = "test104SimpleAssignmentApproveByAdministrator"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -438,7 +422,6 @@ public void test104SimpleAssignmentApproveByAdministrator() throws Exception { @Test public void test106SimpleAssignmentApproveByCheese() throws Exception { - final String TEST_NAME = "test106SimpleAssignmentApproveByCheese"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -496,7 +479,6 @@ public void test106SimpleAssignmentApproveByCheese() throws Exception { @Test public void test108SimpleAssignmentApproveByChef() throws Exception { - final String TEST_NAME = "test108SimpleAssignmentApproveByChef"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -573,7 +555,6 @@ public void test108SimpleAssignmentApproveByChef() throws Exception { //region Testing escalation @Test public void test200EscalatedApprovalStart() throws Exception { - final String TEST_NAME = "test200EscalatedApprovalStart"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -620,10 +601,6 @@ public void test200EscalatedApprovalStart() throws Exception { @Test public void test202FourDaysLater() throws Exception { - final String TEST_NAME = "test202FourDaysLater"; - Task task = getTestTask(); - OperationResult result = task.getResult(); - dummyAuditService.clear(); dummyTransport.clearMessages(); @@ -652,7 +629,6 @@ public void test202FourDaysLater() throws Exception { // escalation should occur here @Test public void test204SixDaysLater() throws Exception { - final String TEST_NAME = "test204SixDaysLater"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -689,7 +665,7 @@ public void test204SixDaysLater() throws Exception { assertEquals("Wrong escalation level name", "Line manager escalation", ApprovalContextUtil.getEscalationLevelName(workItem)); List events = assertEvents(aCase, 2); - assertEscalationEvent(events.get(1), userAdministrator.getOid(), userGuybrushOid, 1, "Line managers", + assertEscalationEvent(events.get(1), userAdministrator.getOid(), userGuybrushOid, 1, Collections.singletonList(userGuybrushOid), Collections.singletonList(userCheeseOid), WorkItemDelegationMethodType.ADD_ASSIGNEES, 1, "Line manager escalation"); @@ -719,10 +695,6 @@ public void test204SixDaysLater() throws Exception { @Test public void test205EightDaysLater() throws Exception { - final String TEST_NAME = "test205EightDaysLater"; - Task task = getTestTask(); - OperationResult result = task.getResult(); - dummyAuditService.clear(); dummyTransport.clearMessages(); @@ -770,7 +742,6 @@ public void test205EightDaysLater() throws Exception { @Test public void test206ApproveByCheese() throws Exception { - final String TEST_NAME = "test206ApproveByCheese"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -863,7 +834,6 @@ public void test206ApproveByCheese() throws Exception { // notification should be send @Test public void test208SixDaysLater() throws Exception { - final String TEST_NAME = "test208SixDaysLater"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -904,10 +874,6 @@ public void test208SixDaysLater() throws Exception { @Test public void test209EightDaysLater() throws Exception { - final String TEST_NAME = "test209EightDaysLater"; - Task task = getTestTask(); - OperationResult result = task.getResult(); - dummyAuditService.clear(); dummyTransport.clearMessages(); @@ -947,7 +913,6 @@ private void checkTwoCompleted(List lifecycleMessages) { assertMessage(sorted.get("barkeeper@evolveum.com"), "barkeeper@evolveum.com", null, "Security (2/3)", "Allocated to: Horridly Scarred Barkeep (barkeeper)"); - int completed; assertMessage(lifecycleMessages.get(0), null, "Work item has been completed", "^Carried out by:", "Reason: Timed action", @@ -960,7 +925,6 @@ private void checkTwoCompleted(List lifecycleMessages) { @Test public void test220FormRoleAssignmentStart() throws Exception { - final String TEST_NAME = "test220FormRoleAssignmentStart"; PrismObject bob = getUserFromRepo(userBobOid); login(bob); @@ -1004,7 +968,6 @@ public void test220FormRoleAssignmentStart() throws Exception { @Test public void test221FormApproveByLechuck() throws Exception { - final String TEST_NAME = "test221FormApproveByLechuck"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1049,7 +1012,6 @@ public void test221FormApproveByLechuck() throws Exception { @Test public void test222FormApproveByCheese() throws Exception { - final String TEST_NAME = "test222FormApproveByCheese"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1119,7 +1081,6 @@ public void test222FormApproveByCheese() throws Exception { @Test public void test250ApproverAssignment() throws Exception { - final String TEST_NAME = "test250ApproverAssignment"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1204,11 +1165,6 @@ private Map sortByRecipientsSingle(Collection messages return rv; } - private Task getParentTask(PrismObject task, OperationResult result) - throws SchemaException, ObjectNotFoundException { - return taskManager.getTaskByIdentifier(task.asObjectable().getParent(), result); - } - private void assertTriggers(CaseType aCase, int count) { assertEquals("Wrong # of triggers", count, aCase.getTrigger().size()); } @@ -1241,13 +1197,13 @@ private List assertEvents(CaseType aCase, int expectedCount) { } private void assertEscalationEvent(CaseEventType wfProcessEventType, String initiator, String originalAssignee, - int stageNumber, String stageName, List assigneesBefore, List delegatedTo, + int stageNumber, List assigneesBefore, List delegatedTo, WorkItemDelegationMethodType methodType, int newEscalationLevelNumber, String newEscalationLevelName) throws SchemaException { if (!(wfProcessEventType instanceof WorkItemEscalationEventType)) { fail("Wrong event class: expected: " + WorkItemEscalationEventType.class + ", real: " + wfProcessEventType.getClass()); } WorkItemEscalationEventType event = (WorkItemEscalationEventType) wfProcessEventType; - assertEvent(event, initiator, originalAssignee, stageNumber, stageName); + assertEvent(event, initiator, originalAssignee, stageNumber); PrismAsserts.assertReferenceValues(ref(event.getAssigneeBefore()), assigneesBefore.toArray(new String[0])); PrismAsserts.assertReferenceValues(ref(event.getDelegatedTo()), delegatedTo.toArray(new String[0])); assertEquals("Wrong delegation method", methodType, event.getDelegationMethod()); @@ -1256,18 +1212,18 @@ private void assertEscalationEvent(CaseEventType wfProcessEventType, String init } private void assertCompletionEvent(CaseEventType wfProcessEventType, String initiator, String originalAssignee, - int stageNumber, String stageName, WorkItemOutcomeType outcome, String comment) throws SchemaException { + int stageNumber, WorkItemOutcomeType outcome, String comment) throws SchemaException { if (!(wfProcessEventType instanceof WorkItemCompletionEventType)) { fail("Wrong event class: expected: " + WorkItemCompletionEventType.class + ", real: " + wfProcessEventType.getClass()); } WorkItemCompletionEventType event = (WorkItemCompletionEventType) wfProcessEventType; - assertEvent(event, initiator, originalAssignee, stageNumber, stageName); + assertEvent(event, initiator, originalAssignee, stageNumber); assertEquals("Wrong outcome", outcome, ApprovalUtils.fromUri(event.getOutput().getOutcome())); assertEquals("Wrong comment", comment, event.getOutput().getComment()); } - private void assertEvent(CaseEventType processEvent, String initiator, String originalAssignee, Integer stageNumber, - String stageName) throws SchemaException { + private void assertEvent(CaseEventType processEvent, + String initiator, String originalAssignee, Integer stageNumber) throws SchemaException { if (!(processEvent instanceof WorkItemEventType)) { fail("Wrong event class: expected: " + WorkItemEventType.class + ", real: " + processEvent.getClass()); } @@ -1280,5 +1236,4 @@ private void assertEvent(CaseEventType processEvent, String initiator, String or PrismAsserts.assertReferenceValue(ref(event.getOriginalAssigneeRef()), originalAssignee); } } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java index 1b7f34b5261..578e5a7c241 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java @@ -7,6 +7,19 @@ package com.evolveum.midpoint.testing.story; +import static org.testng.AssertJUnit.assertNotNull; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.opends.server.types.DirectoryException; +import org.opends.server.types.Entry; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; import com.evolveum.icf.dummy.resource.DummyObjectClass; import com.evolveum.icf.dummy.resource.DummyPrivilege; @@ -20,40 +33,20 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import org.opends.server.types.DirectoryException; -import org.opends.server.types.Entry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import javax.xml.namespace.QName; - -import java.io.File; - -import static org.testng.AssertJUnit.assertNotNull; - /** * @author Radovan Semancik * @author mederly - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestUniversity extends AbstractStoryTest { @@ -69,7 +62,6 @@ public class TestUniversity extends AbstractStoryTest { protected static final File RESOURCE_OPENDJ_FILE = new File(TEST_DIR, "resource-opendj.xml"); protected static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; protected static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; - protected static final QName OPENDJ_ASSOCIATION_GROUP_NAME = new QName(RESOURCE_OPENDJ_NAMESPACE, "group"); private static final String DUMMY_PRIVILEGE_ATTRIBUTE_HR_ORGPATH = "orgpath"; @@ -82,21 +74,9 @@ public class TestUniversity extends AbstractStoryTest { protected static final File TASK_LIVE_SYNC_DUMMY_HR_FILE = new File(TEST_DIR, "task-dummy-hr-livesync.xml"); protected static final String TASK_LIVE_SYNC_DUMMY_HR_OID = "10000000-0000-0000-5555-555500000001"; - protected static final File TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE = new File(TEST_DIR, "task-reconcile-opendj-default-single.xml"); - protected static final String TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID = "10000000-0000-0000-5555-555500000004"; - - protected static final File TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_FILE = new File(TEST_DIR, "task-reconcile-opendj-ldapgroup-single.xml"); - protected static final String TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID = "10000000-0000-0000-5555-555500000014"; - - private static final File SCABB_OU_LDIF_FILE = new File(TEST_DIR, "scabb.ldif"); - private static final File BOOTY_OU_LDIF_FILE = new File(TEST_DIR, "booty.ldif"); - private static final File BOOTY_LOOKOUT_OU_LDIF_FILE = new File(TEST_DIR, "booty-lookout.ldif"); - @Autowired private ReconciliationTaskHandler reconciliationTaskHandler; - private DebugReconciliationTaskResultListener reconciliationTaskResultListener; - protected static DummyResource dummyResourceHr; protected static DummyResourceContoller dummyResourceCtlHr; protected ResourceType resourceDummyHrType; @@ -124,7 +104,7 @@ public static void stopResources() { public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - reconciliationTaskResultListener = new DebugReconciliationTaskResultListener(); + DebugReconciliationTaskResultListener reconciliationTaskResultListener = new DebugReconciliationTaskResultListener(); reconciliationTaskHandler.setReconciliationTaskResultListener(reconciliationTaskResultListener); // Resources @@ -141,11 +121,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti resourceOpenDjType = resourceOpenDj.asObjectable(); openDJController.setResource(resourceOpenDj); -// // LDAP content -// openDJController.addEntryFromLdifFile(SCABB_OU_LDIF_FILE); -// openDJController.addEntryFromLdifFile(BOOTY_OU_LDIF_FILE); -// openDJController.addEntryFromLdifFile(BOOTY_LOOKOUT_OU_LDIF_FILE); -// // Object Templates importObjectFromFile(OBJECT_TEMPLATE_ORG_FILE, initResult); setDefaultObjectTemplate(OrgType.COMPLEX_TYPE, OBJECT_TEMPLATE_ORG_OID); @@ -162,8 +137,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); TestUtil.assertSuccess(testResultHr); @@ -178,8 +152,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddComeniusUniversity() throws Exception { - final String TEST_NAME = "test100AddComeniusUniversity"; - DummyPrivilege comenius = new DummyPrivilege("UK"); // WHEN @@ -201,8 +173,6 @@ public void test100AddComeniusUniversity() throws Exception { @Test public void test110AddComeniusStructure() throws Exception { - final String TEST_NAME = "test110AddComeniusStructure"; - DummyPrivilege srcFmfi = new DummyPrivilege("FMFI"); srcFmfi.addAttributeValue(DUMMY_PRIVILEGE_ATTRIBUTE_HR_ORGPATH, "UK"); @@ -271,11 +241,8 @@ private void assertNoGroupMembers(PrismObject org) throws Exception { assertNoAttribute(groupShadow.asObjectable(), new QName(MidPointConstants.NS_RI, "uniqueMember")); } - @Test public void test120MoveComputingCentre() throws Exception { - final String TEST_NAME = "test120MoveComputingCentre"; - DummyPrivilege srcVc = dummyResourceHr.getPrivilegeByName("VC"); // WHEN @@ -335,18 +302,18 @@ private PrismObject getAndAssertFunctionalOrg(String orgName) throws Sc String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, "org-group"); PrismObject groupShadow = getShadowModel(groupOid); - display("Org "+orgName+" group shadow", groupShadow); + display("Org " + orgName + " group shadow", groupShadow); // TODO assert shadow content - Entry ouEntry = openDJController.searchSingle("ou="+orgName); - assertNotNull("No ou LDAP entry for "+orgName, ouEntry); + Entry ouEntry = openDJController.searchSingle("ou=" + orgName); + assertNotNull("No ou LDAP entry for " + orgName, ouEntry); display("OU entry", ouEntry); - openDJController.assertObjectClass(ouEntry, "organizationalUnit"); + OpenDJController.assertObjectClass(ouEntry, "organizationalUnit"); - Entry groupEntry = openDJController.searchSingle("cn=DL-"+orgName); - assertNotNull("No group LDAP entry for "+orgName, groupEntry); + Entry groupEntry = openDJController.searchSingle("cn=DL-" + orgName); + assertNotNull("No group LDAP entry for " + orgName, groupEntry); display("OU GROUP entry", groupEntry); - openDJController.assertObjectClass(groupEntry, "groupOfUniqueNames"); + OpenDJController.assertObjectClass(groupEntry, "groupOfUniqueNames"); return org; } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java index 142f64003b6..1c6c00f45c9 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java @@ -6,15 +6,10 @@ */ package com.evolveum.midpoint.testing.story; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; @@ -55,31 +50,20 @@ import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationPhaseType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestUnix extends AbstractStoryTest { @@ -170,46 +154,14 @@ public class TestUnix extends AbstractStoryTest { public static final String SEQUENCE_UIDNUMBER_OID = "7d4acb8c-65e3-11e5-9ef4-6382ba96fe6c"; public static final File SEQUENCE_GIDNUMBER_FILE = new File(TEST_DIR, "sequence-gidnumber.xml"); - public static final String SEQUENCE_GIDNUMBER_OID = "02cb7caa-6618-11e5-87a5-7b6c6776a63e"; protected static final String USER_STAN_USERNAME = "stan"; protected static final String USER_STAN_FIST_NAME = "Stan"; protected static final String USER_STAN_LAST_NAME = "Salesman"; - private static final String ACCOUNT_LEMONHEAD_USERNAME = "lemonhead"; - private static final String ACCOUNT_LEMONHEAD_FIST_NAME = "Lemonhead"; - private static final String ACCOUNT_LEMONHEAD_LAST_NAME = "Canibal"; - - private static final String ACCOUNT_SHARPTOOTH_USERNAME = "sharptooth"; - private static final String ACCOUNT_SHARPTOOTH_FIST_NAME = "Sharptooth"; - private static final String ACCOUNT_SHARPTOOTH_LAST_NAME = "Canibal"; - - private static final String ACCOUNT_REDSKULL_USERNAME = "redskull"; - private static final String ACCOUNT_REDSKULL_FIST_NAME = "Redskull"; - private static final String ACCOUNT_REDSKULL_LAST_NAME = "Canibal"; - - private static final String ACCOUNT_GUYBRUSH_USERNAME = "guybrush"; - private static final String ACCOUNT_GUYBRUSH_FIST_NAME = "Guybrush"; - private static final String ACCOUNT_GUYBRUSH_LAST_NAME = "Threepwood"; - - private static final String ACCOUNT_COBB_USERNAME = "cobb"; - private static final String ACCOUNT_COBB_FIST_NAME = "Cobb"; - private static final String ACCOUNT_COBB_LAST_NAME = "Loom"; - - private static final String ACCOUNT_STAN_USERNAME = "stan"; - private static final String ACCOUNT_STAN_FIST_NAME = "Stan"; - private static final String ACCOUNT_STAN_LAST_NAME = "Salesman"; - - private static final String ACCOUNT_AUGUSTUS_USERNAME = "augustus"; - private static final String ACCOUNT_AUGUSTUS_FIST_NAME = "Augustus"; - private static final String ACCOUNT_AUGUSTUS_LAST_NAME = "DeWaat"; - - - @Autowired(required=true) + @Autowired private ReconciliationTaskHandler reconciliationTaskHandler; - private DebugReconciliationTaskResultListener reconciliationTaskResultListener; - protected ResourceType resourceOpenDjType; protected PrismObject resourceOpenDj; @@ -246,7 +198,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -254,7 +206,7 @@ public static void stopResources() throws Exception { public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - reconciliationTaskResultListener = new DebugReconciliationTaskResultListener(); + DebugReconciliationTaskResultListener reconciliationTaskResultListener = new DebugReconciliationTaskResultListener(); reconciliationTaskHandler.setReconciliationTaskResultListener(reconciliationTaskResultListener); // Resources @@ -293,7 +245,6 @@ protected String getResourceOid() { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(getResourceOid(), task); @@ -305,8 +256,6 @@ public void test000Sanity() throws Exception { @Test public void test010Schema() throws Exception { - final String TEST_NAME = "test010Schema"; - resourceOpenDj = getObject(ResourceType.class, getResourceOid()); resourceOpenDjType = resourceOpenDj.asObjectable(); @@ -316,29 +265,28 @@ public void test010Schema() throws Exception { display("OpenDJ schema (resource)", resourceSchema); ObjectClassComplexTypeDefinition ocDefPosixAccount = resourceSchema.findObjectClassDefinition(OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME); - assertNotNull("No objectclass "+OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME+" in resource schema", ocDefPosixAccount); - assertTrue("Objectclass "+OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME+" is not auxiliary", ocDefPosixAccount.isAuxiliary()); + assertNotNull("No objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", ocDefPosixAccount); + assertTrue("Objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", ocDefPosixAccount.isAuxiliary()); ObjectClassComplexTypeDefinition ocDefPosixGroup = resourceSchema.findObjectClassDefinition(OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME); - assertNotNull("No objectclass "+OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME+" in resource schema", ocDefPosixGroup); - assertTrue("Objectclass "+OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME+" is not auxiliary", ocDefPosixGroup.isAuxiliary()); + assertNotNull("No objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", ocDefPosixGroup); + assertTrue("Objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", ocDefPosixGroup.isAuxiliary()); RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resourceOpenDj); display("OpenDJ schema (refined)", refinedSchema); RefinedObjectClassDefinition rOcDefPosixAccount = refinedSchema.getRefinedDefinition(OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME); - assertNotNull("No refined objectclass "+OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME+" in resource schema", rOcDefPosixAccount); - assertTrue("Refined objectclass "+OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME+" is not auxiliary", rOcDefPosixAccount.isAuxiliary()); + assertNotNull("No refined objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", rOcDefPosixAccount); + assertTrue("Refined objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", rOcDefPosixAccount.isAuxiliary()); RefinedObjectClassDefinition rOcDefPosixGroup = refinedSchema.getRefinedDefinition(OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME); - assertNotNull("No refined objectclass "+OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME+" in resource schema", rOcDefPosixGroup); - assertTrue("Refined objectclass "+OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME+" is not auxiliary", rOcDefPosixGroup.isAuxiliary()); + assertNotNull("No refined objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", rOcDefPosixGroup); + assertTrue("Refined objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", rOcDefPosixGroup.isAuxiliary()); } @Test public void test100AddUserHermanBasic() throws Exception { - final String TEST_NAME = "test100AddUserHermanBasic"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -365,7 +313,6 @@ public void test100AddUserHermanBasic() throws Exception { @Test public void test110AddUserMancombUnix() throws Exception { - final String TEST_NAME = "test110AddUserMancombUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -392,7 +339,6 @@ public void test110AddUserMancombUnix() throws Exception { @Test public void test111AccountMancombEditObjectClassDefinition() throws Exception { - final String TEST_NAME = "test111AccountMancombEditObjectClassDefinition"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -421,7 +367,6 @@ public void test111AccountMancombEditObjectClassDefinition() throws Exception { @Test public void test119DeleteUserMancombUnix() throws Exception { - final String TEST_NAME = "test119DeleteUserMancombUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -446,11 +391,10 @@ public void test119DeleteUserMancombUnix() throws Exception { @Test public void test120AddUserLargo() throws Exception { - final String TEST_NAME = "test120AddUserLargo"; Task task = getTestTask(); OperationResult result = task.getResult(); - PrismObject user = createUser(USER_LARGO_USERNAME, USER_LARGO_FIST_NAME, USER_LARGO_LAST_NAME, (String)null); + PrismObject user = createUser(USER_LARGO_USERNAME, USER_LARGO_FIST_NAME, USER_LARGO_LAST_NAME, (String) null); // WHEN when(); @@ -469,7 +413,6 @@ public void test120AddUserLargo() throws Exception { @Test public void test122AssignUserLargoBasic() throws Exception { - final String TEST_NAME = "test122AssignUserLargoBasic"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -497,7 +440,6 @@ public void test122AssignUserLargoBasic() throws Exception { @Test public void test124AssignUserLargoUnix() throws Exception { - final String TEST_NAME = "test124AssignUserLargoUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -531,7 +473,6 @@ public void test124AssignUserLargoUnix() throws Exception { @Test public void test125RecomputeUserLargo() throws Exception { - final String TEST_NAME = "test125RecomputeUserLargo"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -559,7 +500,6 @@ public void test125RecomputeUserLargo() throws Exception { @Test public void test126UnAssignUserLargoUnix() throws Exception { - final String TEST_NAME = "test126UnAssignUserLargoUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -587,7 +527,6 @@ public void test126UnAssignUserLargoUnix() throws Exception { @Test public void test127RecomputeUserLargo() throws Exception { - final String TEST_NAME = "test127RecomputeUserLargo"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -615,7 +554,6 @@ public void test127RecomputeUserLargo() throws Exception { @Test public void test128UnAssignUserLargoBasic() throws Exception { - final String TEST_NAME = "test128UnAssignUserLargoBasic"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -642,7 +580,6 @@ public void test128UnAssignUserLargoBasic() throws Exception { @Test public void test129RecomputeUserLargo() throws Exception { - final String TEST_NAME = "test129RecomputeUserLargo"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -669,7 +606,6 @@ public void test129RecomputeUserLargo() throws Exception { @Test public void test130AssignUserLargoUnix() throws Exception { - final String TEST_NAME = "test130AssignUserLargoUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -697,7 +633,6 @@ public void test130AssignUserLargoUnix() throws Exception { @Test public void test131ReconcileUserLargo() throws Exception { - final String TEST_NAME = "test131ReconcileUserLargo"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -736,26 +671,25 @@ public void test131ReconcileUserLargo() throws Exception { */ @Test public void test132MeddleWithAccountAndReconcileUserLargo() throws Exception { - final String TEST_NAME = "test132MeddleWithAccountAndReconcileUserLargo"; Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); openDJController.executeLdifChange( - "dn: "+accountLargoDn+"\n"+ - "changetype: modify\n" + - "delete: objectClass\n" + - "objectClass: posixAccount\n" + - "-\n" + - "delete: homeDirectory\n" + - "homeDirectory: /home/largo\n" + - "-\n" + - "delete: uidNumber\n" + - "uidNumber: "+ USER_LARGO_UID_NUMBER +"\n" + - "-\n" + - "delete: gidNumber\n" + - "gidNumber: "+ USER_LARGO_UID_NUMBER +"\n" + "dn: " + accountLargoDn + "\n" + + "changetype: modify\n" + + "delete: objectClass\n" + + "objectClass: posixAccount\n" + + "-\n" + + "delete: homeDirectory\n" + + "homeDirectory: /home/largo\n" + + "-\n" + + "delete: uidNumber\n" + + "uidNumber: " + USER_LARGO_UID_NUMBER + "\n" + + "-\n" + + "delete: gidNumber\n" + + "gidNumber: " + USER_LARGO_UID_NUMBER + "\n" ); Entry entryBefore = openDJController.fetchEntry(accountLargoDn); @@ -803,7 +737,6 @@ protected void assertTest132Audit() { */ @Test public void test133ReconcileUserLargoAgain() throws Exception { - final String TEST_NAME = "test133ReconcileUserLargoAgain"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -841,7 +774,6 @@ public void test133ReconcileUserLargoAgain() throws Exception { @Test public void test134AssignUserLargoBasic() throws Exception { - final String TEST_NAME = "test134AssignUserLargoBasic"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -877,7 +809,6 @@ public void test134AssignUserLargoBasic() throws Exception { @Test public void test135UnAssignUserLargoUnix() throws Exception { - final String TEST_NAME = "test135UnAssignUserLargoUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -922,26 +853,25 @@ protected void assertTest135Audit() { */ @Test // MID-2883 public void test136MeddleWithAccountAndReconcileUserLargo() throws Exception { - final String TEST_NAME = "test136MeddleWithAccountAndReconcileUserLargo"; Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); openDJController.executeLdifChange( - "dn: "+accountLargoDn+"\n"+ - "changetype: modify\n" + - "add: objectClass\n" + - "objectClass: posixAccount\n" + - "-\n" + - "add: homeDirectory\n" + - "homeDirectory: /home/largo\n" + - "-\n" + - "add: uidNumber\n" + - "uidNumber: "+ USER_LARGO_UID_NUMBER +"\n" + - "-\n" + - "add: gidNumber\n" + - "gidNumber: "+ USER_LARGO_UID_NUMBER +"\n" + "dn: " + accountLargoDn + "\n" + + "changetype: modify\n" + + "add: objectClass\n" + + "objectClass: posixAccount\n" + + "-\n" + + "add: homeDirectory\n" + + "homeDirectory: /home/largo\n" + + "-\n" + + "add: uidNumber\n" + + "uidNumber: " + USER_LARGO_UID_NUMBER + "\n" + + "-\n" + + "add: gidNumber\n" + + "gidNumber: " + USER_LARGO_UID_NUMBER + "\n" ); Entry entryBefore = openDJController.fetchEntry(accountLargoDn); @@ -981,7 +911,6 @@ protected void assertAccountTest136(PrismObject shadow) throws Excep */ @Test public void test137ReconcileUserLargoAgain() throws Exception { - final String TEST_NAME = "test137ReconcileUserLargoAgain"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1027,7 +956,6 @@ protected void assertTest137Account(PrismObject shadow) throws Excep @Test public void test138UnAssignUserLargoBasic() throws Exception { - final String TEST_NAME = "test138UnAssignUserLargoUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1056,7 +984,6 @@ public void test138UnAssignUserLargoBasic() throws Exception { @Test public void test200AddLdapGroupMonkeyIsland() throws Exception { - final String TEST_NAME = "test200AddLdapGroupMonkeyIsland"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1084,7 +1011,6 @@ public void test200AddLdapGroupMonkeyIsland() throws Exception { @Test public void test202AssignUserHermanMonkeyIsland() throws Exception { - final String TEST_NAME = "test202AssignUserHermanMonkeyIsland"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1112,7 +1038,6 @@ public void test202AssignUserHermanMonkeyIsland() throws Exception { @Test public void test210AddUnixGroupVillains() throws Exception { - final String TEST_NAME = "test210AddUnixGroupVillains"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1140,7 +1065,6 @@ public void test210AddUnixGroupVillains() throws Exception { @Test public void test211AssignUserLargoUnix() throws Exception { - final String TEST_NAME = "test211AssignUserLargoUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1168,7 +1092,6 @@ public void test211AssignUserLargoUnix() throws Exception { @Test public void test212AssignUserLargoVillains() throws Exception { - final String TEST_NAME = "test212AssignUserLargoVillains"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1192,13 +1115,12 @@ public void test212AssignUserLargoVillains() throws Exception { display("Shadow (model)", shadow); String accountLArgoDn = assertPosixAccount(shadow, USER_LARGO_UID_NUMBER); Entry groupVillains = openDJController.fetchEntry(groupVillainsDn); - openDJController.assertAttribute(groupVillains, "memberUid", USER_LARGO_USERNAME); + OpenDJController.assertAttribute(groupVillains, "memberUid", USER_LARGO_USERNAME); //openDJController.assertAttribute(groupVillains, "memberUid", Integer.toString(USER_LARGO_UID_NUMBER)); } @Test public void test250AddUserRangerBasic() throws Exception { - final String TEST_NAME = "test250AddUserRangerBasic"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1225,7 +1147,6 @@ public void test250AddUserRangerBasic() throws Exception { @Test public void test251AssignUserRangerBasic() throws Exception { - final String TEST_NAME = "test251AssignUserRangerBasic"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1253,7 +1174,6 @@ public void test251AssignUserRangerBasic() throws Exception { @Test public void test252AddUnixGroupRangers() throws Exception { - final String TEST_NAME = "test252AddUnixGroupRangers"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1281,7 +1201,6 @@ public void test252AddUnixGroupRangers() throws Exception { @Test public void test253AddUnixGroupSeals() throws Exception { - final String TEST_NAME = "test253AddUnixGroupSeals"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1311,7 +1230,6 @@ public void test253AddUnixGroupSeals() throws Exception { @Test public void test254AssignUserRangerRangers() throws Exception { - final String TEST_NAME = "test254AssignUserRangerRangers"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1337,22 +1255,21 @@ public void test254AssignUserRangerRangers() throws Exception { String accountRangerDn = assertPosixAccount(shadow, USER_RANGER_UID_NUMBER); Entry groupRangers = openDJController.fetchEntry(groupRangersDn); //openDJController.assertAttribute(groupRangers, "memberUid", Integer.toString(USER_RANGER_UID_NUMBER)); - openDJController.assertAttribute(groupRangers, "memberUid", USER_RANGER_USERNAME); + OpenDJController.assertAttribute(groupRangers, "memberUid", USER_RANGER_USERNAME); assertGroupAssociation(shadow, groupRangersOid); PrismObject repoShadow = provisioningService.getObject(ShadowType.class, accountOid, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), task, result); display("Shadow (repo)", repoShadow); //PrismProperty uidNumberRepoAttr = repoShadow.findProperty(prismContext.path(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NAMESPACE, OPENDJ_UIDNUMBER_ATTRIBUTE_NAME))); - //PrismAsserts.assertPropertyValue(uidNumberRepoAttr, USER_RANGER_UID_NUMBER); + //PrismAsserts.assertPropertyValue(uidNumberRepoAttr, USER_RANGER_UID_NUMBER); PrismProperty uidRepoAttr = repoShadow.findProperty( ItemPath.create(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NAMESPACE, OPENDJ_UID_ATTRIBUTE_NAME))); - PrismAsserts.assertPropertyValue(uidRepoAttr, USER_RANGER_USERNAME); + PrismAsserts.assertPropertyValue(uidRepoAttr, USER_RANGER_USERNAME); } @Test public void test255AssignUserRangerSeals() throws Exception { - final String TEST_NAME = "test255AssignUserRangerSeals"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1377,7 +1294,7 @@ public void test255AssignUserRangerSeals() throws Exception { String accountLArgoDn = assertPosixAccount(shadow, USER_RANGER_UID_NUMBER); Entry groupSeals = openDJController.fetchEntry(groupSealsDn); //openDJController.assertAttribute(groupSeals, "memberUid", Integer.toString(USER_RANGER_UID_NUMBER)); - openDJController.assertAttribute(groupSeals, "memberUid", USER_RANGER_USERNAME); + OpenDJController.assertAttribute(groupSeals, "memberUid", USER_RANGER_USERNAME); assertGroupAssociation(shadow, groupRangersOid); assertGroupAssociation(shadow, groupSealsOid); @@ -1385,7 +1302,6 @@ public void test255AssignUserRangerSeals() throws Exception { @Test public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { - final String TEST_NAME = "test256UnAssignUserRangerSealsKeepRangers"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1413,17 +1329,16 @@ public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { // account should still be in the rangers group Entry groupRangers = openDJController.fetchEntry(groupRangersDn); //openDJController.assertAttribute(groupRangers, "memberUid", Integer.toString(USER_RANGER_UID_NUMBER)); - openDJController.assertAttribute(groupRangers, "memberUid", USER_RANGER_USERNAME); + OpenDJController.assertAttribute(groupRangers, "memberUid", USER_RANGER_USERNAME); // account should not be in the group anymore. memberUid should be // empty... Entry groupSeals = openDJController.fetchEntry(groupSealsDn); - openDJController.assertNoAttribute(groupSeals, "memberUid"); + OpenDJController.assertNoAttribute(groupSeals, "memberUid"); } @Test public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception { - final String TEST_NAME = "test257RenameUserAndAccountsCheckGroupmembership"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1455,14 +1370,12 @@ public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception Entry groupRangers = openDJController.fetchEntry(groupRangersDn); assertUnixGroup(shadowGroup, ROLE_RANGERS_GID); - openDJController.assertAttribute(groupRangers, "memberUid", USER_RANGER_USERNAME_RENAMED); + OpenDJController.assertAttribute(groupRangers, "memberUid", USER_RANGER_USERNAME_RENAMED); } - @Test public void test260DeleteUserUsrangerUnix() throws Exception { - final String TEST_NAME = "test260DeleteUserUsrangerUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1490,7 +1403,6 @@ public void test260DeleteUserUsrangerUnix() throws Exception { */ @Test public void test270RenameUnixGroupSeals() throws Exception { - final String TEST_NAME = "test270RenameUnixGroupSeals"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1512,13 +1424,11 @@ public void test270RenameUnixGroupSeals() throws Exception { display("Shadow (model)", shadow); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, groupSealsOid, null, result); display("Shadow (repo)", shadowRepo); - String newGroupSealsDn = assertUnixGroup(shadow, ROLE_SEALS_GID); - + assertUnixGroup(shadow, ROLE_SEALS_GID); } @Test public void test300AddUserCapsizeUnixFail() throws Exception { - final String TEST_NAME = "test300AddUserCapsizeUnixFail"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1562,7 +1472,6 @@ public void test300AddUserCapsizeUnixFail() throws Exception { */ @Test public void test310AddUserWallyUnix() throws Exception { - final String TEST_NAME = "test310AddUserWallyUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1602,23 +1511,22 @@ public void test310AddUserWallyUnix() throws Exception { */ @Test public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { - final String TEST_NAME = "test312AccountWallyRemovePosixObjectclassNative"; Task task = getTestTask(); OperationResult result = task.getResult(); - openDJController.executeLdifChange("dn: "+accountWallyDn+"\n"+ - "changetype: modify\n"+ - "delete: objectclass\n"+ - "objectclass: posixAccount\n"+ - "-\n"+ - "delete: uidNumber\n"+ - "uidNumber: "+USER_WALLY_UID_NUMBER+"\n"+ - "-\n"+ - "delete: gidNumber\n"+ - "gidNumber: "+USER_WALLY_UID_NUMBER+"\n"+ - "-\n"+ - "delete: homeDirectory\n"+ - "homeDirectory: /home/wally"); + openDJController.executeLdifChange("dn: " + accountWallyDn + "\n" + + "changetype: modify\n" + + "delete: objectclass\n" + + "objectclass: posixAccount\n" + + "-\n" + + "delete: uidNumber\n" + + "uidNumber: " + USER_WALLY_UID_NUMBER + "\n" + + "-\n" + + "delete: gidNumber\n" + + "gidNumber: " + USER_WALLY_UID_NUMBER + "\n" + + "-\n" + + "delete: homeDirectory\n" + + "homeDirectory: /home/wally"); Entry entryWallyBefore = openDJController.fetchEntry(accountWallyDn); display("Wally LDAP account before", entryWallyBefore); @@ -1652,23 +1560,22 @@ public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { */ @Test public void test314AccountWallyAddPosixObjectclassNative() throws Exception { - final String TEST_NAME = "test314AccountWallyAddPosixObjectclassNative"; Task task = getTestTask(); OperationResult result = task.getResult(); - openDJController.executeLdifChange("dn: "+accountWallyDn+"\n"+ - "changetype: modify\n"+ - "add: objectclass\n"+ - "objectclass: posixAccount\n"+ - "-\n"+ - "add: uidNumber\n"+ - "uidNumber: "+USER_WALLY_UID_NUMBER+"\n"+ - "-\n"+ - "add: gidNumber\n"+ - "gidNumber: "+USER_WALLY_UID_NUMBER+"\n"+ - "-\n"+ - "add: homeDirectory\n"+ - "homeDirectory: /home/wally"); + openDJController.executeLdifChange("dn: " + accountWallyDn + "\n" + + "changetype: modify\n" + + "add: objectclass\n" + + "objectclass: posixAccount\n" + + "-\n" + + "add: uidNumber\n" + + "uidNumber: " + USER_WALLY_UID_NUMBER + "\n" + + "-\n" + + "add: gidNumber\n" + + "gidNumber: " + USER_WALLY_UID_NUMBER + "\n" + + "-\n" + + "add: homeDirectory\n" + + "homeDirectory: /home/wally"); Entry entryWallyBefore = openDJController.fetchEntry(accountWallyDn); display("Wally LDAP account before", entryWallyBefore); @@ -1698,7 +1605,6 @@ public void test314AccountWallyAddPosixObjectclassNative() throws Exception { @Test public void test400ListAllAccountsObjectClass() throws Exception { - final String TEST_NAME = "test400ListAllAccountsObjectClass"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1720,7 +1626,6 @@ public void test400ListAllAccountsObjectClass() throws Exception { @Test public void test401ListAllAccountsKindIntent() throws Exception { - final String TEST_NAME = "test401ListAllAccountsKindIntent"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1743,7 +1648,6 @@ public void test401ListAllAccountsKindIntent() throws Exception { @Test public void test402ListLdapGroupsKindIntent() throws Exception { - final String TEST_NAME = "test402ListLdapGroupsKindIntent"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1766,7 +1670,6 @@ public void test402ListLdapGroupsKindIntent() throws Exception { @Test public void test403ListUnixGroupsKindIntent() throws Exception { - final String TEST_NAME = "test403ListUnixGroupsKindIntent"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1788,7 +1691,6 @@ public void test403ListUnixGroupsKindIntent() throws Exception { @Test public void test500AddUserStan() throws Exception { - final String TEST_NAME = "test500AddUserStan"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1821,7 +1723,6 @@ public void test500AddUserStan() throws Exception { @Test public void test510StanDisablePosixAssocAndReconcile() throws Exception { - final String TEST_NAME = "test510StanDisablePosixAssocAndReconcile"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1918,46 +1819,49 @@ protected void assertUserPosix(PrismObject user, String username, Stri assertUser(user, user.getOid(), username, firstName + " " + lastName, firstName, lastName); PrismContainer extension = user.getExtension(); - assertNotNull("No extension in "+user, extension); + assertNotNull("No extension in " + user, extension); PrismAsserts.assertPropertyValue(extension, EXTENSION_UID_NUMBER_NAME, Integer.toString(uidNumber)); } protected String assertBasicAccount(PrismObject shadow) throws DirectoryException { ShadowType shadowType = shadow.asObjectable(); - assertEquals("Wrong objectclass in "+shadow, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); - assertTrue("Unexpected auxiliary objectclasses in "+shadow + ": "+shadowType.getAuxiliaryObjectClass(), + assertEquals("Wrong objectclass in " + shadow, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); + assertTrue("Unexpected auxiliary objectclasses in " + shadow + ": " + shadowType.getAuxiliaryObjectClass(), shadowType.getAuxiliaryObjectClass().isEmpty()); + //noinspection ConstantConditions String dn = (String) ShadowUtil.getSecondaryIdentifiers(shadow).iterator().next().getRealValue(); Entry entry = openDJController.fetchEntry(dn); - assertNotNull("No ou LDAP entry for "+dn); + assertNotNull("No ou LDAP entry for " + dn, entry); display("Posix account entry", entry); - openDJController.assertObjectClass(entry, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); - openDJController.assertNoObjectClass(entry, OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertObjectClass(entry, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertNoObjectClass(entry, OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()); return entry.getDN().toString(); } protected String assertAccount(PrismObject shadow, QName... expectedAuxObjectClasses) throws DirectoryException { ShadowType shadowType = shadow.asObjectable(); - assertEquals("Wrong objectclass in "+shadow, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); - PrismAsserts.assertEqualsCollectionUnordered("Wrong auxiliary objectclasses in "+shadow, + assertEquals("Wrong objectclass in " + shadow, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); + PrismAsserts.assertEqualsCollectionUnordered("Wrong auxiliary objectclasses in " + shadow, shadowType.getAuxiliaryObjectClass(), expectedAuxObjectClasses); + //noinspection ConstantConditions String dn = (String) ShadowUtil.getSecondaryIdentifiers(shadow).iterator().next().getRealValue(); Entry entry = openDJController.fetchEntry(dn); - assertNotNull("No ou LDAP entry for "+dn); + assertNotNull("No ou LDAP entry for " + dn, entry); display("Posix account entry", entry); - openDJController.assertObjectClass(entry, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertObjectClass(entry, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); return entry.getDN().toString(); } protected String assertPosixAccount(PrismObject shadow, Integer expectedUid) throws DirectoryException { ShadowType shadowType = shadow.asObjectable(); - assertEquals("Wrong objectclass in "+shadow, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); - PrismAsserts.assertEqualsCollectionUnordered("Wrong auxiliary objectclasses in "+shadow, + assertEquals("Wrong objectclass in " + shadow, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); + PrismAsserts.assertEqualsCollectionUnordered("Wrong auxiliary objectclasses in " + shadow, shadowType.getAuxiliaryObjectClass(), OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME); + //noinspection ConstantConditions String dn = (String) ShadowUtil.getSecondaryIdentifiers(shadow).iterator().next().getRealValue(); if (expectedUid != null) { ResourceAttribute uidNumberAttr = ShadowUtil @@ -1969,13 +1873,13 @@ protected String assertPosixAccount(PrismObject shadow, Integer expe } Entry entry = openDJController.fetchEntry(dn); - assertNotNull("No ou LDAP entry for "+dn); + assertNotNull("No ou LDAP entry for " + dn, entry); display("Posix account entry", entry); - openDJController.assertObjectClass(entry, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); - openDJController.assertObjectClass(entry, OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertObjectClass(entry, OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertObjectClass(entry, OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()); if (expectedUid != null) { - openDJController.assertAttribute(entry, OPENDJ_UIDNUMBER_ATTRIBUTE_NAME, Integer.toString(expectedUid)); - openDJController.assertAttribute(entry, OPENDJ_GIDNUMBER_ATTRIBUTE_NAME, Integer.toString(expectedUid)); + OpenDJController.assertAttribute(entry, OPENDJ_UIDNUMBER_ATTRIBUTE_NAME, Integer.toString(expectedUid)); + OpenDJController.assertAttribute(entry, OPENDJ_GIDNUMBER_ATTRIBUTE_NAME, Integer.toString(expectedUid)); } return entry.getDN().toString(); @@ -1986,21 +1890,21 @@ protected ShadowAssociationType assertGroupAssociation(PrismObject a if (association != null) { return association; } - AssertJUnit.fail("No association for "+groupShadowOid+" in "+accountShadow); + AssertJUnit.fail("No association for " + groupShadowOid + " in " + accountShadow); return null; // NOT REACHED } protected void assertNoGroupAssociation(PrismObject accountShadow, String groupShadowOid) { ShadowAssociationType association = findAssociation(accountShadow, groupShadowOid); - assertNull("Unexpected association for "+groupShadowOid+" in "+accountShadow, association); + assertNull("Unexpected association for " + groupShadowOid + " in " + accountShadow, association); } @Nullable private ShadowAssociationType findAssociation(PrismObject accountShadow, String groupShadowOid) { ShadowType accountShadowType = accountShadow.asObjectable(); - for (ShadowAssociationType association: accountShadowType.getAssociation()) { - assertNotNull("Association without shadowRef in "+accountShadow+": "+association, association.getShadowRef()); - assertNotNull("Association without shadowRef OID in "+accountShadow+": "+association, association.getShadowRef().getOid()); + for (ShadowAssociationType association : accountShadowType.getAssociation()) { + assertNotNull("Association without shadowRef in " + accountShadow + ": " + association, association.getShadowRef()); + assertNotNull("Association without shadowRef OID in " + accountShadow + ": " + association, association.getShadowRef().getOid()); if (association.getShadowRef().getOid().equals(groupShadowOid)) { return association; } @@ -2038,42 +1942,44 @@ private PrismObject createUnixGroupRole(String name, String metaRoleOi private String assertLdapGroup(PrismObject shadow) throws DirectoryException { ShadowType shadowType = shadow.asObjectable(); - assertEquals("Wrong objectclass in "+shadow, OPENDJ_GROUP_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); - assertTrue("Unexpected auxiliary objectclasses in "+shadow + ": "+shadowType.getAuxiliaryObjectClass(), + assertEquals("Wrong objectclass in " + shadow, OPENDJ_GROUP_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); + assertTrue("Unexpected auxiliary objectclasses in " + shadow + ": " + shadowType.getAuxiliaryObjectClass(), shadowType.getAuxiliaryObjectClass().isEmpty()); + //noinspection ConstantConditions String dn = (String) ShadowUtil.getSecondaryIdentifiers(shadow).iterator().next().getRealValue(); Entry entry = openDJController.fetchEntry(dn); - assertNotNull("No group LDAP entry for "+dn); + assertNotNull("No group LDAP entry for " + dn, entry); display("Ldap group entry", entry); - openDJController.assertObjectClass(entry, OPENDJ_GROUP_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); - openDJController.assertNoObjectClass(entry, OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertObjectClass(entry, OPENDJ_GROUP_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertNoObjectClass(entry, OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()); return entry.getDN().toString(); } private String assertUnixGroup(PrismObject shadow, Integer expectedGidNumber) throws DirectoryException { ShadowType shadowType = shadow.asObjectable(); - assertEquals("Wrong objectclass in "+shadow, OPENDJ_GROUP_UNIX_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); - PrismAsserts.assertEqualsCollectionUnordered("Wrong auxiliary objectclasses in "+shadow, + assertEquals("Wrong objectclass in " + shadow, OPENDJ_GROUP_UNIX_STRUCTURAL_OBJECTCLASS_NAME, shadowType.getObjectClass()); + PrismAsserts.assertEqualsCollectionUnordered("Wrong auxiliary objectclasses in " + shadow, shadowType.getAuxiliaryObjectClass(), OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME); + //noinspection ConstantConditions String dn = (String) ShadowUtil.getSecondaryIdentifiers(shadow).iterator().next().getRealValue(); ResourceAttribute gidNumberAttr = ShadowUtil.getAttribute(shadow, new QName(RESOURCE_OPENDJ_NAMESPACE, OPENDJ_GIDNUMBER_ATTRIBUTE_NAME)); PrismAsserts.assertPropertyValue(gidNumberAttr, expectedGidNumber); Entry entry = openDJController.fetchEntry(dn); - assertNotNull("No group LDAP entry for "+dn); + assertNotNull("No group LDAP entry for " + dn, entry); display("Posix account entry", entry); - openDJController.assertObjectClass(entry, OPENDJ_GROUP_UNIX_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); - openDJController.assertObjectClass(entry, OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()); - openDJController.assertAttribute(entry, "gidNumber", expectedGidNumber.toString()); + OpenDJController.assertObjectClass(entry, OPENDJ_GROUP_UNIX_STRUCTURAL_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertObjectClass(entry, OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()); + OpenDJController.assertAttribute(entry, "gidNumber", expectedGidNumber.toString()); return entry.getDN().toString(); } protected void assertModifyTimestamp(PrismObject shadow, long startTs, long endTs) throws Exception { Long actual = getTimestampAttribute(shadow); - TestUtil.assertBetween("Wrong modify timestamp attribute in "+shadow, startTs-1000, endTs+1000, actual); + TestUtil.assertBetween("Wrong modify timestamp attribute in " + shadow, startTs - 1000, endTs + 1000, actual); } protected Long getTimestampAttribute(PrismObject shadow) throws Exception { diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java index 97170f9dcd2..db4e003d329 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java @@ -6,19 +6,12 @@ */ package com.evolveum.midpoint.testing.story; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.util.Arrays; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - import org.apache.directory.api.util.GeneralizedTime; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; @@ -35,15 +28,18 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.ldap.OpenDJController; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * Unix test with tolerant auxiliary object classes. - * + *

* Also this is using different timestamp format in LDAP connector configuration. * * @author Radovan Semancik */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestUnixTolerantAux extends TestUnix { @@ -111,7 +107,6 @@ protected void assertTest137Account(PrismObject shadow) throws Excep @Test public void test140AssignUserLargoBasic() throws Exception { - final String TEST_NAME = "test140AssignUserLargoBasic"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -144,20 +139,19 @@ public void test140AssignUserLargoBasic() throws Exception { */ @Test public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { - final String TEST_NAME = "test142MeddleWithAccountAndReconcileUserLargo"; Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); openDJController.executeLdifChange( - "dn: "+accountLargoDn+"\n"+ - "changetype: modify\n" + - "add: objectClass\n" + - "objectClass: "+OPENDJ_ACCOUNT_LABELED_URI_OBJECT_AUXILIARY_OBJECTCLASS_NAME.getLocalPart()+"\n" + - "-\n" + - "add: labeledURI\n" + - "labeledURI: "+ URI_WHATEVER + "\n" + "dn: " + accountLargoDn + "\n" + + "changetype: modify\n" + + "add: objectClass\n" + + "objectClass: " + OPENDJ_ACCOUNT_LABELED_URI_OBJECT_AUXILIARY_OBJECTCLASS_NAME.getLocalPart() + "\n" + + "-\n" + + "add: labeledURI\n" + + "labeledURI: " + URI_WHATEVER + "\n" ); Entry entryBefore = openDJController.fetchEntry(accountLargoDn); @@ -191,7 +185,6 @@ public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { @Test public void test144AssignUserLargoUnix() throws Exception { - final String TEST_NAME = "test144AssignUserLargoUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -221,7 +214,6 @@ public void test144AssignUserLargoUnix() throws Exception { @Test public void test146UnassignUserLargoUnix() throws Exception { - final String TEST_NAME = "test146UnassignUserLargoUnix"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -251,7 +243,6 @@ public void test146UnassignUserLargoUnix() throws Exception { @Test public void test149UnAssignUserLargoBasic() throws Exception { - final String TEST_NAME = "test149UnAssignUserLargoBasic"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -291,7 +282,7 @@ protected Long getTimestampAttribute(PrismObject shadow) throws Exce return null; } if (!attributeValue.endsWith("Z")) { - fail("Non-zulu timestamp: "+attributeValue); + fail("Non-zulu timestamp: " + attributeValue); } GeneralizedTime gt = new GeneralizedTime(attributeValue); return gt.getCalendar().getTimeInMillis(); @@ -303,12 +294,12 @@ private void assertUserAuxes(PrismObject userAfter, QName... expectedA } private void assertLabeledUri(PrismObject shadow, String expecteduri) throws DirectoryException { - ShadowType shadowType = shadow.asObjectable(); + //noinspection ConstantConditions String dn = (String) ShadowUtil.getSecondaryIdentifiers(shadow).iterator().next().getRealValue(); Entry entry = openDJController.fetchEntry(dn); - assertNotNull("No ou LDAP entry for "+dn); + assertNotNull("No ou LDAP entry for " + dn, entry); display("Posix account entry", entry); - openDJController.assertAttribute(entry, OPENDJ_LABELED_URI_ATTRIBUTE_NAME, expecteduri); + OpenDJController.assertAttribute(entry, OPENDJ_LABELED_URI_ATTRIBUTE_NAME, expecteduri); } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java index 9f3aecbf747..ea94d16471b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java @@ -6,6 +6,20 @@ * and European Union Public License. See LICENSE file for details. */ +import static org.testng.AssertJUnit.*; + +import java.io.File; +import java.util.List; +import javax.xml.namespace.QName; + +import org.opends.server.types.DirectoryException; +import org.opends.server.types.Entry; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + import com.evolveum.icf.dummy.resource.DummyAccount; import com.evolveum.icf.dummy.resource.DummyObjectClass; import com.evolveum.icf.dummy.resource.DummyResource; @@ -35,25 +49,11 @@ import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.opends.server.types.DirectoryException; -import org.opends.server.types.Entry; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import javax.xml.namespace.QName; -import java.io.File; -import java.util.List; - -import static org.testng.AssertJUnit.*; /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestVillage extends AbstractStoryTest { @@ -122,14 +122,14 @@ public class TestVillage extends AbstractStoryTest { private static final String ACCOUNT_HERMAN_LAST_NAME = "Toothrot"; private static final String ACCOUNT_HERMAN_LOC = "Monkey Island"; private static final String ACCOUNT_HERMAN_ORG = "Gov"; - private static final String USER_HERMAN_NAME = "G."+ACCOUNT_HERMAN_FIST_NAME+"."+ACCOUNT_HERMAN_LAST_NAME; + private static final String USER_HERMAN_NAME = "G." + ACCOUNT_HERMAN_FIST_NAME + "." + ACCOUNT_HERMAN_LAST_NAME; private static final String ACCOUNT_LEMONHEAD_USERNAME = "lemonhead"; private static final String ACCOUNT_LEMONHEAD_FIST_NAME = "Lemonhead"; private static final String ACCOUNT_LEMONHEAD_LAST_NAME = "Canibal"; private static final String ACCOUNT_LEMONHEAD_LOC = "Monkey Island"; private static final String ACCOUNT_LEMONHEAD_ORG = "Exec"; - private static final String USER_LEMONHEAD_NAME = "E."+ACCOUNT_LEMONHEAD_FIST_NAME+"."+ACCOUNT_LEMONHEAD_LAST_NAME; + private static final String USER_LEMONHEAD_NAME = "E." + ACCOUNT_LEMONHEAD_FIST_NAME + "." + ACCOUNT_LEMONHEAD_LAST_NAME; private static final String ACCOUNT_SHARPTOOTH_USERNAME = "sharptooth"; private static final String ACCOUNT_SHARPTOOTH_FIST_NAME = "Sharptooth"; @@ -144,7 +144,7 @@ public class TestVillage extends AbstractStoryTest { private static final String ACCOUNT_MANCOMB_LAST_NAME = "Seepgood"; private static final String ACCOUNT_MANCOMB_LOC = "-"; private static final String ACCOUNT_MANCOMB_ORG = "-"; - private static final String USER_MANCOMB_NAME = ACCOUNT_MANCOMB_FIST_NAME+"."+ACCOUNT_MANCOMB_LAST_NAME; + private static final String USER_MANCOMB_NAME = ACCOUNT_MANCOMB_FIST_NAME + "." + ACCOUNT_MANCOMB_LAST_NAME; private static final String ACCOUNT_COBB_USERNAME = "cobb"; private static final String ACCOUNT_COBB_FIST_NAME = "Cobb"; @@ -165,7 +165,7 @@ public class TestVillage extends AbstractStoryTest { private static final String ACCOUNT_WALLY_USERNAME = "wally"; private static final String ACCOUNT_WALLY_FIST_NAME = "Wally"; private static final String ACCOUNT_WALLY_LAST_NAME = "Feed"; - private static final String USER_WALLY_NAME = ACCOUNT_WALLY_FIST_NAME+"."+ACCOUNT_WALLY_LAST_NAME; + private static final String USER_WALLY_NAME = ACCOUNT_WALLY_FIST_NAME + "." + ACCOUNT_WALLY_LAST_NAME; private static final String ACCOUNT_AUGUSTUS_USERNAME = "augustus"; private static final String ACCOUNT_AUGUSTUS_FIST_NAME = "Augustus"; @@ -191,7 +191,6 @@ public class TestVillage extends AbstractStoryTest { private static final String GROUP_PROJECT_JOLLY_ROGER_ADMIN_DN = "cn=admins,ou=Jolly Roger,dc=example,dc=com"; - protected static DummyResource dummyResourceSrc; protected static DummyResourceContoller dummyResourceCtlSrc; protected ResourceType resourceDummySrcType; @@ -263,8 +262,7 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_SOURCE_OID, task); TestUtil.assertSuccess(testResultHr); @@ -286,8 +284,7 @@ public void test000Sanity() throws Exception { */ @Test public void test020ResourceOpenDjGet() throws Exception { - final String TEST_NAME = "test020ResourceOpenDjGet"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT); @@ -356,8 +353,8 @@ public void test022ResourceOpenDjRefinedSchema() throws Exception { RefinedResourceSchema refinedSchemaAfter = RefinedResourceSchema.getRefinedSchema(resourceAfter); long t4 = System.currentTimeMillis(); - display("Times", "getObject(RESOURCE_OPENDJ_OID): "+(t1-t0)+"ms\ngetResourceSchema: "+(t3-t2) - +"ms\ngetRefinedSchema: "+(t4-t3)+"ms"); + display("Times", "getObject(RESOURCE_OPENDJ_OID): " + (t1 - t0) + "ms\ngetResourceSchema: " + (t3 - t2) + + "ms\ngetRefinedSchema: " + (t4 - t3) + "ms"); // variable number of clones: 1 or 2 because of trigger scanner task assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1, 2); @@ -369,15 +366,12 @@ public void test022ResourceOpenDjRefinedSchema() throws Exception { assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_CONFIGURATION_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT, 0); - assertTrue("Resource schema has changed", resourceSchemaBefore == resourceSchemaAfter ); - assertTrue("Refined schema has changed", refinedSchemaBefore == refinedSchemaAfter ); + assertSame("Resource schema has changed", resourceSchemaBefore, resourceSchemaAfter); + assertSame("Refined schema has changed", refinedSchemaBefore, refinedSchemaAfter); } @Test public void test100AddSrcAccountHerman() throws Exception { - final String TEST_NAME = "test100AddSrcAccountHerman"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_HERMAN_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_FIRST_NAME, ACCOUNT_HERMAN_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_LAST_NAME, ACCOUNT_HERMAN_LAST_NAME); @@ -396,9 +390,6 @@ public void test100AddSrcAccountHerman() throws Exception { @Test public void test101HermanAssignBasicRole() throws Exception { - final String TEST_NAME = "test101HermanAssignBasicRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_HERMAN_NAME); // WHEN @@ -413,9 +404,6 @@ public void test101HermanAssignBasicRole() throws Exception { @Test public void test102HermanUnAssignBasicRole() throws Exception { - final String TEST_NAME = "test102HermanUnAssignBasicRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_HERMAN_NAME); // WHEN @@ -430,9 +418,6 @@ public void test102HermanUnAssignBasicRole() throws Exception { @Test public void test103HermanAssignBasicAndSimpleRole() throws Exception { - final String TEST_NAME = "test103HermanAssignBasicAndSimpleRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_HERMAN_NAME); // WHEN @@ -449,9 +434,6 @@ public void test103HermanAssignBasicAndSimpleRole() throws Exception { @Test public void test104HermanUnAssignSimpleRoleThenBasic() throws Exception { - final String TEST_NAME = "test104HermanUnAssignSimpleRoleThenBasic"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_HERMAN_NAME); // WHEN @@ -474,12 +456,8 @@ public void test104HermanUnAssignSimpleRoleThenBasic() throws Exception { assertNoLdapLocGov(userAfter, ACCOUNT_HERMAN_LOC, ACCOUNT_HERMAN_ORG); } - @Test public void test105ModifySrcAccountHermanRemoveLoc() throws Exception { - final String TEST_NAME = "test105ModifySrcAccountHermanRemoveLoc"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); // WHEN @@ -494,9 +472,6 @@ public void test105ModifySrcAccountHermanRemoveLoc() throws Exception { @Test public void test106HermanAssignBasicRole() throws Exception { - final String TEST_NAME = "test106HermanAssignBasicRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_HERMAN_NAME); // WHEN @@ -511,9 +486,6 @@ public void test106HermanAssignBasicRole() throws Exception { @Test public void test107ModifySrcAccountHermanAddLoc() throws Exception { - final String TEST_NAME = "test107ModifySrcAccountHermanAddLoc"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); // WHEN @@ -529,9 +501,6 @@ public void test107ModifySrcAccountHermanAddLoc() throws Exception { @Test public void test108ModifySrcAccountHermanRemoveLoc() throws Exception { - final String TEST_NAME = "test108ModifySrcAccountHermanRemoveLoc"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); // WHEN @@ -547,9 +516,6 @@ public void test108ModifySrcAccountHermanRemoveLoc() throws Exception { @Test public void test109HermanUnAssignBasicRole() throws Exception { - final String TEST_NAME = "test109HermanUnAssignBasicRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_HERMAN_NAME); // WHEN @@ -564,9 +530,6 @@ public void test109HermanUnAssignBasicRole() throws Exception { @Test public void test110AddSrcAccountLemonhead() throws Exception { - final String TEST_NAME = "test110AddSrcAccountLemonhead"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_LEMONHEAD_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_FIRST_NAME, ACCOUNT_LEMONHEAD_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_LAST_NAME, ACCOUNT_LEMONHEAD_LAST_NAME); @@ -590,9 +553,6 @@ public void test110AddSrcAccountLemonhead() throws Exception { */ @Test public void test120AddSrcAccountWally() throws Exception { - final String TEST_NAME = "test120AddSrcAccountWally"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_WALLY_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_FIRST_NAME, ACCOUNT_WALLY_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_LAST_NAME, ACCOUNT_WALLY_LAST_NAME); @@ -609,9 +569,6 @@ public void test120AddSrcAccountWally() throws Exception { @Test public void test121WallyAssignBasicRole() throws Exception { - final String TEST_NAME = "test121WallyAssignBasicRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_WALLY_NAME); // WHEN @@ -625,9 +582,6 @@ public void test121WallyAssignBasicRole() throws Exception { @Test public void test122WallyUnAssignBasicRole() throws Exception { - final String TEST_NAME = "test122WallyUnAssignBasicRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_WALLY_NAME); // WHEN @@ -644,9 +598,6 @@ public void test122WallyUnAssignBasicRole() throws Exception { */ @Test public void test130AddSrcAccountMancomb() throws Exception { - final String TEST_NAME = "test130AddSrcAccountMancomb"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount newAccount = new DummyAccount(ACCOUNT_MANCOMB_USERNAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_FIRST_NAME, ACCOUNT_MANCOMB_FIST_NAME); newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_LAST_NAME, ACCOUNT_MANCOMB_LAST_NAME); @@ -665,9 +616,6 @@ public void test130AddSrcAccountMancomb() throws Exception { @Test public void test131MancombAssignBasicRole() throws Exception { - final String TEST_NAME = "test131WallyAssignBasicRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_MANCOMB_NAME); // WHEN @@ -681,9 +629,6 @@ public void test131MancombAssignBasicRole() throws Exception { @Test public void test132MancombUnAssignBasicRole() throws Exception { - final String TEST_NAME = "test132MancombUnAssignBasicRole"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - PrismObject user = findUserByUsername(USER_MANCOMB_NAME); // WHEN @@ -695,15 +640,11 @@ public void test132MancombUnAssignBasicRole() throws Exception { assertLocGov(userAfter, ACCOUNT_MANCOMB_LOC, ACCOUNT_MANCOMB_ORG); } - /** * Change of org should trigger rename */ @Test public void test150ModifySrcAccountHermanReplaceOrg() throws Exception { - final String TEST_NAME = "test150ModifySrcAccountHermanReplaceOrg"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); // WHEN @@ -724,9 +665,6 @@ public void test150ModifySrcAccountHermanReplaceOrg() throws Exception { */ @Test public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { - final String TEST_NAME = "test152ModifySrcAccountHermanDeleteOrg"; - Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); - DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); // WHEN @@ -748,7 +686,6 @@ public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { @Test public void test200CreateUserAssignOrgPwdPolicy() throws Exception { - final String TEST_NAME = "test200CreateUserAssignOrgPwdPolicy"; Task task = getTestTask(); OperationResult result = createOperationResult(); @@ -783,22 +720,19 @@ public void test200CreateUserAssignOrgPwdPolicy() throws Exception { //TODO: assert added user PrismObject userMikeAfter = getUser(USER_MIKE_OID); - UserAsserter.forUser(userMikeAfter). - assertAssignments(2). - assertLinks(0); + UserAsserter.forUser(userMikeAfter). + assertAssignments(2). + assertLinks(0); } @Test - public void test201unassignRole() throws Exception{ - final String TEST_NAME = "test201unassignRole"; + public void test201unassignRole() throws Exception { unassignRole(USER_MIKE_OID, ROLE_BASIC_OID); //TODO: assertions } @Test - public void test202assignRoleOrgPwdPolicy() throws Exception{ - final String TEST_NAME = "test202assignRoleOrgPwdPolicy"; - + public void test202assignRoleOrgPwdPolicy() throws Exception { //this will throw exception, if incorrect pwd policy is selected...but some assertion will be nice :) Task task = getTestTask(); OperationResult result = task.getResult(); @@ -810,7 +744,6 @@ public void test202assignRoleOrgPwdPolicy() throws Exception{ @Test public void test300AddProjectJollyRoger() throws Exception { - final String TEST_NAME = "test300AddProjectJollyRoger"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -828,7 +761,7 @@ public void test300AddProjectJollyRoger() throws Exception { Entry ouEntry = openDJController.fetchAndAssertEntry("ou=Jolly Roger,dc=example,dc=com", "organizationalUnit"); Entry groupEntry = openDJController.fetchAndAssertEntry(GROUP_PROJECT_JOLLY_ROGER_ADMIN_DN, GROUP_OF_UNIQUE_NAMES_OBJECTCLASS_NAME); - //TODO: more assertions + //TODO: more assertions } /** @@ -840,10 +773,10 @@ public void test310ProjectJollyRogerNestedGroup() throws Exception { Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); - openDJController.addEntry("dn: "+GROUP_JOLLYROGERS_DN+"\n"+ - "objectclass: "+GROUP_OF_UNIQUE_NAMES_OBJECTCLASS_NAME+"\n"+ - "cn: jollyrogers\n"+ - GROUP_MEMBER_ATTRIBUTE_NAME+": "+GROUP_PROJECT_JOLLY_ROGER_ADMIN_DN+"\n"); + openDJController.addEntry("dn: " + GROUP_JOLLYROGERS_DN + "\n" + + "objectclass: " + GROUP_OF_UNIQUE_NAMES_OBJECTCLASS_NAME + "\n" + + "cn: jollyrogers\n" + + GROUP_MEMBER_ATTRIBUTE_NAME + ": " + GROUP_PROJECT_JOLLY_ROGER_ADMIN_DN + "\n"); display("LDAP entries", openDJController.dumpEntries()); @@ -919,44 +852,44 @@ public void test350AddRepoUserNoEmployeeNumberRecompute() throws Exception { private void assertLocGov(PrismObject user, String expLoc, String expOrg) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { UserType userType = user.asObjectable(); - PrismAsserts.assertEqualsPolyString("Wrong locality in "+user, expLoc, userType.getLocality()); + PrismAsserts.assertEqualsPolyString("Wrong locality in " + user, expLoc, userType.getLocality()); if (expOrg == null) { - assertTrue("Unexpected organization in "+user+": "+userType.getOrganization(), userType.getOrganization().isEmpty()); + assertTrue("Unexpected organization in " + user + ": " + userType.getOrganization(), userType.getOrganization().isEmpty()); } else { - PrismAsserts.assertEqualsCollectionUnordered("Wrong organization in "+user, userType.getOrganization(), - PrismTestUtil.createPolyStringType(expOrg)); + PrismAsserts.assertEqualsCollectionUnordered("Wrong organization in " + user, userType.getOrganization(), + PrismTestUtil.createPolyStringType(expOrg)); } if (expLoc == null || expOrg == null) { - assertNull("Wrong costCenter in "+user+", expected empty but was "+userType.getCostCenter(), userType.getCostCenter()); + assertNull("Wrong costCenter in " + user + ", expected empty but was " + userType.getCostCenter(), userType.getCostCenter()); } else { - assertEquals("Wrong costCenter in "+user, userType.getCostCenter(), expOrg+":"+expLoc); + assertEquals("Wrong costCenter in " + user, userType.getCostCenter(), expOrg + ":" + expLoc); } if (expOrg != null && !expOrg.equals("-")) { PrismObject org = findObjectByName(OrgType.class, expOrg); assertAssigned(user, org.getOid(), OrgType.COMPLEX_TYPE); String orgId = org.asObjectable().getIdentifier(); - PrismAsserts.assertEqualsCollectionUnordered("Wrong organizationalUnit in "+user, + PrismAsserts.assertEqualsCollectionUnordered("Wrong organizationalUnit in " + user, userType.getOrganizationalUnit(), PrismTestUtil.createPolyStringType(orgId)); - assertEquals("Wrong title in "+user, "Member of "+orgId, userType.getTitle().getOrig()); + assertEquals("Wrong title in " + user, "Member of " + orgId, userType.getTitle().getOrig()); } else { assertAssignments(user, OrgType.class, 0); - assertTrue("Unexpected organizationalUnit in "+user+": "+userType.getOrganizationalUnit(), userType.getOrganizationalUnit().isEmpty()); - assertNull("Unexpected title in "+user+": "+userType.getDescription(), userType.getTitle()); + assertTrue("Unexpected organizationalUnit in " + user + ": " + userType.getOrganizationalUnit(), userType.getOrganizationalUnit().isEmpty()); + assertNull("Unexpected title in " + user + ": " + userType.getDescription(), userType.getTitle()); } } private void assertUserNoRole(PrismObject user, String firstName, String lastName, String orgName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException { String username = getUsername(firstName, lastName, orgName); - assertNotNull("No "+username+" user", user); + assertNotNull("No " + username + " user", user); display("User", user); - assertUser(user, user.getOid(), username, firstName+" "+lastName, - firstName, lastName); - assertEmployeeNumber(user); - assertLinks(user, 1); + assertUser(user, user.getOid(), username, firstName + " " + lastName, + firstName, lastName); + assertEmployeeNumber(user); + assertLinks(user, 1); assertAccount(user, RESOURCE_DUMMY_SOURCE_OID); assertAssignments(user, RoleType.class, 0); - openDJController.assertNoEntry("uid="+username+",ou=people,dc=example,dc=com"); + openDJController.assertNoEntry("uid=" + username + ",ou=people,dc=example,dc=com"); } private void assertUserLdap(PrismObject user, String firstName, String lastName, String orgName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { @@ -965,11 +898,11 @@ private void assertUserLdap(PrismObject user, String firstName, String private void assertUserLdap(PrismObject user, String firstName, String lastName, String orgName, int assignments) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { String username = getUsername(firstName, lastName, orgName); - assertNotNull("No "+username+" user", user); + assertNotNull("No " + username + " user", user); display("User", user); - assertUser(user, user.getOid(), username, firstName+" "+lastName, - firstName, lastName); - assertEmployeeNumber(user); + assertUser(user, user.getOid(), username, firstName + " " + lastName, + firstName, lastName); + assertEmployeeNumber(user); assertLinks(user, 2); assertAccount(user, RESOURCE_DUMMY_SOURCE_OID); @@ -979,29 +912,27 @@ private void assertUserLdap(PrismObject user, String firstName, String assertAccount(user, RESOURCE_OPENDJ_OID); PrismReferenceValue linkRef = getLinkRef(user, RESOURCE_OPENDJ_OID); PrismObject shadow = getShadowModel(linkRef.getOid()); - display("OpenDJ shadow linked to "+user, shadow); - IntegrationTestTools.assertSecondaryIdentifier(shadow, "uid="+username+",ou=people,dc=example,dc=com"); + display("OpenDJ shadow linked to " + user, shadow); + IntegrationTestTools.assertSecondaryIdentifier(shadow, "uid=" + username + ",ou=people,dc=example,dc=com"); } private void assertEmployeeNumber(PrismObject user) { String employeeNumber = user.asObjectable().getEmployeeNumber(); - assertEquals("Wrong employeeNumber in "+user, user.getOid(), employeeNumber); + assertEquals("Wrong employeeNumber in " + user, user.getOid(), employeeNumber); } private String getUsername(String firstName, String lastName, String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - String username = firstName+"."+lastName; + String username = firstName + "." + lastName; if (orgName != null) { PrismObject org = findObjectByName(OrgType.class, orgName); - username = org.asObjectable().getIdentifier()+"."+username; + username = org.asObjectable().getIdentifier() + "." + username; } return username; } private void assertLdapLocGov(PrismObject user, String expLoc, String expOrg) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException { - UserType userType = user.asObjectable(); - - String groupCn = expOrg+":"+expLoc; - String groupDn = "cn="+groupCn+",ou=groups,"+openDJController.getSuffix(); + String groupCn = expOrg + ":" + expLoc; + String groupDn = "cn=" + groupCn + ",ou=groups," + openDJController.getSuffix(); Entry groupEntry = openDJController.fetchAndAssertEntry(groupDn, "groupOfUniqueNames"); display("Group entry", groupEntry); @@ -1011,15 +942,15 @@ private void assertLdapLocGov(PrismObject user, String expLoc, String openDJController.assertUniqueMember(groupEntry, accountDn); } - private void assertNoLdapLocGov(PrismObject user, String expLoc, String expOrg) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException { + private void assertNoLdapLocGov(PrismObject user, String expLoc, String expOrg) + throws DirectoryException { UserType userType = user.asObjectable(); - String groupCn = expOrg+":"+expLoc; - String groupDn = "cn="+groupCn+",ou=groups,"+openDJController.getSuffix(); + String groupCn = expOrg + ":" + expLoc; + String groupDn = "cn=" + groupCn + ",ou=groups," + openDJController.getSuffix(); Entry groupEntry = openDJController.fetchAndAssertEntry(groupDn, "groupOfUniqueNames"); display("Group entry", groupEntry); - String accountDn = "uid="+userType.getName()+",ou=people,"+openDJController.getSuffix(); + String accountDn = "uid=" + userType.getName() + ",ou=people," + openDJController.getSuffix(); openDJController.assertNoUniqueMember(groupEntry, accountDn); } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java index 5040f9f9ec4..cfc76c1e5bd 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java @@ -28,7 +28,6 @@ import org.testng.annotations.Test; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; @@ -146,8 +145,6 @@ protected String getLdapResourceOid() { @Test public void test000ClonePerformance() throws SchemaException { - final String TEST_NAME = "test000ClonePerformance"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -164,8 +161,6 @@ public void test000ClonePerformance() throws SchemaException { } @Test public void test010Sanity() throws Exception { - final String TEST_NAME = "test010Sanity"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -213,12 +208,12 @@ public void test020GenerateRoles() throws Exception { then(); long endMillis = System.currentTimeMillis(); - recordDuration(TEST_NAME, (endMillis - startMillis)); + recordDuration((endMillis - startMillis)); PerformanceInformation performanceInformation = getRepoPerformanceMonitor() .getThreadLocalPerformanceInformation(); dumpRepoSnapshot("SQL operations for " + TEST_NAME, performanceInformation, "role", NUMBER_OF_GENERATED_ROLES); - dumpGlobalCachePerformanceData(TEST_NAME); + dumpGlobalCachePerformanceData(); result.computeStatus(); assertSuccess(result); @@ -274,11 +269,11 @@ public void test100AddUsers() throws Exception { then(); long endMillis = System.currentTimeMillis(); - recordDuration(TEST_NAME, (endMillis - startMillis)); + recordDuration((endMillis - startMillis)); PerformanceInformation performanceInformation = getRepoPerformanceMonitor().getThreadLocalPerformanceInformation(); - dumpRepoSnapshotPerUser("SQL operations for " + TEST_NAME, performanceInformation); - dumpGlobalCachePerformanceData(TEST_NAME); + dumpRepoSnapshotPerUser(performanceInformation); + dumpGlobalCachePerformanceData(); result.computeStatus(); assertSuccess(result); @@ -286,8 +281,9 @@ public void test100AddUsers() throws Exception { assertLdapConnectorInstances(1); } - private void dumpRepoSnapshotPerUser(String label, PerformanceInformation performanceInformation) { - dumpRepoSnapshot(label, performanceInformation, "user", NUMBER_OF_GENERATED_USERS); + private void dumpRepoSnapshotPerUser(PerformanceInformation performanceInformation) { + dumpRepoSnapshot("SQL operations for " + getTestNameShort(), + performanceInformation, "user", NUMBER_OF_GENERATED_USERS); } private void dumpRepoSnapshot(String label, PerformanceInformation performanceInformation, String unit, int unitCount) { @@ -305,13 +301,8 @@ private void dumpRepoSnapshot(String label, PerformanceInformation performanceIn @Test public void test110RecomputeUsers() throws Exception { - final String TEST_NAME = "test110RecomputeUsers"; - rememberConnectorResourceCounters(); - Task task = getTestTask(); - OperationResult result = task.getResult(); - // WHEN when(); @@ -325,14 +316,13 @@ public void test110RecomputeUsers() throws Exception { // THEN then(); - recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_1_OID)); - + recordDuration(getRunDurationMillis(TASK_RECOMPUTE_1_OID)); PerformanceInformation performanceInformation = getRepoPerformanceMonitor().getGlobalPerformanceInformation(); - dumpRepoSnapshotPerUser("SQL operations for " + TEST_NAME, performanceInformation); - dumpGlobalCachePerformanceData(TEST_NAME); + dumpRepoSnapshotPerUser(performanceInformation); + dumpGlobalCachePerformanceData(); OperationStatsType statistics = getTaskTreeOperationStatistics(TASK_RECOMPUTE_1_OID); - displayOperationStatistics("Task operation statistics for " + TEST_NAME, statistics); + displayOperationStatistics(statistics); assertNotNull(statistics); assertUsers(getNumberOfUsers() + NUMBER_OF_GENERATED_USERS); @@ -369,14 +359,14 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { // THEN then(); - recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_NO_CACHE_OID)); + recordDuration(getRunDurationMillis(TASK_RECOMPUTE_NO_CACHE_OID)); PerformanceInformation performanceInformation = getRepoPerformanceMonitor().getGlobalPerformanceInformation(); - dumpRepoSnapshotPerUser("SQL operations for " + TEST_NAME, performanceInformation); - dumpGlobalCachePerformanceData(TEST_NAME); + dumpRepoSnapshotPerUser(performanceInformation); + dumpGlobalCachePerformanceData(); OperationStatsType statistics = getTaskTreeOperationStatistics(TASK_RECOMPUTE_NO_CACHE_OID); - displayOperationStatistics("Task operation statistics for " + TEST_NAME, statistics); + displayOperationStatistics(statistics); assertNotNull(statistics); assertUsers(getNumberOfUsers() + NUMBER_OF_GENERATED_USERS); @@ -415,14 +405,14 @@ public void test130RecomputeUsersMultinode() throws Exception { // THEN then(); - recordDuration(TEST_NAME, getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_OID)); + recordDuration(getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_OID)); PerformanceInformation performanceInformation = getRepoPerformanceMonitor().getGlobalPerformanceInformation(); - dumpRepoSnapshotPerUser("SQL operations for " + TEST_NAME, performanceInformation); - dumpGlobalCachePerformanceData(TEST_NAME); + dumpRepoSnapshotPerUser(performanceInformation); + dumpGlobalCachePerformanceData(); OperationStatsType statistics = getTaskTreeOperationStatistics(TASK_RECOMPUTE_MULTINODE_OID); - displayOperationStatistics("Task operation statistics for " + TEST_NAME, statistics); + displayOperationStatistics(statistics); assertNotNull(statistics); assertUsers(getNumberOfUsers() + NUMBER_OF_GENERATED_USERS); @@ -463,15 +453,15 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { // THEN then(); - recordDuration(TEST_NAME, getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_MULTITHREADED_OID)); + recordDuration(getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_MULTITHREADED_OID)); // todo retrieve this information from finished task PerformanceInformation performanceInformation = getRepoPerformanceMonitor().getGlobalPerformanceInformation(); - dumpRepoSnapshotPerUser("SQL operations for " + TEST_NAME, performanceInformation); - dumpGlobalCachePerformanceData(TEST_NAME); + dumpRepoSnapshotPerUser(performanceInformation); + dumpGlobalCachePerformanceData(); OperationStatsType statistics = getTaskTreeOperationStatistics(TASK_RECOMPUTE_MULTINODE_MULTITHREADED_OID); - displayOperationStatistics("Task operation statistics for " + TEST_NAME, statistics); + displayOperationStatistics(statistics); assertNotNull(statistics); assertUsers(getNumberOfUsers() + NUMBER_OF_GENERATED_USERS); @@ -512,15 +502,15 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { // THEN then(); - recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_4_OID)); + recordDuration(getRunDurationMillis(TASK_RECOMPUTE_4_OID)); // todo retrieve this information from finished task PerformanceInformation performanceInformation = getRepoPerformanceMonitor().getGlobalPerformanceInformation(); - dumpRepoSnapshotPerUser("SQL operations for " + TEST_NAME, performanceInformation); - dumpGlobalCachePerformanceData(TEST_NAME); + dumpRepoSnapshotPerUser(performanceInformation); + dumpGlobalCachePerformanceData(); OperationStatsType statistics = getTaskTreeOperationStatistics(TASK_RECOMPUTE_4_OID); - displayOperationStatistics("Task operation statistics for " + TEST_NAME, statistics); + displayOperationStatistics(statistics); assertNotNull(statistics); assertUsers(getNumberOfUsers() + NUMBER_OF_GENERATED_USERS); @@ -577,12 +567,8 @@ private void assertSteadyResource() { assertCounterIncrement(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT, 0); } - protected void assertLdapConnectorInstances() throws NumberFormatException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException, IOException, InterruptedException { - assertLdapConnectorInstances(2,4); - } - - private long recordDuration(String label, long duration) { - durations.put(label, duration); + private long recordDuration(long duration) { + durations.put(getTestNameShort(), duration); return duration; } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java index b18af1cb09a..49ddbedd183 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java @@ -7,15 +7,10 @@ package com.evolveum.midpoint.testing.story.ldap; +import static org.testng.AssertJUnit.assertNotNull; + +import java.io.File; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.springframework.test.annotation.DirtiesContext; @@ -24,32 +19,33 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import javax.xml.namespace.QName; -import java.io.File; - -import static org.testng.AssertJUnit.assertNotNull; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.ldap.OpenDJController; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * Testing dependencies: * There are two meta-roles for orgs. * Org Metarole contains two inducements, one for creating organizationalUnit (intent=ou) and one for creating groupOfUniqueNames (intent=group) in ldap. * group depends on ou (since it is created in ou) - * + *

* Org Metarole VIP is very similar it also contains two inducements, one for creating (intent=ou-vip) and one for creating groupOfUniqueNames (intent=group-vip) in ldap. * group-vip depends on ou-cip (since it is created in ou-vip) * * @author michael gruber - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) -public class TestLdapDependency extends AbstractLdapTest { +public class TestLdapDependency extends AbstractLdapTest { public static final File TEST_DIR = new File(LDAP_TEST_DIR, "dependency"); private static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; - private static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; - private static final QName OPENDJ_ASSOCIATION_GROUP_NAME = new QName(RESOURCE_OPENDJ_NAMESPACE, "group"); public static final String ORG_TOP_OID = "00000000-8888-6666-0000-100000000001"; @@ -62,7 +58,6 @@ public class TestLdapDependency extends AbstractLdapTest { private static String orgItOid; private static String orgHrOid; - private static final String ORG_TYPE_FUNCTIONAL = "functional"; private static final String LDAP_GROUP_INTENT = "group"; @@ -72,8 +67,6 @@ public class TestLdapDependency extends AbstractLdapTest { private static final String LDAP_OU_INTENT = "ou"; private static final String LDAP_OU_VIP_INTENT = "ou-vip"; - private PrismObject resourceOpenDj; - @Override protected String getLdapResourceOid() { return RESOURCE_OPENDJ_OID; @@ -114,7 +107,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -122,9 +115,8 @@ public static void stopResources() throws Exception { public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - // Resources - resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, getResourceOpenDjFile(), RESOURCE_OPENDJ_OID, initTask, initResult); + PrismObject resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, getResourceOpenDjFile(), RESOURCE_OPENDJ_OID, initTask, initResult); openDJController.setResource(resourceOpenDj); // Org @@ -138,8 +130,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - Task task = taskManager.createTaskInstance(TestLdapDependency.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -150,7 +141,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddOrgIT() throws Exception { - final String TEST_NAME = "test100AddOrgIT"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -177,7 +167,6 @@ public void test100AddOrgIT() throws Exception { @Test public void test150AssignFunctionalRoleToITOrg() throws Exception { - final String TEST_NAME = "test150AssignFunctionalRoleToITOrg"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -206,7 +195,6 @@ public void test150AssignFunctionalRoleToITOrg() throws Exception { @Test public void test170UnassignFunctionalRoleFromITOrg() throws Exception { - final String TEST_NAME = "test170UnassignFunctionalRoleFromITOrg"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -233,10 +221,8 @@ public void test170UnassignFunctionalRoleFromITOrg() throws Exception { //TODO: assert ldap objects deleted... } - @Test public void test200AddOrgHR() throws Exception { - final String TEST_NAME = "test200AddOrgHR"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -263,7 +249,6 @@ public void test200AddOrgHR() throws Exception { @Test public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { - final String TEST_NAME = "test250AssignFunctionalAndVipRoleToHROrg"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -295,7 +280,6 @@ public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { @Test public void test270UnassignVipRoleFromHROrg() throws Exception { - final String TEST_NAME = "test270UnassignVipRoleFromHROrg"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -327,7 +311,6 @@ public void test270UnassignVipRoleFromHROrg() throws Exception { //test280AssignVipAndSuperVipRoleToHROrg required for test290UnassignVipRoleFromHROrg @Test public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { - final String TEST_NAME = "test280AssignVipAndSuperVipRoleToHROrg"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -360,7 +343,6 @@ public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { @Test public void test290UnassignVipRoleFromHROrg() throws Exception { - final String TEST_NAME = "test290UnassignVipRoleFromHROrg"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -413,54 +395,36 @@ private PrismObject createOrg(String name, String parentOrgOid) throws return org; } - private void assertLdapObjectsFunctionalOrg(PrismObject org) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException { - String orgName = org.getName().toString(); - display("assert org", org.getName()); - - String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, LDAP_GROUP_INTENT); - PrismObject groupShadow = getShadowModel(groupOid); - display("Org "+orgName+" group shadow", groupShadow); - // TODO assert shadow content - - Entry groupEntry = openDJController.searchSingle("cn="+orgName); - assertNotNull("No group LDAP entry for "+orgName, groupEntry); - display("OU GROUP entry", openDJController.toHumanReadableLdifoid(groupEntry)); - openDJController.assertObjectClass(groupEntry, "groupOfUniqueNames"); - - } - - - private void assertLdapObject(PrismObject org, ShadowKindType kind, String intent) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException { - String orgName = org.getName().toString(); + private void assertLdapObject(PrismObject org, ShadowKindType kind, String intent) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, + ConfigurationException, DirectoryException, ExpressionEvaluationException { + String orgName = org.getName().toString(); display("assert org", orgName); String objOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, kind, intent); PrismObject objShadow = getShadowModel(objOid); - display("Org "+orgName+" kind " +kind + " intent " + intent +" shadow", objShadow); + display("Org " + orgName + " kind " + kind + " intent " + intent + " shadow", objShadow); // TODO assert shadow content String search = ""; - if (kind.equals(ShadowKindType.ENTITLEMENT)){ - if (LDAP_GROUP_INTENT.equals(intent)) search = "cn="+orgName; - if (LDAP_GROUP_VIP_INTENT.equals(intent)) search = "cn="+orgName+"-vip"; - if (LDAP_GROUP_SUPERVIP_INTENT.equals(intent)) search = "cn="+orgName+"-supervip"; + if (kind.equals(ShadowKindType.ENTITLEMENT)) { + if (LDAP_GROUP_INTENT.equals(intent)) { search = "cn=" + orgName; } + if (LDAP_GROUP_VIP_INTENT.equals(intent)) { search = "cn=" + orgName + "-vip"; } + if (LDAP_GROUP_SUPERVIP_INTENT.equals(intent)) { search = "cn=" + orgName + "-supervip"; } } - if (kind.equals(ShadowKindType.GENERIC)){ - if (LDAP_OU_INTENT.equals(intent)) search = "ou="+orgName; - if (LDAP_OU_VIP_INTENT.equals(intent)) search = "ou="+orgName+"-vip"; + if (kind.equals(ShadowKindType.GENERIC)) { + if (LDAP_OU_INTENT.equals(intent)) { search = "ou=" + orgName; } + if (LDAP_OU_VIP_INTENT.equals(intent)) { search = "ou=" + orgName + "-vip"; } } Entry objEntry = openDJController.searchSingle(search); - assertNotNull("No LDAP entry for "+orgName, objEntry); - display("LDAP entry kind " +kind + " inten " + intent +" ldapObj", objEntry); + assertNotNull("No LDAP entry for " + orgName, objEntry); + display("LDAP entry kind " + kind + " intent " + intent + " ldapObj", objEntry); - if (kind.equals(ShadowKindType.ENTITLEMENT)){ - openDJController.assertObjectClass(objEntry, "groupOfUniqueNames"); + if (kind.equals(ShadowKindType.ENTITLEMENT)) { + OpenDJController.assertObjectClass(objEntry, "groupOfUniqueNames"); } - if (kind.equals(ShadowKindType.GENERIC)){ - openDJController.assertObjectClass(objEntry, "organizationalUnit"); + if (kind.equals(ShadowKindType.GENERIC)) { + OpenDJController.assertObjectClass(objEntry, "organizationalUnit"); } - } - - }