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

pkiraly / metadata-qa-api / #729

13 Oct 2025 08:23PM UTC coverage: 86.412% (-0.03%) from 86.443%
#729

push

web-flow
Merge pull request #268 from pkiraly/dependabot/maven/org.apache.commons-commons-lang3-3.19.0

build(deps): bump org.apache.commons:commons-lang3 from 3.18.0 to 3.19.0

5660 of 6550 relevant lines covered (86.41%)

0.86 hits per line

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

86.84
/src/main/java/de/gwdg/metadataqa/api/rule/singlefieldchecker/ImageDimensionChecker.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
import de.gwdg.metadataqa.api.configuration.schema.Dimension;
11
import de.gwdg.metadataqa.api.util.DimensionDao;
12
import de.gwdg.metadataqa.api.util.ImageDimensionExtractor;
13

14
import java.io.IOException;
15
import java.util.List;
16
import java.util.logging.Logger;
17

18
public class ImageDimensionChecker extends SingleFieldChecker {
19

20
  public static final String PREFIX = "imageDimension";
21
  protected Dimension dimensionRule;
22

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

25
  public ImageDimensionChecker(DataElement field, Dimension dimension) {
26
    this(field, field.getLabel(), dimension);
1✔
27
  }
1✔
28

29
  public ImageDimensionChecker(DataElement field, String header, Dimension dimension) {
30
    super(field, header + ":" + PREFIX);
1✔
31
    this.dimensionRule = dimension;
1✔
32
  }
1✔
33

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

39
    var allPassed = true;
1✔
40
    var isNA = true;
1✔
41
    List<XmlFieldInstance> instances = selector.get(field);
1✔
42
    if (instances != null && !instances.isEmpty()) {
1✔
43
      for (XmlFieldInstance instance : instances) {
1✔
44
        if (instance.hasValue()) {
1✔
45
          isNA = false;
1✔
46
          try {
47
            if (isDebug())
1✔
48
              LOGGER.info("value: " + instance.getValue());
×
49
            DimensionDao dimension = ImageDimensionExtractor.extractRemote(instance.getValue());
1✔
50
            if (dimension == null
1✔
51
              || (dimensionRule.getMinWidth()  != null && dimension.getWidth()  < dimensionRule.getMinWidth())
1✔
52
              || (dimensionRule.getMaxWidth()  != null && dimension.getWidth()  > dimensionRule.getMaxWidth())
1✔
53
              || (dimensionRule.getMinHeight() != null && dimension.getHeight() < dimensionRule.getMinHeight())
1✔
54
              || (dimensionRule.getMaxHeight() != null && dimension.getHeight() > dimensionRule.getMaxHeight())
1✔
55
              || (dimensionRule.getMinShortside()  != null && dimension.getShort()  < dimensionRule.getMinShortside())
1✔
56
              || (dimensionRule.getMaxShortside()  != null && dimension.getShort()  > dimensionRule.getMaxShortside())
1✔
57
              || (dimensionRule.getMinLongside()   != null && dimension.getLong()   < dimensionRule.getMinLongside())
1✔
58
              || (dimensionRule.getMaxLongside()   != null && dimension.getLong()   > dimensionRule.getMaxLongside())
1✔
59
            ) {
60
              allPassed = false;
1✔
61
            }
62
          } catch (IOException e) {
×
63
            allPassed = false;
×
64
          }
1✔
65
          if (!allPassed)
1✔
66
            break;
1✔
67
        }
68
      }
1✔
69
    }
70

71
    addOutput(results, isNA, allPassed, outputType);
1✔
72
    if (isDebug())
1✔
73
      LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ") result: " + RuleCheckingOutputStatus.create(isNA, allPassed, isMandatory()));
×
74
  }
1✔
75
}
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