Search in sources :

Example 11 with FormattedErrorCode

use of gov.cms.qpp.conversion.model.error.FormattedErrorCode in project qpp-conversion-tool by CMSgov.

the class FormattedErrorCodeTest method testEqualsDifferentErrorCode.

@Test
void testEqualsDifferentErrorCode() {
    FormattedErrorCode o1 = new FormattedErrorCode(ErrorCode.UNEXPECTED_ERROR, "Some Message");
    FormattedErrorCode o2 = new FormattedErrorCode(ErrorCode.ACI_NUMERATOR_DENOMINATOR_MISSING_MEASURE_ID, "Some Message");
    Truth.assertThat(o1).isNotEqualTo(o2);
}
Also used : FormattedErrorCode(gov.cms.qpp.conversion.model.error.FormattedErrorCode) Test(org.junit.jupiter.api.Test)

Example 12 with FormattedErrorCode

use of gov.cms.qpp.conversion.model.error.FormattedErrorCode in project qpp-conversion-tool by CMSgov.

the class CheckerTest method testCheckerHasMeasuresShortCut.

@Test
void testCheckerHasMeasuresShortCut() {
    Set<Detail> errors = new LinkedHashSet<>();
    Detail err = new Detail();
    err.setMessage("test");
    errors.add(err);
    Node root = new Node();
    Checker.check(root, errors).hasMeasures(ERROR_MESSAGE, "MeasureId");
    assertWithMessage("Checker should return one validation error").that(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsExactly(new FormattedErrorCode(null, "test"));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) FormattedErrorCode(gov.cms.qpp.conversion.model.error.FormattedErrorCode) Node(gov.cms.qpp.conversion.model.Node) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 13 with FormattedErrorCode

use of gov.cms.qpp.conversion.model.error.FormattedErrorCode in project qpp-conversion-tool by CMSgov.

the class QualityMeasureSectionValidatorTest method duplicateEcqMeasure.

@Test
void duplicateEcqMeasure() {
    List<Detail> errorDetails = manipulatorHandler.executeScenario(MEASURE_REFERENCE_RESULTS_CMS_V2.name(), "measureId", false);
    assertThat(errorDetails).comparingElementsUsing(DetailsErrorEquals.INSTANCE).contains(new FormattedErrorCode(ErrorCode.MEASURE_GUID_MISSING, ErrorCode.MEASURE_GUID_MISSING.getMessage()));
}
Also used : FormattedErrorCode(gov.cms.qpp.conversion.model.error.FormattedErrorCode) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 14 with FormattedErrorCode

use of gov.cms.qpp.conversion.model.error.FormattedErrorCode in project qpp-conversion-tool by CMSgov.

the class ConverterTest method testValidationErrors.

@Test
@PrepareForTest({ Converter.class, QrdaValidator.class })
public void testValidationErrors() throws Exception {
    Context context = new Context();
    context.setDoDefaults(true);
    TestHelper.mockDecoder(context, JennyDecoder.class, new ComponentKey(TemplateId.DEFAULT, Program.ALL));
    QrdaValidator mockQrdaValidator = TestHelper.mockValidator(context, TestDefaultValidator.class, new ComponentKey(TemplateId.DEFAULT, Program.ALL), true);
    PowerMockito.whenNew(QrdaValidator.class).withAnyArguments().thenReturn(mockQrdaValidator);
    Path path = Paths.get("src/test/resources/converter/errantDefaultedNode.xml");
    Converter converter = new Converter(new PathSource(path), context);
    try {
        converter.transform();
        fail("The converter should not create valid QPP JSON");
    } catch (TransformException exception) {
        AllErrors allErrors = exception.getDetails();
        List<Error> errors = allErrors.getErrors();
        assertWithMessage("There must only be one error source.").that(errors).hasSize(1);
        List<Detail> details = errors.get(0).getDetails();
        assertWithMessage("The expected validation error was missing").that(details).comparingElementsUsing(DetailsErrorEquals.INSTANCE).contains(new FormattedErrorCode(ErrorCode.UNEXPECTED_ERROR, "Test validation error for Jenny"));
    }
}
Also used : Path(java.nio.file.Path) QrdaValidator(gov.cms.qpp.conversion.validate.QrdaValidator) FormattedErrorCode(gov.cms.qpp.conversion.model.error.FormattedErrorCode) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) ComponentKey(gov.cms.qpp.conversion.model.ComponentKey) TransformException(gov.cms.qpp.conversion.model.error.TransformException) List(java.util.List) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

FormattedErrorCode (gov.cms.qpp.conversion.model.error.FormattedErrorCode)14 Test (org.junit.jupiter.api.Test)13 Detail (gov.cms.qpp.conversion.model.error.Detail)3 ComponentKey (gov.cms.qpp.conversion.model.ComponentKey)1 Node (gov.cms.qpp.conversion.model.Node)1 AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)1 TransformException (gov.cms.qpp.conversion.model.error.TransformException)1 QrdaValidator (gov.cms.qpp.conversion.validate.QrdaValidator)1 Path (java.nio.file.Path)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1