Search in sources :

Example 6 with TemplateId

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

the class EncoderTest method decodeTemplateIds.

/**
 * decodeTemplateIds for each TemplateId in the list ensure that it exists in
 * the registry.
 * @throws Exception
 */
@Test
void decodeTemplateIds() throws Exception {
    Registry<OutputEncoder> registry = new Registry<>(new Context(), Encoder.class);
    for (TemplateId templateId : templateIds) {
        OutputEncoder encoder = registry.get(templateId);
        assertWithMessage(templateId + " returned node should not be null").that(encoder).isNotNull();
    }
}
Also used : Context(gov.cms.qpp.conversion.Context) Registry(gov.cms.qpp.conversion.model.Registry) TemplateId(gov.cms.qpp.conversion.model.TemplateId) Test(org.junit.jupiter.api.Test)

Example 7 with TemplateId

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

the class DecoderTest method decodeTemplateIds.

@Test
void decodeTemplateIds() throws Exception {
    Registry<QrdaDecoder> registry = new Registry<>(new Context(), Decoder.class);
    for (TemplateId templateId : templateIds) {
        QrdaDecoder decoder = registry.get(templateId);
        assertWithMessage("%s returned node should not be null", templateId.name()).that(decoder).isNotNull();
    }
}
Also used : Context(gov.cms.qpp.conversion.Context) Registry(gov.cms.qpp.conversion.model.Registry) TemplateId(gov.cms.qpp.conversion.model.TemplateId) Test(org.junit.jupiter.api.Test)

Example 8 with TemplateId

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

the class Checker method onlyHasChildren.

/**
 * Verifies that the target node contains only children of specified template ids
 *
 * @param code that identifies the error
 * @param types types of template ids to filter
 * @return The checker, for chaining method calls.
 */
Checker onlyHasChildren(LocalizedError code, TemplateId... types) {
    if (!shouldShortcut()) {
        Set<TemplateId> templateIds = EnumSet.noneOf(TemplateId.class);
        for (TemplateId templateId : types) {
            templateIds.add(templateId);
        }
        boolean valid = node.getChildNodes().stream().allMatch(childNode -> templateIds.contains(childNode.getType()));
        if (!valid) {
            details.add(detail(code));
        }
    }
    return this;
}
Also used : TemplateId(gov.cms.qpp.conversion.model.TemplateId)

Aggregations

TemplateId (gov.cms.qpp.conversion.model.TemplateId)8 Node (gov.cms.qpp.conversion.model.Node)3 Context (gov.cms.qpp.conversion.Context)2 Registry (gov.cms.qpp.conversion.model.Registry)2 Element (org.jdom2.Element)2 Test (org.junit.jupiter.api.Test)2 DecodeData (gov.cms.qpp.conversion.model.DecodeData)1 Decoder (gov.cms.qpp.conversion.model.Decoder)1 Detail (gov.cms.qpp.conversion.model.error.Detail)1