Reduce the number of problems in aai-common by removing unused imports
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / introspection / tools / IntrospectorValidatorTest.java
index 7c0539b..bc222ec 100644 (file)
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package org.onap.aai.introspection.tools;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.aai.AAISetup;
-import org.onap.aai.introspection.*;
-import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+package org.onap.aai.introspection.tools;
 
 import static junit.framework.TestCase.assertNotNull;
 import static org.eclipse.persistence.jpa.jpql.Assert.fail;
@@ -31,6 +26,19 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.springframework.test.annotation.DirtiesContext;
+
+@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class IntrospectorValidatorTest extends AAISetup {
 
     private Loader loader;
@@ -41,11 +49,11 @@ public class IntrospectorValidatorTest extends AAISetup {
 
     @Before
     public void setup() {
-        loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
+        loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
         issue = new Issue();
         try {
             introspector = loader.introspectorFromName("pserver");
-        }catch(Exception e){
+        } catch (Exception e) {
             fail("Introspector instantiation call threw an exception " + e);
         }
         b = new IntrospectorValidator.Builder();
@@ -57,11 +65,11 @@ public class IntrospectorValidatorTest extends AAISetup {
                 return true;
             }
         });
-        //this method does nothing
-        iv.processPrimitiveList("TEST",introspector);
+        // this method does nothing
+        iv.processPrimitiveList("TEST", introspector);
     }
 
-    public void setupIssue(String message, IssueType type, String propName, Introspector introspector){
+    public void setupIssue(String message, IssueType type, String propName, Introspector introspector) {
         issue.setDetail(message);
         issue.setType(type);
         issue.setPropName(propName);
@@ -70,56 +78,60 @@ public class IntrospectorValidatorTest extends AAISetup {
 
     @Test
     public void testIntrospectorValidatorMaxDepth() throws AAIUnknownObjectException {
-        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector);
         b.restrictDepth(4);
         assertEquals("Maximum Depth should be 4", 4, b.getMaximumDepth());
     }
 
     @Test
     public void testIntrospectorValidatorValidationRequired() throws AAIUnknownObjectException {
-        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector);
         b.validateRequired(true);
         assertTrue("Validation should be required", b.getValidateRequired());
     }
 
     @Test
-    public void testIntrospectorValidatorValidatedFalse() throws AAIUnknownObjectException{
-        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+    public void testIntrospectorValidatorValidatedFalse() throws AAIUnknownObjectException {
+        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector);
         try {
             assertFalse("Not currently validated", iv.validate(introspector));
-        }catch (Exception e){
+        } catch (Exception e) {
             fail("Introspector validate call threw an exception " + e);
         }
     }
 
     @Test
-    public void testIntrospectorValidatorResolveIssues() throws AAIUnknownObjectException{
-        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+    public void testIntrospectorValidatorResolveIssues() throws AAIUnknownObjectException {
+        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector);
         assertTrue("Introspector call to resolve issues should return true", iv.resolveIssues());
     }
 
     @Test
-    public void testIntrospectorValidatorGetIssues() throws AAIUnknownObjectException{
-        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
-        iv.getIssues();
+    public void testIntrospectorValidatorGetIssues() throws AAIUnknownObjectException {
+        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector);
+        List<Issue> result = iv.getIssues();
+        Assert.assertNotNull(result);
+
     }
 
     @Test
-    public void testIntrospectorValidatorProcessComplexObject() throws AAIUnknownObjectException{
-        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+    public void testIntrospectorValidatorProcessComplexObject() throws AAIUnknownObjectException {
+        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector);
         iv.processComplexObj(introspector);
+        Assert.assertNotNull(introspector);
     }
 
     @Test
-    public void testIntrospectorValidatorCreateComplexListSize() throws AAIUnknownObjectException{
-        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
-        assertEquals("create complex list size should return 0", 0, iv.createComplexListSize(introspector, introspector));
+    public void testIntrospectorValidatorCreateComplexListSize() throws AAIUnknownObjectException {
+        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector);
+        assertEquals("create complex list size should return 0", 0,
+                iv.createComplexListSize(introspector, introspector));
     }
 
     @Test
-    public void testIntrospectorValidatorGetResolvers() throws AAIUnknownObjectException{
-        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
-        assertNotNull("Get resolvers should not be null",  b.getResolvers());
+    public void testIntrospectorValidatorGetResolvers() throws AAIUnknownObjectException {
+        setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector);
+        assertNotNull("Get resolvers should not be null", b.getResolvers());
     }
 
-}
\ No newline at end of file
+}