Search in sources :

Example 61 with Context

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

the class TemplateIdTest method testGetTemplateIdNotHistoricalNoExtension.

@Test
void testGetTemplateIdNotHistoricalNoExtension() {
    Context context = new Context();
    context.setHistorical(false);
    assertThat(TemplateId.PLACEHOLDER.getTemplateId(context)).isEqualTo(TemplateId.PLACEHOLDER.getRoot());
}
Also used : Context(gov.cms.qpp.conversion.Context) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 62 with Context

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

the class Registry method createHandlerConstructor.

private Function<Context, Object> createHandlerConstructor(Class<?> handlerClass) throws NoSuchMethodException, IllegalAccessException {
    try {
        Constructor<?> constructor = handlerClass.getConstructor(Context.class);
        MethodHandle handle = MethodHandles.lookup().unreflectConstructor(constructor).asType(MethodType.methodType(Object.class, Context.class));
        return constructorContextArgument(handle);
    } catch (NoSuchMethodException thatsOk) {
        Constructor<?> constructor = getNoArgsConstructor(handlerClass);
        MethodHandle handle = MethodHandles.lookup().unreflectConstructor(constructor).asType(MethodType.methodType(Object.class));
        return constructorNoArgs(handle);
    }
}
Also used : Context(gov.cms.qpp.conversion.Context) Constructor(java.lang.reflect.Constructor) MethodHandle(java.lang.invoke.MethodHandle)

Example 63 with Context

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

the class MeasureDataValidatorTest method internalValidateSingleNode.

@Test
void internalValidateSingleNode() throws Exception {
    String happy = TestHelper.getFixture("measureDataHappy.xml");
    Node placeholder = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(happy));
    MeasureDataValidator validator = new MeasureDataValidator();
    Node underTest = placeholder.findFirstNode(TemplateId.MEASURE_DATA_CMS_V2);
    validator.internalValidateSingleNode(underTest);
    Set<Detail> errors = validator.getDetails();
    assertWithMessage("Expect no errors on the happy path").that(errors).isEmpty();
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 64 with Context

use of gov.cms.qpp.conversion.Context 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 65 with Context

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

the class MeasurePerformedDecoderTest method setUp.

@BeforeEach
void setUp() throws IOException {
    context = new Context();
    xmlFragment = TestHelper.getFixture("MeasurePerformed.xml");
}
Also used : Context(gov.cms.qpp.conversion.Context) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Context (gov.cms.qpp.conversion.Context)114 Test (org.junit.jupiter.api.Test)92 Node (gov.cms.qpp.conversion.model.Node)63 BufferedWriter (java.io.BufferedWriter)17 StringWriter (java.io.StringWriter)17 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)14 Element (org.jdom2.Element)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 QppOutputEncoder (gov.cms.qpp.conversion.encode.QppOutputEncoder)8 ArrayList (java.util.ArrayList)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 TemplateId (gov.cms.qpp.conversion.model.TemplateId)4 Detail (gov.cms.qpp.conversion.model.error.Detail)4 InputStream (java.io.InputStream)4 Namespace (org.jdom2.Namespace)4 Map (java.util.Map)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 Converter (gov.cms.qpp.conversion.Converter)2 PathSource (gov.cms.qpp.conversion.PathSource)2 ComponentKey (gov.cms.qpp.conversion.model.ComponentKey)2