• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pkiraly / metadata-qa-api / #654

16 Apr 2025 12:29PM UTC coverage: 87.241% (+0.008%) from 87.233%
#654

push

pkiraly
Handle anyOf scope in EqualityChecker

3 of 4 new or added lines in 1 file covered. (75.0%)

5525 of 6333 relevant lines covered (87.24%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.85
/src/main/java/de/gwdg/metadataqa/api/rule/pairchecker/EqualityChecker.java
1
package de.gwdg.metadataqa.api.rule.pairchecker;
2

3
import de.gwdg.metadataqa.api.counter.FieldCounter;
4
import de.gwdg.metadataqa.api.json.DataElement;
5
import de.gwdg.metadataqa.api.model.XmlFieldInstance;
6
import de.gwdg.metadataqa.api.model.selector.Selector;
7
import de.gwdg.metadataqa.api.rule.RuleCheckerOutput;
8
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputStatus;
9
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputType;
10

11
import java.util.List;
12

13
public class EqualityChecker extends PropertyPairChecker {
14

15
  private static final long serialVersionUID = -5363342097255677979L;
16
  public static final String PREFIX = "equals";
17
  protected String fixedValue;
18

19
  public EqualityChecker(DataElement field1, DataElement field2) {
20
    super(field1, field2, PREFIX);
1✔
21
  }
1✔
22

23
  @Override
24
  public void update(Selector cache, FieldCounter<RuleCheckerOutput> results, RuleCheckingOutputType outputType) {
25
    if (isDebug())
1✔
26
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id);
×
27

28
    var allPassed = true;
1✔
29
    var isNA = true;
1✔
30
    int matches = 0;
1✔
31
    List<XmlFieldInstance> instances1 = cache.get(field1.getAbsolutePath().replace("[*]", ""));
1✔
32
    List<XmlFieldInstance> instances2 = cache.get(field2.getAbsolutePath().replace("[*]", ""));
1✔
33
    if (instances1 != null && !instances1.isEmpty() && instances2 != null && !instances2.isEmpty()) {
1✔
34
      for (XmlFieldInstance instance1 : instances1) {
1✔
35
        isNA = false;
1✔
36
        if (instance1.hasValue()) {
1✔
37
          boolean hasValue2 = false;
1✔
38
          for (XmlFieldInstance instance2 : instances2) {
1✔
39
            if (isDebug())
1✔
40
              LOGGER.info(String.format("%s %s values: '%s' vs '%s'", this.getClass().getSimpleName(), this.id, instance1.getValue(), instance2.getValue()));
×
41
            if (instance2.hasValue()) {
1✔
42
              hasValue2 = true;
1✔
43
              if (!instance1.getValue().equals(instance2.getValue())) {
1✔
44
                allPassed = false;
1✔
45
                break;
1✔
46
              } else {
47
                matches++;
1✔
48
              }
49
            }
50
            if (!hasValue2)
1✔
51
              isNA = true;
×
52
          }
1✔
53
        }
54
      }
1✔
55
    }
56
    if (scopeIsAnyOf() && !isNA && matches > 0)
1✔
NEW
57
      allPassed = true;
×
58
    addOutput(results, isNA, allPassed, outputType);
1✔
59
    if (isDebug())
1✔
60
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ") result: " + RuleCheckingOutputStatus.create(isNA, allPassed, isMandatory()));
×
61
  }
1✔
62

63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc