use of gov.cms.qpp.conversion.model.error.Detail in project qpp-conversion-tool by CMSgov.
the class AciNumeratorValidatorTest method noChildrenTest.
@Test
void noChildrenTest() {
Node aciNumeratorNode = new Node(TemplateId.ACI_NUMERATOR);
AciNumeratorValidator validator = new AciNumeratorValidator();
Set<Detail> errors = validator.validateSingleNode(aciNumeratorNode);
assertWithMessage("Should result in Children Validation Error").that(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsExactly(ErrorCode.NUMERATOR_DENOMINATOR_MISSING_CHILDREN.format(AciNumeratorValidator.NUMERATOR_NAME));
}
use of gov.cms.qpp.conversion.model.error.Detail in project qpp-conversion-tool by CMSgov.
the class AciNumeratorValidatorTest method tooManyChildrenTest.
@Test
void tooManyChildrenTest() {
Node aciNumeratorNode = new Node(TemplateId.ACI_NUMERATOR);
Node aggregateCountNode1 = new Node(TemplateId.ACI_AGGREGATE_COUNT);
Node aggregateCountNode2 = new Node(TemplateId.ACI_AGGREGATE_COUNT);
aggregateCountNode1.putValue("aggregateCount", "100");
aggregateCountNode2.putValue("aggregateCount", "200");
aciNumeratorNode.addChildNode(aggregateCountNode1);
aciNumeratorNode.addChildNode(aggregateCountNode2);
AciNumeratorValidator validator = new AciNumeratorValidator();
Set<Detail> errors = validator.validateSingleNode(aciNumeratorNode);
assertWithMessage("Too many children Validation Error not issued").that(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsExactly(ErrorCode.NUMERATOR_DENOMINATOR_CHILD_EXACT.format(AciNumeratorValidator.NUMERATOR_NAME));
}
use of gov.cms.qpp.conversion.model.error.Detail in project qpp-conversion-tool by CMSgov.
the class AciNumeratorValidatorTest method invalidValueNaNTest.
@Test
void invalidValueNaNTest() {
// Not a number check
Node aciNumeratorNode = new Node(TemplateId.ACI_NUMERATOR);
Node aggregateCountNode = new Node(TemplateId.ACI_AGGREGATE_COUNT);
String value = "not a number";
aggregateCountNode.putValue("aggregateCount", value);
aciNumeratorNode.addChildNode(aggregateCountNode);
AciNumeratorValidator validator = new AciNumeratorValidator();
Set<Detail> errors = validator.validateSingleNode(aciNumeratorNode);
assertWithMessage("Validation error size should be 1 because this will be caught by the aggregate count validator.").that(errors).hasSize(1);
}
use of gov.cms.qpp.conversion.model.error.Detail in project qpp-conversion-tool by CMSgov.
the class AciNumeratorValidatorTest method validateNumeratorWithValue.
private void validateNumeratorWithValue(String value) {
Node aciNumeratorNode = new Node(TemplateId.ACI_NUMERATOR);
Node aggregateCountNode = new Node(TemplateId.ACI_AGGREGATE_COUNT);
aggregateCountNode.putValue("aggregateCount", value);
aciNumeratorNode.addChildNode(aggregateCountNode);
AciNumeratorValidator validator = new AciNumeratorValidator();
Set<Detail> errors = validator.validateSingleNode(aciNumeratorNode);
assertWithMessage("no errors should be present").that(errors).isEmpty();
}
use of gov.cms.qpp.conversion.model.error.Detail in project qpp-conversion-tool by CMSgov.
the class JsonOutputEncoder method encode.
@Override
public void encode(Writer writer) {
try {
JsonWrapper wrapper = new JsonWrapper();
for (Node curNode : nodes) {
encode(wrapper, curNode);
}
writer.write(wrapper.toString());
writer.flush();
} catch (IOException exception) {
DEV_LOG.error("Couldn't write out JSON file.", exception);
Detail detail = Detail.forErrorCode(ErrorCode.UNEXPECTED_ENCODE_ERROR);
detail.setMessage(exception.getMessage());
details.add(detail);
}
}
Aggregations