Skip to content

Commit

Permalink
Merge branch 'PLT-136' of https://github.com/CMSgov/ab2d into PLT-136
Browse files Browse the repository at this point in the history
  • Loading branch information
oluwolenpbc authored and oluwolenpbc committed Oct 25, 2023
2 parents c224f14 + c0e144b commit 879fb37
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ApiText {
public static final String BULK_RESPONSE = "Absolute URL of an endpoint for subsequent status requests (polling location)";
public static final String RUNNING_JOBIDS = "URLs of currently running jobs. To cancel one of those jobs, invoke the Status DELETE call.";
public static final String BULK_SINCE = "Beginning time of query. Returns all records \"since\" this time. At this time, it must be after " + SINCE_EARLIEST_DATE;
public static final String BULK_SINCE_DEFAULT = " If no value is provided, it will default to the last time a successful job was requested if it exists. This rule is NOT applied to sandbox contract matching Z0***.";
public static final String BULK_SINCE_DEFAULT = " If no value is provided, it will default to the last time a successful job was requested if it exists. The earliest accepted date is 2020-02-13T00:00:00.000-05:00";
public static final String BULK_RESPONSE_LONG = "Absolute URL of an endpoint for subsequent status requests (polling location)";
public static final String EXPORT_STARTED = "Export request has started";
public static final String MAX_JOBS = "Too many jobs are currently running. Either wait for currently running jobs to finish or cancel some/all of those jobs.";
Expand Down
44 changes: 19 additions & 25 deletions e2e-test/src/test/java/gov/cms/ab2d/e2etest/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,14 @@ class TestRunner {

private final Set<String> acceptableIdStrings = Set.of("carrier", "dme", "hha", "hospice", "inpatient", "outpatient", "snf");

// Define default test contract
private String testContractV1 = "Z0000";
private String testContractV2 = "Z0000";

// Get all methods annotated with @Test and run them. This will only be called from TestLaucher when running against
// an external environment, the regular tests that run as part of a build will be called like they normally would
// during a build.
public void runTests(String testContract) throws InvocationTargetException, IllegalAccessException {
if (testContract != null && !testContract.isEmpty()) {
log.info("Running test with contract: " + testContract);
}
final Class annotation = Test.class;
final Class<Test> annotation = Test.class;
final Class<?> klass = this.getClass();
final List<Method> allMethods = new ArrayList<>(Arrays.asList(klass.getDeclaredMethods()));
for (final Method method : allMethods) {
Expand Down Expand Up @@ -253,7 +249,7 @@ private HttpResponse<String> pollForStatusResponse(String statusUrl) throws Inte
List<String> xProgressList = statusResponse.headers().map().get("x-progress");
if (xProgressList != null && !xProgressList.isEmpty()) {
String xProgress = xProgressList.iterator().next();
int xProgressValue = Integer.valueOf(xProgress.substring(0, xProgress.indexOf('%')));
int xProgressValue = Integer.parseInt(xProgress.substring(0, xProgress.indexOf('%')));
if (xProgressValue > 0 && xProgressValue < 100) {
statusesBetween0And100.add(xProgressValue);
}
Expand Down Expand Up @@ -403,25 +399,23 @@ private void checkMetadata(OffsetDateTime since, JSONObject jsonObject) throws J

private void checkEOBExtensions(JSONObject jsonObject, FhirVersion version) throws JSONException {
switch (version) {
case STU3:
checkEOBExtensionsSTU3(jsonObject);
break;
case R4:
checkEOBExtensionsR4(jsonObject);
break;
default:
break;
case STU3 -> checkEOBExtensionsSTU3(jsonObject);
case R4 -> checkEOBExtensionsR4(jsonObject);
default -> {
}
}
}

private void checkEOBExtensionsSTU3(JSONObject jsonObject) throws JSONException {

final JSONArray extensions = jsonObject.getJSONArray("extension");
assertNotNull(extensions);
assertEquals(1, extensions.length());

// Assume first extension is MBI object
JSONObject idObj = extensions.getJSONObject(0);
List<Integer> possibleNumberOfExtensions = Arrays.asList(11, 21, 22, 23 ,24);

assertTrue(possibleNumberOfExtensions.contains(extensions.length())) ;

// Assume last extension is MBI object
JSONObject idObj = extensions.getJSONObject(extensions.length()-1);
assertNotNull(idObj);

// Unwrap identifier
Expand Down Expand Up @@ -475,11 +469,10 @@ private boolean validFields(JSONObject jsonObject) {
if (!allowedFields.contains(val)) {
if (disallowedFields.contains(val)) {
log.info("********** API outputted invalid field '" + val + "'");
return false;
} else {
log.info("********** API outputted unknown field '" + val + "'");
return false;
}
return false;
}
} catch (JSONException e) {
e.printStackTrace();
Expand Down Expand Up @@ -511,7 +504,7 @@ private Pair<String, JSONArray> performStatusRequests(List<String> contentLocati
List<String> retryAfterList = statusResponse.headers().map().get("retry-after");
assertEquals(retryAfterList.iterator().next(), String.valueOf(DELAY));
List<String> xProgressList = statusResponse.headers().map().get("x-progress");
assertTrue(xProgressList.iterator().next().matches("\\d+\\% complete"));
assertTrue(xProgressList.iterator().next().matches("\\d+% complete"));

HttpResponse<String> retryStatusResponse = apiClient.statusRequest(contentLocationList.iterator().next());

Expand Down Expand Up @@ -625,6 +618,7 @@ void testClientCannotDownloadOtherClientsJob(FhirVersion version, String contrac

APIClient secondAPIClient = createSecondClient();

assertNotNull(downloadDetails);
HttpResponse<InputStream> downloadResponse = secondAPIClient.fileDownloadRequest(downloadDetails.getFirst());
assertEquals(403, downloadResponse.statusCode());
}
Expand Down Expand Up @@ -819,7 +813,10 @@ void testHealthEndPoint() throws IOException, InterruptedException {
* @return the stream of arguments
*/
private Stream<Arguments> getVersionAndContract() {
// Define default test contract
String testContractV1 = "Z0000";
if (v2Enabled()) {
String testContractV2 = "Z0000";
return Stream.of(arguments(STU3, testContractV1), arguments(R4, testContractV2));
} else {
return Stream.of(arguments(STU3, testContractV1));
Expand All @@ -841,9 +838,6 @@ static Stream<Arguments> getVersion() {

private static boolean v2Enabled() {
String v2Enabled = System.getenv("AB2D_V2_ENABLED");
if (v2Enabled != null && v2Enabled.equalsIgnoreCase("true")) {
return true;
}
return false;
return v2Enabled != null && v2Enabled.equalsIgnoreCase("true");
}
}
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@

<!-- AB2D lib versions -->
<events-client.version>1.11.8</events-client.version>
<bfd-lib.version>2.0.9</bfd-lib.version>
<bfd-lib.version>2.0.10</bfd-lib.version>
<fhir-lib.version>1.1.11</fhir-lib.version>
<aggregator-lib.version>1.2.11</aggregator-lib.version>
<filters-lib.version>1.8.5</filters-lib.version>
<aggregator-lib.version>1.2.12</aggregator-lib.version>
<filters-lib.version>1.8.7</filters-lib.version>
<properties-client.version>1.1.9</properties-client.version>
<contract-client.version>1.1.4</contract-client.version>
</properties>
Expand Down
16 changes: 8 additions & 8 deletions settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>ab2d-maven-cache</name>
<url>${repository_url}/ab2d-maven-repo/</url>
<name>ab2d-maven-virtual</name>
<url>${repository_url}/ab2d-maven-virtual</url>
</repository>
<repository>
<snapshots/>
<id>snapshots</id>
<name>ab2d-maven</name>
<url>${repository_url}/ab2d-main/</url>
<name>ab2d-maven-virtual</name>
<url>${repository_url}/ab2d-maven-virtual</url>
</repository>
</repositories>
<pluginRepositories>
Expand All @@ -38,14 +38,14 @@
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>ab2d-maven-cache</name>
<url>${repository_url}/ab2d-maven-repo</url>
<name>ab2d-maven-virtual</name>
<url>${repository_url}/ab2d-maven-virtual</url>
</pluginRepository>
<pluginRepository>
<snapshots/>
<id>snapshots</id>
<name>ab2d-maven</name>
<url>${repository_url}/ab2d-main</url>
<name>ab2d-maven-virtual</name>
<url>${repository_url}/ab2d-maven-virtual</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
Expand Down

0 comments on commit 879fb37

Please sign in to comment.