Search in sources :

Example 56 with Detail

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));
}
Also used : Node(gov.cms.qpp.conversion.model.Node) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 57 with Detail

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));
}
Also used : Node(gov.cms.qpp.conversion.model.Node) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 58 with Detail

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);
}
Also used : Node(gov.cms.qpp.conversion.model.Node) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 59 with Detail

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();
}
Also used : Node(gov.cms.qpp.conversion.model.Node) Detail(gov.cms.qpp.conversion.model.error.Detail)

Example 60 with Detail

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);
    }
}
Also used : Node(gov.cms.qpp.conversion.model.Node) IOException(java.io.IOException) Detail(gov.cms.qpp.conversion.model.error.Detail)

Aggregations

Detail (gov.cms.qpp.conversion.model.error.Detail)123 Test (org.junit.jupiter.api.Test)108 Node (gov.cms.qpp.conversion.model.Node)105 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)16 Converter (gov.cms.qpp.conversion.Converter)9 AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)9 TransformException (gov.cms.qpp.conversion.model.error.TransformException)9 PathSource (gov.cms.qpp.conversion.PathSource)8 ArrayList (java.util.ArrayList)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Context (gov.cms.qpp.conversion.Context)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)3 FormattedErrorCode (gov.cms.qpp.conversion.model.error.FormattedErrorCode)3 Path (java.nio.file.Path)2 LinkedHashSet (java.util.LinkedHashSet)2 InputStreamSupplierSource (gov.cms.qpp.conversion.InputStreamSupplierSource)1 JsonWrapper (gov.cms.qpp.conversion.encode.JsonWrapper)1 TemplateId (gov.cms.qpp.conversion.model.TemplateId)1