|
| 1 | +package gov.cms.qpp.conversion.validate; |
| 2 | + |
| 3 | +import static com.google.common.truth.Truth.assertWithMessage; |
| 4 | + |
| 5 | +import java.util.List; |
| 6 | + |
| 7 | +import org.junit.jupiter.api.BeforeEach; |
| 8 | +import org.junit.jupiter.api.Test; |
| 9 | + |
| 10 | +import gov.cms.qpp.conversion.model.Node; |
| 11 | +import gov.cms.qpp.conversion.model.TemplateId; |
| 12 | +import gov.cms.qpp.conversion.model.error.Detail; |
| 13 | +import gov.cms.qpp.conversion.model.error.ProblemCode; |
| 14 | +import gov.cms.qpp.conversion.model.error.correspondence.DetailsErrorEquals; |
| 15 | + |
| 16 | +class SspClinicalDocumentValidatorTest { |
| 17 | + |
| 18 | + private Node clinicalDocumentNode; |
| 19 | + private Node measureSectionNode; |
| 20 | + |
| 21 | + @BeforeEach |
| 22 | + void setUp() { |
| 23 | + clinicalDocumentNode = new Node(TemplateId.CLINICAL_DOCUMENT); |
| 24 | + clinicalDocumentNode.putValue("programName", "SSP"); |
| 25 | + |
| 26 | + measureSectionNode = new Node(TemplateId.MEASURE_SECTION_V5); |
| 27 | + } |
| 28 | + |
| 29 | + @Test |
| 30 | + void testValidCategory_NoErrors() { |
| 31 | + measureSectionNode.putValue("category", "pi"); |
| 32 | + clinicalDocumentNode.addChildNode(measureSectionNode); |
| 33 | + |
| 34 | + SspClinicalDocumentValidator validator = new SspClinicalDocumentValidator(); |
| 35 | + List<Detail> errors = validator.validateSingleNode(clinicalDocumentNode).getErrors(); |
| 36 | + |
| 37 | + assertWithMessage("There should be no errors for category 'pi'") |
| 38 | + .that(errors).isEmpty(); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + void testNullCategory_ShouldError() { |
| 43 | + // category is not set |
| 44 | + clinicalDocumentNode.addChildNode(measureSectionNode); |
| 45 | + |
| 46 | + SspClinicalDocumentValidator validator = new SspClinicalDocumentValidator(); |
| 47 | + List<Detail> errors = validator.validateSingleNode(clinicalDocumentNode).getErrors(); |
| 48 | + |
| 49 | + assertWithMessage("Must report SSP_PI_ONLY_MEASURE_CATEGORY when category is null") |
| 50 | + .that(errors) |
| 51 | + .comparingElementsUsing(DetailsErrorEquals.INSTANCE) |
| 52 | + .containsExactly( |
| 53 | + ProblemCode.SSP_PI_ONLY_MEASURE_CATEGORY.format("SSP", "none") |
| 54 | + ); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + void testInvalidCategory_ShouldError() { |
| 59 | + measureSectionNode.putValue("category", "invalid"); |
| 60 | + clinicalDocumentNode.addChildNode(measureSectionNode); |
| 61 | + |
| 62 | + SspClinicalDocumentValidator validator = new SspClinicalDocumentValidator(); |
| 63 | + List<Detail> errors = validator.validateSingleNode(clinicalDocumentNode).getErrors(); |
| 64 | + |
| 65 | + assertWithMessage("Must report SSP_PI_ONLY_MEASURE_CATEGORY when category is invalid") |
| 66 | + .that(errors) |
| 67 | + .comparingElementsUsing(DetailsErrorEquals.INSTANCE) |
| 68 | + .containsExactly( |
| 69 | + ProblemCode.SSP_PI_ONLY_MEASURE_CATEGORY.format("SSP", "invalid") |
| 70 | + ); |
| 71 | + } |
| 72 | +} |
0 commit comments