• 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

68.97
/src/main/java/de/gwdg/metadataqa/api/util/InstanceCounter.java
1
package de.gwdg.metadataqa.api.util;
2

3
import de.gwdg.metadataqa.api.json.DataElement;
4
import de.gwdg.metadataqa.api.model.XmlFieldInstance;
5
import de.gwdg.metadataqa.api.model.selector.Selector;
6

7
import java.util.List;
8

9
public class InstanceCounter {
10
  boolean isNA = true;
1✔
11
  boolean ignoreNA = false;
1✔
12
  int count = 0;
1✔
13
  private final Selector selector;
14
  private final DataElement field;
15
  private boolean allowEmptyInstances = true;
1✔
16

17
  public InstanceCounter(Selector selector, DataElement field) {
×
18
    this.selector = selector;
×
19
    this.field = field;
×
20
    count();
×
21
  }
×
22

23
  public InstanceCounter(Selector selector, DataElement field, boolean allowEmptyInstances) {
1✔
24
    this.selector = selector;
1✔
25
    this.field = field;
1✔
26
    this.allowEmptyInstances = allowEmptyInstances;
1✔
27
    count();
1✔
28
  }
1✔
29

30
  private void count() {
31
    List<XmlFieldInstance> instances = selector.get(field);
1✔
32
    // System.err.println(instances.size());
33
    if (instances != null && !instances.isEmpty())
1✔
34
      for (XmlFieldInstance instance : instances)
1✔
35
        if (allowEmptyInstances || instance.hasValue()) {
1✔
36
          count++;
1✔
37
          isNA = false;
1✔
38
        }
39
  }
1✔
40

41
  public boolean isNA() {
42
    if (ignoreNA)
1✔
43
      return false;
×
44
    return isNA;
1✔
45
  }
46

47
  public int getCount() {
48
    return count;
1✔
49
  }
50

51
  public void ignoreNA() {
52
    this.ignoreNA = true;
×
53
  }
×
54

55
  @Override
56
  public String toString() {
57
    return "InstanceCounter{" +
×
58
      "isNA=" + isNA +
59
      ", count=" + count +
60
      '}';
61
  }
62
}
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