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

pkiraly / metadata-qa-api / #692

04 Jun 2025 11:56AM UTC coverage: 86.93% (-0.3%) from 87.231%
#692

push

pkiraly
Merge branch 'main' of github.com:pkiraly/metadata-qa-api

5547 of 6381 relevant lines covered (86.93%)

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/singlefieldchecker/MinCountChecker.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.selector.Selector;
6
import de.gwdg.metadataqa.api.rule.RuleCheckerOutput;
7
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputStatus;
8
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputType;
9
import de.gwdg.metadataqa.api.util.InstanceCounter;
10

11
public class MinCountChecker extends SingleFieldChecker {
12

13
  private static final long serialVersionUID = 2298498693779624776L;
14
  public static final String PREFIX = "minCount";
15
  protected Integer minCount;
16
  protected boolean allowEmptyInstances = false;
1✔
17

18
  public MinCountChecker(DataElement field, Integer minCount) {
19
    this(field, field.getLabel(), minCount);
1✔
20
  }
1✔
21

22
  public MinCountChecker(DataElement field, Integer minCount, boolean allowEmptyInstances) {
23
    this(field, field.getLabel(), minCount);
1✔
24
    this.allowEmptyInstances = allowEmptyInstances;
1✔
25
  }
1✔
26

27
  public MinCountChecker(DataElement field, String header, Integer minCount) {
28
    super(field, header + ":" + PREFIX);
1✔
29
    this.minCount = minCount;
1✔
30
  }
1✔
31

32
  @Override
33
  public void update(Selector selector, FieldCounter<RuleCheckerOutput> results, RuleCheckingOutputType outputType) {
34
    if (isDebug())
1✔
35
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id);
1✔
36

37
    // System.err.println(selector);
38
    var allPassed = false;
1✔
39
    var counter = new InstanceCounter(selector, field, allowEmptyInstances);
1✔
40
    if (isDebug())
1✔
41
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ") number of instances: " + counter.getCount());
1✔
42
    if (counter.getCount() >= minCount)
1✔
43
      allPassed = true;
1✔
44
    else if (counter.isNA() && minCount > 0)
1✔
45
      counter.ignoreNA();
×
46

47
    addOutput(results, counter.isNA(), allPassed, outputType);
1✔
48
    if (isDebug())
1✔
49
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ") result: " + RuleCheckingOutputStatus.create(counter.isNA(), allPassed, isMandatory()));
1✔
50
  }
1✔
51

52
  public void setAllowEmptyInstances(boolean allowEmptyInstances) {
53
    this.allowEmptyInstances = allowEmptyInstances;
×
54
  }
×
55

56
  public Integer getMinCount() {
57
    return minCount;
×
58
  }
59

60
  public boolean isEmptyInstancesAllowed() {
61
    return allowEmptyInstances;
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