Author: tilman
Date: Wed Mar 25 20:45:55 2026
New Revision: 1932556

Log:
PDFBOX-5660: sonar fix

Modified:
   
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java

Modified: 
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java 
    Wed Mar 25 17:19:00 2026        (r1932555)
+++ 
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java 
    Wed Mar 25 20:45:55 2026        (r1932556)
@@ -192,46 +192,43 @@ class XMPSchemaTester
         Field[] fields = schemaClass.getFields();
         for (Field field : fields)
         {
-            if (field.isAnnotationPresent(PropertyType.class))
+            if (field.isAnnotationPresent(PropertyType.class) && 
!field.get(schema).equals(property))
             {
-                if (!field.get(schema).equals(property))
+                PropertyType pt = field.getAnnotation(PropertyType.class);
+                if (pt.type() == Types.LangAlt)
                 {
-                    PropertyType pt = field.getAnnotation(PropertyType.class);
-                    if (pt.type() == Types.LangAlt)
-                    {
-                        // do not check method existence
-                    }
-                    else if (pt.type() == Types.Thumbnail && pt.card() == 
Cardinality.Alt)
-                    {
-                        // do not check method existence
-                    }
-                    else if (pt.type() == Types.ResourceRef)
-                    {
-                        // do not check method existence
-                    }
-                    else if (pt.type() == Types.Version && pt.card() == 
Cardinality.Seq)
-                    {
-                        // do not check method existence
-                    }
-                    else
+                    // do not check method existence
+                }
+                else if (pt.type() == Types.Thumbnail && pt.card() == 
Cardinality.Alt)
+                {
+                    // do not check method existence
+                }
+                else if (pt.type() == Types.ResourceRef)
+                {
+                    // do not check method existence
+                }
+                else if (pt.type() == Types.Version && pt.card() == 
Cardinality.Seq)
+                {
+                    // do not check method existence
+                }
+                else
+                {
+                    // type test
+                    PropertyType spt = 
retrievePropertyType(field.get(schema).toString());
+                    String getNameProperty = "get" + 
prepareName(field.get(schema).toString(), spt) + "Property";
+                    Method getMethod = schemaClass.getMethod(getNameProperty);
+                    assertNull(getMethod.invoke(schema), getNameProperty + " 
should return null when testing " + property);
+                    // value test
+                    String getNameValue = "get" + 
prepareName(field.get(schema).toString(), spt);
+                    if (schemaClass == XMPMediaManagementSchema.class && 
"getHistory".equals(getNameValue))
                     {
-                        // type test
-                        PropertyType spt = 
retrievePropertyType(field.get(schema).toString());
-                        String getNameProperty = "get" + 
prepareName(field.get(schema).toString(), spt) + "Property";
-                        Method getMethod = 
schemaClass.getMethod(getNameProperty);
-                        assertNull(getMethod.invoke(schema), getNameProperty + 
" should return null when testing " + property);
-                        // value test
-                        String getNameValue = "get" + 
prepareName(field.get(schema).toString(), spt);
-                        if (schemaClass == XMPMediaManagementSchema.class && 
"getHistory".equals(getNameValue))
-                        {
-                            // PDFBOX-6111: getHistory() has been removed 
because it doesn't work
-                            // because it's an array of a structured type and 
not of a text value
-                            continue;
-                        }
-                        getMethod = schemaClass.getMethod(getNameValue);
-                        assertNotNull(getMethod, getNameValue + " method 
should exist");
-                        assertNull(getMethod.invoke(schema), getNameValue + " 
should return null when testing " + property);
+                        // PDFBOX-6111: getHistory() has been removed because 
it doesn't work
+                        // because it's an array of a structured type and not 
of a text value
+                        continue;
                     }
+                    getMethod = schemaClass.getMethod(getNameValue);
+                    assertNotNull(getMethod, getNameValue + " method should 
exist");
+                    assertNull(getMethod.invoke(schema), getNameValue + " 
should return null when testing " + property);
                 }
             }
         }

Reply via email to