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));
}
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);
}
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");
}
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"));
}
}
Aggregations