Search in sources :

Example 16 with JsonWrapper

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

the class QrdaControllerV1Test method initialization.

@BeforeEach
void initialization() throws IOException {
    JsonWrapper wrapper = new JsonWrapper();
    wrapper.putString("key", "Good Qpp");
    when(report.getEncoded()).thenReturn(wrapper);
    multipartFile = new MockMultipartFile(GOOD_FILE_CONTENT, new ByteArrayInputStream(GOOD_FILE_CONTENT.getBytes()));
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper) ByteArrayInputStream(java.io.ByteArrayInputStream) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 17 with JsonWrapper

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

the class DefaultEncoderTest method encodeDefaultNode.

@Test
void encodeDefaultNode() throws EncodeException {
    Node root = new Node(TemplateId.DEFAULT);
    Node placeHolder = new Node(TemplateId.PLACEHOLDER, root);
    root.addChildNode(placeHolder);
    JsonWrapper wrapper = new JsonWrapper();
    new DefaultEncoder("Default Encode test").internalEncode(wrapper, root);
    assertThat(wrapper.toString()).hasLength(3);
}
Also used : JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 18 with JsonWrapper

use of gov.cms.qpp.conversion.encode.JsonWrapper 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 19 with JsonWrapper

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

the class ConverterTest method testSkipDefaults.

@Test
public void testSkipDefaults() {
    Converter converter = new Converter(new PathSource(Paths.get("src/test/resources/converter/defaultedNode.xml")));
    converter.getContext().setDoDefaults(false);
    converter.getContext().setDoValidation(false);
    JsonWrapper qpp = converter.transform();
    String content = qpp.toString();
    assertThat(content).doesNotContain("Jenny");
}
Also used : JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 20 with JsonWrapper

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

the class ScopedConversionTest method scopedConversion.

@SuppressWarnings("unchecked")
private Map<String, Object> scopedConversion(QrdaScope testSection) {
    Converter converter = new Converter(new PathSource(Paths.get(SUCCESS_MAKER)));
    converter.getContext().setScope(Sets.newHashSet(testSection));
    JsonWrapper qpp = converter.transform();
    return JsonHelper.readJson(qpp.toString(), HashMap.class);
}
Also used : JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper)

Aggregations

JsonWrapper (gov.cms.qpp.conversion.encode.JsonWrapper)24 Test (org.junit.jupiter.api.Test)10 Converter (gov.cms.qpp.conversion.Converter)9 PathSource (gov.cms.qpp.conversion.PathSource)8 Node (gov.cms.qpp.conversion.model.Node)3 Map (java.util.Map)3 Path (java.nio.file.Path)2 Test (org.junit.Test)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 JsonPath (com.jayway.jsonpath.JsonPath)1 JsonPathAggregator (gov.cms.qpp.acceptance.helper.JsonPathAggregator)1 JsonPathToXpathHelper (gov.cms.qpp.acceptance.helper.JsonPathToXpathHelper)1 Context (gov.cms.qpp.conversion.Context)1 ConversionReport (gov.cms.qpp.conversion.ConversionReport)1 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)1 XmlInputFileException (gov.cms.qpp.conversion.decode.XmlInputFileException)1 EncodeException (gov.cms.qpp.conversion.encode.EncodeException)1 JsonOutputEncoder (gov.cms.qpp.conversion.encode.JsonOutputEncoder)1