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

pkiraly / metadata-qa-api / #742

14 Jan 2026 12:45PM UTC coverage: 85.581% (-0.6%) from 86.157%
#742

push

pkiraly
Add parent check

32 of 96 new or added lines in 7 files covered. (33.33%)

2 existing lines in 2 files now uncovered.

5686 of 6644 relevant lines covered (85.58%)

0.86 hits per line

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

70.59
/src/main/java/de/gwdg/metadataqa/api/rule/singlefieldchecker/DependencyChecker.java
1
package de.gwdg.metadataqa.api.rule.singlefieldchecker;
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
import java.util.Map;
13
import java.util.logging.Logger;
14

15
public class DependencyChecker extends SingleFieldChecker {
16

17
  public static final String PREFIX = "dependency";
18
  protected List<String> dependencies;
19
  private RuleCheckingOutputStatus failedDepencencyStatus;
20
  private Boolean isParentCheck = false;
1✔
21

22
  private static final Logger LOGGER = Logger.getLogger(DependencyChecker.class.getCanonicalName());
1✔
23

24
  public DependencyChecker(DataElement field, List<String> dependencies) {
25
    this(field, field.getLabel(), dependencies, RuleCheckingOutputStatus.FAILED);
1✔
26
  }
1✔
27

28
  public DependencyChecker(DataElement field,
29
                           List<String> dependencies,
30
                           RuleCheckingOutputStatus failedDepencencyStatus) {
31
    this(field, field.getLabel(), dependencies, failedDepencencyStatus);
×
32
  }
×
33

34
  public DependencyChecker(DataElement field,
35
                           String header,
36
                           List<String> dependencies,
37
                           RuleCheckingOutputStatus failedDepencencyStatus) {
38
    super(field, header + ":" + PREFIX);
1✔
39
    this.dependencies = dependencies;
1✔
40
    this.failedDepencencyStatus = failedDepencencyStatus;
1✔
41
  }
1✔
42

43
  @Override
44
  public void update(Selector selector, FieldCounter<RuleCheckerOutput> results, RuleCheckingOutputType outputType) {
45
    update(selector, results, outputType, null);
×
46
  }
×
47

48
  public void update(Selector cache,
49
                     FieldCounter<RuleCheckerOutput> localResults,
50
                     RuleCheckingOutputType outputType,
51
                     FieldCounter<RuleCheckerOutput> globalResults) {
52
    if (isDebug())
1✔
53
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ", dependencies: " + getDependencies());
×
54

55
    if (globalResults == null) {
1✔
56
      globalResults = localResults;
×
57
    }
58

59
    var isNA = true;
1✔
60
    var allPassed = true;
1✔
61
    List<XmlFieldInstance> instances = cache.get(field);
1✔
62
    if (instances != null && !instances.isEmpty()) {
1✔
63
      for (XmlFieldInstance instance : instances) {
1✔
64
        isNA = false;
1✔
65
      }
1✔
66
    }
67
    Map<String, Boolean> result = getResult(outputType, globalResults);
1✔
68
    allPassed = result.get("allPassed");
1✔
69
    isNA = result.get("isNA");
1✔
70

71
    addOutput(localResults, isNA, allPassed, outputType);
1✔
72
    if (isDebug())
1✔
73
      LOGGER.info(String.format("%s %s) result: %s [isNA: %s, allPassed: %s, isMandatory: %s]", this.getClass().getSimpleName(), this.id, RuleCheckingOutputStatus.create(isNA, allPassed, isMandatory()), isNA, allPassed, isMandatory()));
×
74
  }
1✔
75

76
  public List<String> getDependencies() {
77
    return dependencies;
×
78
  }
79

80
  public Map<String, Boolean> getResult(RuleCheckingOutputType outputType,
81
                                        FieldCounter<RuleCheckerOutput> globalResults) {
82
    boolean allPassed = true;
1✔
83
    boolean isNA = true;
1✔
84
    for (String ruleId : dependencies) {
1✔
85
      String outputKey = outputType.equals(RuleCheckingOutputType.BOTH) ? ruleId + ":status" : ruleId;
1✔
86
      if (globalResults.has(outputKey)) {
1✔
87
        var status = globalResults.get(outputKey).getStatus();
1✔
88
        if (!status.equals(RuleCheckingOutputStatus.PASSED))
1✔
89
          allPassed = false;
1✔
90
        if (!status.equals(RuleCheckingOutputStatus.NA))
1✔
91
          isNA = false;
1✔
92
      } else {
1✔
93
        LOGGER.warning(String.format("Referenced rule (ids: %s->%s) is missing (key: %s)", getId(), ruleId, outputKey));
×
94
        LOGGER.warning("globalResults: " + globalResults.getMap());
×
95
        allPassed = false;
×
96
        break;
×
97
      }
98
    }
1✔
99
    return Map.of("allPassed", allPassed, "isNA", isNA);
1✔
100
  }
101

102
  public Boolean getParentCheck() {
NEW
103
    return isParentCheck;
×
104
  }
105

106
  public void setParentCheck(Boolean parentCheck) {
NEW
107
    isParentCheck = parentCheck;
×
NEW
108
  }
×
109
}
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