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

pkiraly / metadata-qa-api / #634

13 Mar 2025 08:06PM UTC coverage: 87.186% (-0.1%) from 87.296%
#634

push

pkiraly
Fix dependency checker #223

20 of 74 new or added lines in 11 files covered. (27.03%)

1 existing line in 1 file now uncovered.

5375 of 6165 relevant lines covered (87.19%)

0.87 hits per line

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

89.66
/src/main/java/de/gwdg/metadataqa/api/rule/singlefieldchecker/HasChildrenChecker.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.model.selector.XmlSelector;
8
import de.gwdg.metadataqa.api.rule.RuleCheckerOutput;
9
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputStatus;
10
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputType;
11
import org.w3c.dom.Node;
12

13
import java.util.List;
14

15
public class HasChildrenChecker extends SingleFieldChecker {
16

17
  private static final long serialVersionUID = 1114999259831619599L;
18
  public static final String PREFIX = "hasValue";
19
  protected List<String> children;
20

21
  /**
22
   * @param field The field
23
   * @param children The list of children (XPath)
24
   */
25
  public HasChildrenChecker(DataElement field, List<String> children) {
26
    this(field, field.getLabel(), children);
1✔
27
  }
1✔
28

29
  public HasChildrenChecker(DataElement field, String header, List<String> children) {
30
    super(field, header + ":" + PREFIX);
1✔
31
    this.children = children;
1✔
32
  }
1✔
33

34
  @Override
35
  public void update(Selector cache, FieldCounter<RuleCheckerOutput> results, RuleCheckingOutputType outputType) {
36
    if (isDebug())
1✔
NEW
37
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id + " field: " + field.getLabel());
×
38

39
    var allPassed = false;
1✔
40
    var isNA = true;
1✔
41
    if (cache.getClass().equals(XmlSelector.class)) {
1✔
42
      List<Node> nodes = (List<Node>) cache.getFragment(field.getPath());
1✔
43
      if (!nodes.isEmpty()) {
1✔
44
        isNA = false;
1✔
45
        for (Node node : nodes) {
1✔
46
          for (String childPath : children) {
1✔
47
            List values = cache.get(childPath, childPath, node);
1✔
48
            if (values.isEmpty()) {
1✔
49
              allPassed = false;
1✔
50
              break;
1✔
51
            } else {
52
              allPassed = true;
1✔
53
            }
54
          }
1✔
55
          if (!allPassed)
1✔
56
            break;
1✔
57
        }
1✔
58
      } else {
NEW
59
        allPassed = true;
×
60
      }
61
    }
62
    addOutput(results, isNA, allPassed, outputType);
1✔
63
    if (isDebug())
1✔
64
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ") result: " + RuleCheckingOutputStatus.create(isNA, allPassed));
×
65
  }
1✔
66

67
}
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