Skip to content

Commit

Permalink
Merge branch 'master' into QPPCT-562
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Harrison authored Dec 21, 2017
2 parents ad6dc6e + 6d5734d commit f84a927
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -26,8 +27,6 @@

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assume.assumeTrue;


class SubmissionIntegrationTest {

Expand All @@ -43,7 +42,7 @@ static void setup() throws IOException {
request.setHeader("qpp-taxpayer-identification-number", "000777777");
request.setHeader("Content-Type", "application/json");
HttpResponse response = client.execute(request);
assumeTrue("Submissions api is down", endpointIsUp(response));
Assumptions.assumeTrue(endpointIsUp(response), "Submissions api is down");

try {
List<Map<?, ?>> subs = JsonHelper.readJsonAtJsonPath(response.getEntity().getContent(),
Expand All @@ -69,7 +68,7 @@ void setupTest() {
@Test
void testSubmissionApiPostSuccess() throws IOException {
HttpResponse httpResponse = servicePost(qpp);
assumeTrue("Submissions api is down", endpointIsUp(httpResponse));
Assumptions.assumeTrue(endpointIsUp(httpResponse), "Submissions api is down");
cleanUp(httpResponse);

assertThat(getStatus(httpResponse)).isEqualTo(200);
Expand All @@ -81,7 +80,7 @@ void testSubmissionApiPostFailure() throws IOException {
Map<String, Object> obj = (Map<String, Object>) qpp.getObject();
obj.remove("performanceYear");
HttpResponse httpResponse = servicePost(qpp);
assumeTrue("Submissions api is down", endpointIsUp(httpResponse));
Assumptions.assumeTrue(endpointIsUp(httpResponse), "Submissions api is down");

assertWithMessage("QPP submission should be unprocessable")
.that(getStatus(httpResponse))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
package gov.cms.qpp.conversion.encode;

import static com.google.common.truth.Truth.assertWithMessage;

import java.util.LinkedHashMap;
import java.util.List;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import gov.cms.qpp.conversion.Context;
import gov.cms.qpp.conversion.model.Node;
import gov.cms.qpp.conversion.model.TemplateId;
import gov.cms.qpp.conversion.model.validation.MeasureConfigs;
import gov.cms.qpp.conversion.model.validation.SubPopulations;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.LinkedHashMap;
import java.util.List;

import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assertThat;

public class QualityMeasureIdMultiEncoderTest {
class QualityMeasureIdMultiEncoderTest {

private static final String REQUIRE_POPULATION_TOTAL = "Must have a required eligiblePopulation";
private static final String REQUIRE_PERFORMANCE_MET = "Must have a required performanceMet";
Expand Down Expand Up @@ -47,18 +53,18 @@ public class QualityMeasureIdMultiEncoderTest {
private JsonWrapper wrapper;
private QualityMeasureIdEncoder encoder;

@BeforeClass
public static void setUpCustomMeasureData() {
@BeforeAll
static void setUpCustomMeasureData() {
MeasureConfigs.setMeasureDataFile("test-multi-prop-measure-data.json");
}

@AfterClass
public static void resetMeasuresData() {
@AfterAll
static void resetMeasuresData() {
MeasureConfigs.setMeasureDataFile(MeasureConfigs.DEFAULT_MEASURE_DATA_FILE_NAME);
}

@Before
public void setUp() {
@BeforeEach
void setUp() {
qualityMeasureId = new Node(TemplateId.MEASURE_REFERENCE_RESULTS_CMS_V2);
qualityMeasureId.putValue(MEASURE_ID, "test1");

Expand Down Expand Up @@ -121,7 +127,7 @@ public void setUp() {
}

@Test
public void testInternalEncode() {
void testInternalEncode() {
qualityMeasureId.addChildNodes(
eligiblePopulationNode, eligiblePopulationExceptionNode,
eligiblePopulationExclusionNode, numeratorNode, denominatorNode,
Expand All @@ -139,7 +145,7 @@ public void testInternalEncode() {
}

@Test
public void testNullSubPopulations() {
void testNullSubPopulations() {
qualityMeasureId.putValue(MEASURE_ID, "test2");
qualityMeasureId.addChildNodes(eligiblePopulationNode, eligiblePopulationExceptionNode,
numeratorNode, denominatorNode, eligiblePopulationNodeTwo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package gov.cms.qpp.conversion.validate;

import static com.google.common.truth.Truth.assertWithMessage;

import java.util.Set;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import gov.cms.qpp.conversion.model.Node;
import gov.cms.qpp.conversion.model.TemplateId;
import gov.cms.qpp.conversion.model.error.Detail;
import gov.cms.qpp.conversion.model.error.ErrorCode;
import gov.cms.qpp.conversion.model.error.correspondence.DetailsErrorEquals;
import org.junit.Before;
import org.junit.Test;

import java.util.Set;

import static com.google.common.truth.Truth.assertWithMessage;

public class AciMeasurePerformedRnRValidatorTest {
class AciMeasurePerformedRnRValidatorTest {

private AciMeasurePerformedRnRValidator validator;
private Node aciMeasurePerformedRnRNode;

@Before
public void init() {
@BeforeEach
void init() {
validator = new AciMeasurePerformedRnRValidator();

aciMeasurePerformedRnRNode = new Node(TemplateId.ACI_MEASURE_PERFORMED_REFERENCE_AND_RESULTS);
Expand All @@ -29,14 +30,14 @@ public void init() {
}

@Test
public void testValidateGoodData() throws Exception {
void testValidateGoodData() throws Exception {
Set<Detail> errors = run();
assertWithMessage("no errors should be present")
.that(errors).isEmpty();
}

@Test
public void testWithNoMeasureId() throws Exception {
void testWithNoMeasureId() throws Exception {
aciMeasurePerformedRnRNode.removeValue("measureId");
Set<Detail> errors = run();
assertWithMessage("Should result in a MEASURE_ID_IS_REQUIRED error")
Expand All @@ -45,7 +46,7 @@ public void testWithNoMeasureId() throws Exception {
}

@Test
public void testWithNoChildren() throws Exception {
void testWithNoChildren() throws Exception {
aciMeasurePerformedRnRNode.getChildNodes().clear();
Set<Detail> errors = run();
assertWithMessage("Validation error size should be 1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
package gov.cms.qpp.conversion.validate;

import static com.google.common.truth.Truth.assertWithMessage;

import java.util.Set;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import gov.cms.qpp.conversion.model.Node;
import gov.cms.qpp.conversion.model.TemplateId;
import gov.cms.qpp.conversion.model.error.Detail;
import gov.cms.qpp.conversion.model.error.ErrorCode;
import gov.cms.qpp.conversion.model.error.correspondence.DetailsErrorEquals;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.util.Set;

import static com.google.common.truth.Truth.assertWithMessage;
class AciSectionValidatorTest {

public class AciSectionValidatorTest {
private static final String VALID_ACI_MEASURE = "ACI_EP_1";
private Node reportingParamNode;
private Node aciNumeratorDenominatorNode;
private Node measureNode;
private Node aciSectionNode;

@Rule
public ExpectedException thrown = ExpectedException.none();

@Before
public void setUpAciSectionNode() {
@BeforeEach
void setUpAciSectionNode() {
reportingParamNode = new Node(TemplateId.REPORTING_PARAMETERS_ACT);
aciNumeratorDenominatorNode = new Node(TemplateId.ACI_NUMERATOR_DENOMINATOR);
measureNode = new Node(TemplateId.MEASURE_PERFORMED);
Expand All @@ -36,7 +33,7 @@ public void setUpAciSectionNode() {
}

@Test
public void testNoReportingParamPresent() {
void testNoReportingParamPresent() {
aciSectionNode.addChildNodes(aciNumeratorDenominatorNode, measureNode);

AciSectionValidator aciSectionValidator = new AciSectionValidator();
Expand All @@ -49,7 +46,7 @@ public void testNoReportingParamPresent() {
}

@Test
public void testTooManyReportingParams() {
void testTooManyReportingParams() {
Node invalidReportingParamNode = new Node(TemplateId.REPORTING_PARAMETERS_ACT);
aciSectionNode.addChildNodes(reportingParamNode, invalidReportingParamNode, aciNumeratorDenominatorNode, measureNode);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
package gov.cms.qpp.conversion.validate;

import static com.google.common.truth.Truth.assertWithMessage;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import gov.cms.qpp.conversion.model.Node;
import gov.cms.qpp.conversion.model.TemplateId;
import gov.cms.qpp.conversion.model.error.ErrorCode;
import gov.cms.qpp.conversion.model.error.correspondence.DetailsErrorEquals;
import org.junit.Before;
import org.junit.Test;

import static com.google.common.truth.Truth.assertWithMessage;
class CpcQualityMeasureIdValidatorTest {

public class CpcQualityMeasureIdValidatorTest {
private CpcQualityMeasureIdValidator validator;
private Node testNode;

@Before
public void setUp() {
@BeforeEach
void setUp() {
validator = new CpcQualityMeasureIdValidator();

testNode = new Node(TemplateId.MEASURE_REFERENCE_RESULTS_CMS_V2);
testNode.putValue(CpcQualityMeasureIdValidator.MEASURE_ID,"40280381-51f0-825b-0152-22a112d2172a");
}

@Test
public void testPerformanceCountWithNoErrors() {
void testPerformanceCountWithNoErrors() {
addAnyNumberOfChildren(2);
validator.internalValidateSingleNode(testNode);

Expand All @@ -32,7 +34,7 @@ public void testPerformanceCountWithNoErrors() {
}

@Test
public void testPerformanceCountWithIncreasedSizeError() {
void testPerformanceCountWithIncreasedSizeError() {
addAnyNumberOfChildren(3);
validator.internalValidateSingleNode(testNode);

Expand All @@ -42,7 +44,7 @@ public void testPerformanceCountWithIncreasedSizeError() {
}

@Test
public void testPerformanceCountWithDecreasedSizeError() {
void testPerformanceCountWithDecreasedSizeError() {
addAnyNumberOfChildren(1);
validator.internalValidateSingleNode(testNode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,52 @@

import static com.google.common.truth.Truth.assertWithMessage;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import gov.cms.qpp.conversion.decode.PerformanceRateProportionMeasureDecoder;
import gov.cms.qpp.conversion.model.Node;
import gov.cms.qpp.conversion.model.TemplateId;
import gov.cms.qpp.conversion.model.error.ErrorCode;
import gov.cms.qpp.conversion.model.error.correspondence.DetailsErrorEquals;

public class PerformanceRateValidatorTest {
class PerformanceRateValidatorTest {

private PerformanceRateValidator performanceRateValidator;
private Node node;

@Before
public void setup() {
@BeforeEach
void setup() {
performanceRateValidator = new PerformanceRateValidator();
node = new Node(TemplateId.PERFORMANCE_RATE_PROPORTION_MEASURE);
node.putValue(PerformanceRateProportionMeasureDecoder.PERFORMANCE_RATE, "0");
}

@Test
public void testZeroValue() {
void testZeroValue() {
performanceRateValidator.internalValidateSingleNode(node);
assertWithMessage("Must contain a proper value")
.that(performanceRateValidator.getDetails()).isEmpty();
}

@Test
public void testOneValue() {
void testOneValue() {
node.putValue(PerformanceRateProportionMeasureDecoder.PERFORMANCE_RATE, "1");
performanceRateValidator.internalValidateSingleNode(node);
assertWithMessage("Must contain a proper value")
.that(performanceRateValidator.getDetails()).isEmpty();
}

@Test
public void testNAValue() {
void testNAValue() {
node.putValue(PerformanceRateProportionMeasureDecoder.NULL_PERFORMANCE_RATE, "NA");
performanceRateValidator.internalValidateSingleNode(node);
assertWithMessage("Must contain a proper value")
.that(performanceRateValidator.getDetails()).isEmpty();
}

@Test
public void testNegativeValue() {
void testNegativeValue() {
node.putValue(PerformanceRateProportionMeasureDecoder.PERFORMANCE_RATE, "-1");
performanceRateValidator.internalValidateSingleNode(node);
assertWithMessage("Must contain a proper value")
Expand All @@ -55,7 +56,7 @@ public void testNegativeValue() {
}

@Test
public void testInvalidValue() {
void testInvalidValue() {
node.putValue(PerformanceRateProportionMeasureDecoder.PERFORMANCE_RATE, "2");
performanceRateValidator.internalValidateSingleNode(node);
assertWithMessage("Must contain a proper value")
Expand All @@ -64,7 +65,7 @@ public void testInvalidValue() {
}

@Test
public void testInvalidStringValue() {
void testInvalidStringValue() {
node.putValue(PerformanceRateProportionMeasureDecoder.PERFORMANCE_RATE, "Inval");
performanceRateValidator.internalValidateSingleNode(node);
assertWithMessage("Must contain a proper value")
Expand Down
Loading

0 comments on commit f84a927

Please sign in to comment.