From 1bd16d738770e9f5a236a040fb6634e269a80eb7 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Thu, 20 Jul 2023 09:30:01 +0200
Subject: [PATCH] - increased readability

---
 .../plugin/Validation/TestValidateSchema.java | 27 ++++++++++++-------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/java/org/slub/rosetta/dps/repository/plugin/Validation/TestValidateSchema.java b/java/org/slub/rosetta/dps/repository/plugin/Validation/TestValidateSchema.java
index 24b030b..d965827 100644
--- a/java/org/slub/rosetta/dps/repository/plugin/Validation/TestValidateSchema.java
+++ b/java/org/slub/rosetta/dps/repository/plugin/Validation/TestValidateSchema.java
@@ -41,7 +41,7 @@ import static org.junit.Assert.*;
 
 @RunWith(JUnit4.class)
 public class TestValidateSchema {
-    private static XmlFormatValidationPlugin mock;
+    private XmlFormatValidationPlugin mock;
 
     private final Map<String, String> initp = new HashMap<>();
     private URI local2Uri(String sUri) {
@@ -67,6 +67,8 @@ public class TestValidateSchema {
 
     @org.junit.Test
     public void schema_valid() {
+        System.out.println("-----------------------------------------------------------------------------------");
+        String testfile = "resources/test/valid/minimod.xml";
         ValidationResultHandle resultHandle = new ValidationResultHandle();
         ValidationResourceResolver validationResourceResolver = new ValidationResourceResolver(mock.getNamespaceSchemaMap(), resultHandle);
         var v = new ValidateSchema(validationResourceResolver, resultHandle);
@@ -74,19 +76,22 @@ public class TestValidateSchema {
         var has_exception = false;
         var res = false;
         try {
-            var doc = mock.getDocument("resources/test/valid/minimod.xml");
+            var doc = mock.getDocument(testfile);
             res = v.validateAgainst(doc, local2Uri("example_catalog/mods-3.8/flatten/mods-3-8.xsd"));
         } catch ( Exception e) {
             e.printStackTrace();
             has_exception = true;
         }
         System.out.println( resultHandle.getLog());
-        assertFalse("schema validation should not raise an exception", has_exception );
-        assertTrue("schema validation should return true for sucessful validation",  res);
+        assertFalse("schema validation of " + testfile + " should not raise an exception", has_exception );
+        assertTrue( "schema validation of " + testfile + " should return true for sucessful validation",  res);
+
     }
 
     @org.junit.Test
     public void schema_invalid() {
+        System.out.println("-----------------------------------------------------------------------------------");
+        String testfile = "resources/test/invalid/minimod.xml";
         ValidationResultHandle resultHandle = new ValidationResultHandle();
         ValidationResourceResolver validationResourceResolver = new ValidationResourceResolver(mock.getNamespaceSchemaMap(), resultHandle);
         var v = new ValidateSchema(validationResourceResolver, resultHandle);
@@ -94,19 +99,21 @@ public class TestValidateSchema {
         var has_exception = false;
         var res = false;
         try {
-            var doc = mock.getDocument("resources/test/invalid/minimod.xml");
+            var doc = mock.getDocument(testfile);
             res = v.validateAgainst(doc, local2Uri("example_catalog/mods-3.8/flatten/mods-3-8.xsd"));
         } catch ( Exception e) {
             System.out.println( "EXCEPTION:" + e.getMessage());
             e.printStackTrace();
             has_exception = true;
         }
-        assertFalse("schema validation should not raise an exception", has_exception );
-        assertFalse("schema validation should return false for failed validation",  res);
+        assertFalse("schema validation of " + testfile + " should not raise an exception", has_exception );
+        assertFalse("schema validation of " + testfile + " should return false for failed validation",  res);
     }
 
     @org.junit.Test
     public void check_import_regression() {
+        System.out.println("-----------------------------------------------------------------------------------");
+        String testfile = "resources/test/valid/kml/KML_Samples.kml";
         Set<ValidationSchema> nssm  = new HashSet<>();
         Set<ValidationSchema> old = mock.getNamespaceSchemaMap();
         for (ValidationSchema val : old) { // filter Atoim out to trigger error
@@ -122,14 +129,14 @@ public class TestValidateSchema {
         var has_exception = false;
         var res = false;
         try {
-            var doc = mock.getDocument("resources/test/valid/kml/KML_Samples.kml");
+            var doc = mock.getDocument(testfile);
             res = v.validateAgainst(doc, local2Uri("example_catalog/kml-2.3.0/ogckml23.xsd"));
         } catch ( Exception e) {
             System.out.println( "EXCEPTION:" + e.getMessage());
             e.printStackTrace();
             has_exception = true;
         }
-        assertFalse("schema validation should not raise an exception", has_exception );
-        assertFalse("schema validation should return false for failed validation",  res);
+        assertFalse("schema validation of " + testfile + " should not raise an exception", has_exception );
+        assertFalse("schema validation of " + testfile + " should return false for failed validation",  res);
     }
 }
-- 
GitLab