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

pkiraly / metadata-qa-api / #645

03 Apr 2025 10:56AM UTC coverage: 87.22% (-0.01%) from 87.234%
#645

push

pkiraly
More strict MinLengh check

2 of 4 new or added lines in 1 file covered. (50.0%)

1 existing line in 1 file now uncovered.

5453 of 6252 relevant lines covered (87.22%)

0.87 hits per line

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

82.76
/src/main/java/de/gwdg/metadataqa/api/rule/singlefieldchecker/MinLengthChecker.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

13
public class MinLengthChecker extends SingleFieldChecker {
14

15
  private static final long serialVersionUID = -1842497411816592850L;
16
  public static final String PREFIX = "minLength";
17
  protected Integer minLength;
18

19
  public MinLengthChecker(DataElement field, Integer minLength) {
20
    this(field, field.getLabel(), minLength);
1✔
21
  }
1✔
22

23
  public MinLengthChecker(DataElement field, String header, Integer minLength) {
24
    super(field, header + ":" + PREFIX);
1✔
25
    this.minLength = minLength;
1✔
26
  }
1✔
27

28
  @Override
29
  public void update(Selector cache, FieldCounter<RuleCheckerOutput> results, RuleCheckingOutputType outputType) {
30
    if (isDebug())
1✔
31
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id);
×
32

33
    var isNA = true;
1✔
34
    boolean hasFailed = false;
1✔
35
    int passCount = 0;
1✔
36
    List<XmlFieldInstance> instances = cache.get(field);
1✔
37
    if (instances != null && !instances.isEmpty()) {
1✔
38
      for (XmlFieldInstance instance : instances) {
1✔
39
        isNA = false;
1✔
40
        if (instance.hasValue()) {
1✔
41
          if (isDebug())
1✔
UNCOV
42
            LOGGER.info("value: " + instance.getValue());
×
43
          if (instance.getValue().length() < minLength) {
1✔
44
            hasFailed = true;
1✔
45
          } else {
46
            passCount++;
1✔
47
          }
48
        } else {
NEW
49
          hasFailed = true;
×
50
        }
51
        if (hasFailed && scopeIsAllOf())
1✔
NEW
52
          break;
×
53
      }
1✔
54
    }
55
    boolean allPassed = isPassed(passCount, hasFailed);
1✔
56
    addOutput(results, isNA, allPassed, outputType);
1✔
57
    if (isDebug())
1✔
58
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ") result: " + RuleCheckingOutputStatus.create(isNA, allPassed, isMandatory()));
×
59
  }
1✔
60
}
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