Skip to content

Commit

Permalink
FAILED if isNA and failed
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Nov 26, 2024
1 parent 7f3d90c commit 1b0b33c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public String asString() {
* @return the output status
*/
public static RuleCheckingOutputStatus create(boolean isNA, boolean passed) {
if (isNA)
if (isNA && passed)
return NA;
else if (passed)
return PASSED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputStatus;
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputType;
import de.gwdg.metadataqa.api.rule.singlefieldchecker.DependencyChecker;
import de.gwdg.metadataqa.api.rule.singlefieldchecker.MinCountChecker;

import java.util.List;

Expand Down Expand Up @@ -53,6 +54,13 @@ public void update(Selector cache, FieldCounter<RuleCheckerOutput> results, Rule
}
} else {
isNA = true;
for (RuleChecker checker : checkers) {
if (checker instanceof MinCountChecker) {
MinCountChecker minCountChecker = (MinCountChecker) checker;
if (!minCountChecker.isEmptyInstancesAllowed() || minCountChecker.getMinCount() > 0)
allPassed = false;
}
}
}
addOutput(results, isNA, allPassed, outputType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,12 @@ else if (counter.isNA() && minCount > 0)
public void setAllowEmptyInstances(boolean allowEmptyInstances) {
this.allowEmptyInstances = allowEmptyInstances;
}

public Integer getMinCount() {
return minCount;
}

public boolean isEmptyInstancesAllowed() {
return allowEmptyInstances;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void testAsString() {
@Test
public void testCreate() {
assertEquals(RuleCheckingOutputStatus.NA, RuleCheckingOutputStatus.create(true, true));
assertEquals(RuleCheckingOutputStatus.NA, RuleCheckingOutputStatus.create(true, false));
assertEquals(RuleCheckingOutputStatus.FAILED, RuleCheckingOutputStatus.create(true, false));
assertEquals(RuleCheckingOutputStatus.PASSED, RuleCheckingOutputStatus.create(false, true));
assertEquals(RuleCheckingOutputStatus.FAILED, RuleCheckingOutputStatus.create(false, false));
}
Expand All @@ -45,7 +45,7 @@ public void negate_failed() {
@Test
public void negate_NA() {
RuleCheckingOutputStatus type = RuleCheckingOutputStatus.create(true, false);
assertEquals(RuleCheckingOutputStatus.NA, type);
assertEquals(RuleCheckingOutputStatus.FAILED, type.negate());
assertEquals(RuleCheckingOutputStatus.FAILED, type);
assertEquals(RuleCheckingOutputStatus.PASSED, type.negate());
}
}

0 comments on commit 1b0b33c

Please sign in to comment.