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

pkiraly / metadata-qa-api / #644

03 Apr 2025 09:28AM UTC coverage: 87.234% (-0.2%) from 87.454%
#644

push

pkiraly
Add mandatory and scope as generic rule properties #225

70 of 87 new or added lines in 12 files covered. (80.46%)

6 existing lines in 4 files now uncovered.

5453 of 6251 relevant lines covered (87.23%)

0.87 hits per line

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

85.19
/src/main/java/de/gwdg/metadataqa/api/rule/pairchecker/DisjointChecker.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 DisjointChecker extends PropertyPairChecker {
14

15
  private static final long serialVersionUID = -2921501305139849002L;
16
  public static final String PREFIX = "disjoint";
17

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

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

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