Search in sources :

Example 1 with ComponentKey

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

the class QrdaDecoderEngineTest method mockDecoders.

@BeforeAll
static void mockDecoders() {
    context = new Context();
    TestHelper.mockDecoder(context, TestChildContinue.class, new ComponentKey(TemplateId.ACI_SECTION, Program.ALL));
    TestHelper.mockDecoder(context, TestChildFinish.class, new ComponentKey(TemplateId.IA_SECTION, Program.ALL));
    TestHelper.mockDecoder(context, TestChildEscape.class, new ComponentKey(TemplateId.MEASURE_SECTION_V2, Program.ALL));
}
Also used : Context(gov.cms.qpp.conversion.Context) ComponentKey(gov.cms.qpp.conversion.model.ComponentKey) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with ComponentKey

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

the class QrdaValidatorTest method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    nodesPassedIntoValidateSingleNode = new ArrayList<>();
    Context context = new Context();
    objectUnderTest = TestHelper.mockValidator(context, RequiredTestValidator.class, new ComponentKey(TEST_REQUIRED_TEMPLATE_ID, Program.ALL), true);
    objectUnderTest = TestHelper.mockValidator(context, OptionalTestValidator.class, new ComponentKey(TEST_OPTIONAL_TEMPLATE_ID, Program.ALL), false, objectUnderTest);
}
Also used : Context(gov.cms.qpp.conversion.Context) ComponentKey(gov.cms.qpp.conversion.model.ComponentKey) Before(org.junit.Before)

Example 3 with ComponentKey

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

the class ConverterTest method testDefaults.

@Test
public void testDefaults() {
    Context context = new Context();
    context.setDoDefaults(true);
    context.setDoValidation(false);
    TestHelper.mockDecoder(context, JennyDecoder.class, new ComponentKey(TemplateId.DEFAULT, Program.ALL));
    TestHelper.mockEncoder(context, Jenncoder.class, new ComponentKey(TemplateId.DEFAULT, Program.ALL));
    Converter converter = new Converter(new PathSource(Paths.get("src/test/resources/converter/defaultedNode.xml")), context);
    JsonWrapper qpp = converter.transform();
    String content = qpp.toString();
    assertThat(content).contains("Jenny");
}
Also used : JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper) ComponentKey(gov.cms.qpp.conversion.model.ComponentKey) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with ComponentKey

use of gov.cms.qpp.conversion.model.ComponentKey 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

ComponentKey (gov.cms.qpp.conversion.model.ComponentKey)4 Context (gov.cms.qpp.conversion.Context)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 JsonWrapper (gov.cms.qpp.conversion.encode.JsonWrapper)1 AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)1 FormattedErrorCode (gov.cms.qpp.conversion.model.error.FormattedErrorCode)1 TransformException (gov.cms.qpp.conversion.model.error.TransformException)1 QrdaValidator (gov.cms.qpp.conversion.validate.QrdaValidator)1 Path (java.nio.file.Path)1 List (java.util.List)1 Before (org.junit.Before)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1