Skip to content

Commit

Permalink
the rest of cleanup of test classes for future Checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Jan 28, 2020
1 parent 49a03d5 commit 04ed830
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 119 deletions.
Expand Up @@ -6,24 +6,20 @@
*/
package com.evolveum.midpoint.model.impl;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.*;

import java.io.File;
import java.util.Collection;

import javax.xml.namespace.QName;

import com.evolveum.midpoint.common.refinery.*;
import com.evolveum.midpoint.model.impl.util.ModelImplUtils;

import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

import com.evolveum.midpoint.common.refinery.*;
import com.evolveum.midpoint.model.impl.util.ModelImplUtils;
import com.evolveum.midpoint.schema.internals.InternalMonitor;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.result.OperationResult;
Expand All @@ -35,9 +31,8 @@

/**
* @author semancik
*
*/
@ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"})
@ContextConfiguration(locations = { "classpath:ctx-model-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestRefinedSchema extends AbstractInternalModelIntegrationTest {

Expand All @@ -55,15 +50,13 @@ public class TestRefinedSchema extends AbstractInternalModelIntegrationTest {
"task-reconcile-dummy-kind-intent-objectclass.xml");
public static final String TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID = "3f2a1140-e60e-11e5-adb7-776abfbb2227";


private RefinedResourceSchema refinedSchema;
private RefinedResourceSchema refinedSchemaModel;

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
InternalMonitor.reset();
// InternalMonitor.setTraceShadowFetchOperation(true);
}

@Test
Expand All @@ -81,7 +74,7 @@ public void test000Sanity() throws Exception {
}

@Test
public void test010SanityModel() throws Exception {
public void test010SanityModel() throws Exception {
final String TEST_NAME = "test010SanityModel";
TestUtil.displayTestTitle(this, TEST_NAME);

Expand All @@ -93,8 +86,8 @@ public void test010SanityModel() throws Exception {
// THEN
getDummyResourceController().assertRefinedSchemaSanity(refinedSchemaModel);

assertTrue("Not layer refined schema, it is "+refinedSchemaModel.getClass(), refinedSchemaModel instanceof LayerRefinedResourceSchema);
assertEquals("Wrong layer", LayerType.MODEL, ((LayerRefinedResourceSchema)refinedSchemaModel).getLayer());
assertTrue("Not layer refined schema, it is " + refinedSchemaModel.getClass(), refinedSchemaModel instanceof LayerRefinedResourceSchema);
assertEquals("Wrong layer", LayerType.MODEL, ((LayerRefinedResourceSchema) refinedSchemaModel).getLayer());
}

@Test
Expand All @@ -108,9 +101,8 @@ public void test100EntitlementRefinedObjectClasses() throws Exception {
display("entitlement rOcDefs", entitlementROcDefs);

// THEN

for (RefinedObjectClassDefinition entitlementROcDef: entitlementROcDefs) {
assertEquals("Wrong kind in "+entitlementROcDef, ShadowKindType.ENTITLEMENT, entitlementROcDef.getKind());
for (RefinedObjectClassDefinition entitlementROcDef : entitlementROcDefs) {
assertEquals("Wrong kind in " + entitlementROcDef, ShadowKindType.ENTITLEMENT, entitlementROcDef.getKind());
}

assertEquals("Wrong number of entitlement rOcDefs", 6, entitlementROcDefs.size());
Expand All @@ -127,9 +119,8 @@ public void test101EntitlementRefinedObjectClassesModel() throws Exception {
display("entitlement rOcDefs", entitlementROcDefs);

// THEN

for (RefinedObjectClassDefinition entitlementROcDef: entitlementROcDefs) {
assertEquals("Wrong kind in "+entitlementROcDef, ShadowKindType.ENTITLEMENT, entitlementROcDef.getKind());
for (RefinedObjectClassDefinition entitlementROcDef : entitlementROcDefs) {
assertEquals("Wrong kind in " + entitlementROcDef, ShadowKindType.ENTITLEMENT, entitlementROcDef.getKind());
}

assertEquals("Wrong number of entitlement rOcDefs", 6, entitlementROcDefs.size());
Expand All @@ -140,7 +131,7 @@ public void test110DetermineObjectClassObjectClass() throws Exception {
final String TEST_NAME = "test110DetermineObjectClassObjectClass";
TestUtil.displayTestTitle(this, TEST_NAME);

OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);

importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE);

Expand All @@ -163,7 +154,7 @@ public void test112DetermineObjectClassKindIntent() throws Exception {
final String TEST_NAME = "test112DetermineObjectClassKindIntent";
TestUtil.displayTestTitle(this, TEST_NAME);

OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);

importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE);

Expand All @@ -186,7 +177,7 @@ public void test114DetermineObjectClassKindIntentObjectClass() throws Exception
final String TEST_NAME = "test114DetermineObjectClassKindIntentObjectClass";
TestUtil.displayTestTitle(this, TEST_NAME);

OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);

importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE);

Expand All @@ -209,7 +200,7 @@ public void test120DetermineObjectClassObjectClassModel() throws Exception {
final String TEST_NAME = "test120DetermineObjectClassObjectClassModel";
TestUtil.displayTestTitle(this, TEST_NAME);

OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);

importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE);

Expand All @@ -233,7 +224,7 @@ public void test122DetermineObjectClassKindIntentModel() throws Exception {
final String TEST_NAME = "test122DetermineObjectClassKindIntentModel";
TestUtil.displayTestTitle(this, TEST_NAME);

OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);

importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE);

Expand All @@ -258,7 +249,7 @@ public void test124DetermineObjectClassKindIntentObjectClassModel() throws Excep
final String TEST_NAME = "test124DetermineObjectClassKindIntentObjectClassModel";
TestUtil.displayTestTitle(this, TEST_NAME);

OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);

importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE);

Expand All @@ -281,26 +272,25 @@ public void test124DetermineObjectClassKindIntentObjectClassModel() throws Excep
private void assertObjectClass(ObjectClassComplexTypeDefinition objectClass,
QName objectClassQName) {
assertNotNull("No object class", objectClass);
assertEquals("Wrong object class QName in object class "+objectClass, objectClassQName, objectClass.getTypeName());
assertEquals("Wrong object class QName in object class " + objectClass, objectClassQName, objectClass.getTypeName());
}

private void assertRefinedObjectClass(ObjectClassComplexTypeDefinition objectClass,
QName objectClassQName, ShadowKindType kind, String intent) {
assertNotNull("No object class", objectClass);
if (!(objectClass instanceof RefinedObjectClassDefinition)) {
AssertJUnit.fail("Expected refined object class definition, but it was "+objectClass+" ("+objectClass.getClass()+")");
AssertJUnit.fail("Expected refined object class definition, but it was " + objectClass + " (" + objectClass.getClass() + ")");
}
RefinedObjectClassDefinition rOcDef = (RefinedObjectClassDefinition)objectClass;
assertEquals("Wrong object class QName in rOcDef "+rOcDef, objectClassQName, rOcDef.getTypeName());
assertEquals("Wrong kind in rOcDef "+rOcDef, kind, rOcDef.getKind());
assertEquals("Wrong kind in rOcDef "+rOcDef, intent, rOcDef.getIntent());
RefinedObjectClassDefinition rOcDef = (RefinedObjectClassDefinition) objectClass;
assertEquals("Wrong object class QName in rOcDef " + rOcDef, objectClassQName, rOcDef.getTypeName());
assertEquals("Wrong kind in rOcDef " + rOcDef, kind, rOcDef.getKind());
assertEquals("Wrong kind in rOcDef " + rOcDef, intent, rOcDef.getIntent());
}

private void assertLayerRefinedObjectClass(ObjectClassComplexTypeDefinition objectClass,
QName objectClassQName, ShadowKindType kind, String intent, LayerType layer) {
assertRefinedObjectClass(objectClass, objectClassQName, kind, intent);
assertTrue("Not layer refined definition, it is "+refinedSchemaModel.getClass(), objectClass instanceof LayerRefinedObjectClassDefinition);
assertEquals("Wrong layer", layer, ((LayerRefinedObjectClassDefinition)objectClass).getLayer());

assertTrue("Not layer refined definition, it is " + refinedSchemaModel.getClass(), objectClass instanceof LayerRefinedObjectClassDefinition);
assertEquals("Wrong layer", layer, ((LayerRefinedObjectClassDefinition) objectClass).getLayer());
}
}
Expand Up @@ -6,15 +6,10 @@
*/
package com.evolveum.midpoint.model.impl.lens;

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.Collection;

import javax.xml.namespace.QName;

import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -24,8 +19,6 @@
import org.testng.annotations.Test;

import com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision;
import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.model.impl.lens.LensProjectionContext;
import com.evolveum.midpoint.model.impl.lens.projector.Projector;
import com.evolveum.midpoint.prism.OriginType;
import com.evolveum.midpoint.prism.PrismObject;
Expand All @@ -42,15 +35,10 @@
import com.evolveum.midpoint.test.DummyResourceContoller;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType;
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.*;

/**
* @author semancik
*
*/
@ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
Expand Down
Expand Up @@ -6,21 +6,17 @@
*/
package com.evolveum.midpoint.model.impl.sync;

import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;

import org.testng.annotations.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;

import com.evolveum.midpoint.model.impl.sync.Action;
import com.evolveum.midpoint.model.impl.sync.ActionManager;

/**
*
* @author lazyman
*
*/
@ContextConfiguration(locations = { "classpath:ctx-model-test-no-repo.xml" })
public class ActionManagerImplTest extends AbstractTestNGSpringContextTests {
Expand Down
Expand Up @@ -6,17 +6,14 @@
*/
package com.evolveum.midpoint.model.impl.sync;

import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

import com.evolveum.midpoint.model.impl.sync.SynchronizationSituation;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

/**
*
* @author lazyman
*
*/
public class SynchronizationSituationTest {

Expand Down

0 comments on commit 04ed830

Please sign in to comment.