Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
package gov.va.oneconsult.seoc.api.controller;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import gov.va.oneconsult.seoc.api.Application;
import gov.va.oneconsult.seoc.api.json.CreateServiceRequest;
import gov.va.oneconsult.seoc.api.json.SeocActivateRequest;
import gov.va.oneconsult.seoc.api.json.SeocCreateRequest;
import gov.va.oneconsult.seoc.api.json.SeocGenericResponse;
import gov.va.oneconsult.seoc.api.util.Constants;
import gov.va.oneconsult.seoc.api.util.DeserializeTest;
import gov.va.oneconsult.seoc.api.util.TestUtil;
/**
* Integration Test Cases
*
* @author AbleVets
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ExternalSeocControllerIntTest
{
public static final DeserializeTest deserialize = new DeserializeTest();
public static final String V1_ROOT = "/v1/seoc/";
public static final String ACTIVATE_SEOC = "activate/";
public static final String REVERSE_SEOC = "reverse/";
public static final String DELETE_SEOC = "delete/";
public static final String ROOT = "/v2/seoc/";
public static final String ALL = "all/";
public static final String ACTIVE = "active/";
public static final String vaUserId = "System";
@LocalServerPort
private int port;
private TestRestTemplate restTemplate = new TestRestTemplate();
private HttpHeaders headers = new HttpHeaders();
@Before
public void setup() {
setHeaders();
}
/**
* Description:Test read active seocs successful scenario
*/
@Test
public void readActiveSeocs() {
HttpEntity<String> entity = new HttpEntity<String>(null, new HttpHeaders());
ResponseEntity<String> response = restTemplate.exchange(createURLWithPort(ROOT + ACTIVE), HttpMethod.GET, entity,
String.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
String responseJson = SeocObjectGenerator.asJsonString(response.getBody());
assertThat(responseJson).contains("VHA Office of Community Care - Standardized Episode of Care");
assertThat(responseJson).doesNotContain("services");
assertThat(responseJson).doesNotContain("hptcs");
assertThat(responseJson).contains("previewText");
// Should not have invalid characters
assertThat(responseJson).doesNotContain(Character.toString((char)1));
assertThat(responseJson).doesNotContain(Character.toString((char)2));
assertThat(responseJson).doesNotContain(Character.toString((char)3));
assertThat(responseJson).doesNotContain(Character.toString((char)4));
assertThat(responseJson).doesNotContain(Character.toString((char)5));
assertThat(responseJson).doesNotContain(Character.toString((char)6));
assertThat(responseJson).doesNotContain(Character.toString((char)21));
assertThat(responseJson).doesNotContain(Character.toString((char)23));
assertThat(responseJson).doesNotContain(Character.toString((char)160));
assertThat(responseJson).doesNotContain("‘");
assertThat(responseJson).doesNotContain("’");
assertThat(responseJson).doesNotContain("“");
assertThat(responseJson).doesNotContain("”");
assertThat(responseJson).doesNotContain("–");
}
/**
* Description:Test read published seocs successful scenario, no REV or PRCT
*/
@Test
public void readPublishedSeocs() {
Set<String> billingCodes = new HashSet<String>();
billingCodes.add("code101");
billingCodes.add("code102");
Set<String> clinicalServices = new HashSet<String>();
clinicalServices.add("12-Pulmonary");
CreateServiceRequest serviceRequest = CreateServiceRequest.Builder.create().withDescription("service1")
.withCodeRequired("YES").withVisits(5).withClinicalServices(clinicalServices).withBillingCodes(billingCodes)
.build();
List<CreateServiceRequest> serviceList = new ArrayList<CreateServiceRequest>();
serviceList.add(serviceRequest);
Set<String> hptcs = new HashSet<String>();
hptcs.add("hptc101");
String requestJson = SeocObjectGenerator.asJsonString(SeocCreateRequest.Builder.create("SeocTest1", "Radiology")
.withServiceList(serviceList).withDescription("Description").withDisclaimer("Disclaimer").withDuration(5)
.withMaxVisits(5).withRev(false).withProceduralOverview("Procedural Overview")
.withCategoryOfCare("Acupuncture12").withQasp("QASP1").withHptcs(hptcs).build());
HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);
// Create SEOC
ResponseEntity<String> response = restTemplate.exchange(createURLWithPort(V1_ROOT), HttpMethod.POST, request,
String.class);
assertThat(HttpStatus.CREATED).isEqualTo(response.getStatusCode());
int id = deserialize.createResponse(response.getBody()).getUniqueId();
String etagHash = response.getHeaders().getETag();
// Activate SEOC
headers.setIfMatch(etagHash);
requestJson = SeocObjectGenerator.asJsonString(SeocActivateRequest.Builder.create(id, TestUtil.getEffectiveDateString()).build());
request = new HttpEntity<String>(requestJson, headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + ACTIVATE_SEOC),
HttpMethod.POST, request, String.class);
SeocGenericResponse seocGenericResponse = deserialize.genericResponse(response.getBody());
String actualStatus = seocGenericResponse.getStatus();
assertThat(actualStatus).isEqualTo(Constants.SUCCESS);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
etagHash = response.getHeaders().getETag();
HttpEntity<String> entity = new HttpEntity<String>(null, new HttpHeaders());
response = restTemplate.exchange(createURLWithPort(ROOT), HttpMethod.GET, entity,
String.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertThat(response.getBody()).contains("\"name\":\"SeocTest1\",");
assertThat(response.getBody()).doesNotContain("activatedTimestamp");
assertThat(response.getBody()).doesNotContain("activatedBy");
assertThat(response.getBody()).doesNotContain("discontinuedTimestamp");
assertThat(response.getBody()).doesNotContain("discontinuedBy");
assertThat(response.getBody()).doesNotContain("codedtimestamp");
assertThat(response.getBody()).doesNotContain("codedBy");
assertThat(response.getBody()).doesNotContain("In-Progress");
assertThat(response.getBody()).contains("PRCT");
// Reverse and Delete the Date Hold SEOC to clean up the data
headers.setIfMatch(etagHash);
request = new HttpEntity<>(headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + REVERSE_SEOC + id), HttpMethod.GET,
request, String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
etagHash = response.getHeaders().getETag();
headers.setIfMatch(etagHash);
request = new HttpEntity<>(headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + DELETE_SEOC + id),
HttpMethod.GET, request, String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
}
/**
* Description:Test read published seocs successful scenario, with PRCT but no REV
*/
@Test
public void readPublishedSeocsPrct() {
Set<String> billingCodes = new HashSet<String>();
billingCodes.add("code101");
billingCodes.add("code102");
billingCodes.add("code104");
Set<String> clinicalServices = new HashSet<String>();
clinicalServices.add("12-Pulmonary");
CreateServiceRequest serviceRequest = CreateServiceRequest.Builder.create().withDescription("service1")
.withCodeRequired("YES").withVisits(5).withClinicalServices(clinicalServices).withBillingCodes(billingCodes)
.build();
List<CreateServiceRequest> serviceList = new ArrayList<CreateServiceRequest>();
serviceList.add(serviceRequest);
Set<String> hptcs = new HashSet<String>();
hptcs.add("hptc101");
String requestJson = SeocObjectGenerator.asJsonString(SeocCreateRequest.Builder.create("SeocTest2", "Radiology")
.withServiceList(serviceList).withDescription("Description").withDisclaimer("Disclaimer").withDuration(5)
.withMaxVisits(5).withRev(false).withProceduralOverview("Procedural Overview")
.withCategoryOfCare("Acupuncture12").withQasp("QASP1").withHptcs(hptcs).build());
HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);
// Create SEOC
ResponseEntity<String> response = restTemplate.exchange(createURLWithPort(V1_ROOT), HttpMethod.POST, request,
String.class);
assertThat(HttpStatus.CREATED).isEqualTo(response.getStatusCode());
int id = deserialize.createResponse(response.getBody()).getUniqueId();
String etagHash = response.getHeaders().getETag();
// Activate SEOC
headers.setIfMatch(etagHash);
requestJson = SeocObjectGenerator.asJsonString(SeocActivateRequest.Builder.create(id, TestUtil.getEffectiveDateString()).build());
request = new HttpEntity<String>(requestJson, headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + ACTIVATE_SEOC),
HttpMethod.POST, request, String.class);
SeocGenericResponse seocGenericResponse = deserialize.genericResponse(response.getBody());
String actualStatus = seocGenericResponse.getStatus();
assertThat(actualStatus).isEqualTo(Constants.SUCCESS);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
etagHash = response.getHeaders().getETag();
HttpEntity<String> entity = new HttpEntity<String>(null, new HttpHeaders());
response = restTemplate.exchange(createURLWithPort(ROOT), HttpMethod.GET, entity,
String.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertThat(response.getBody()).contains("\"name\":\"SeocTest2_PRCT\",");
assertThat(response.getBody()).doesNotContain("activatedTimestamp");
assertThat(response.getBody()).doesNotContain("activatedBy");
assertThat(response.getBody()).doesNotContain("discontinuedTimestamp");
assertThat(response.getBody()).doesNotContain("discontinuedBy");
assertThat(response.getBody()).doesNotContain("codedtimestamp");
assertThat(response.getBody()).doesNotContain("codedBy");
assertThat(response.getBody()).doesNotContain("In-Progress");
assertThat(response.getBody()).contains("PRCT");
// Reverse and Delete the Date Hold SEOC to clean up the data
headers.setIfMatch(etagHash);
request = new HttpEntity<>(headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + REVERSE_SEOC + id), HttpMethod.GET,
request, String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
etagHash = response.getHeaders().getETag();
headers.setIfMatch(etagHash);
request = new HttpEntity<>(headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + DELETE_SEOC + id),
HttpMethod.GET, request, String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
}
/**
* Description:Test read published seocs successful scenario, with REV and PRCT
*/
@Test
public void readPublishedSeocsRevPrct() {
Set<String> billingCodes = new HashSet<String>();
billingCodes.add("code101");
billingCodes.add("code102");
billingCodes.add("code104");
Set<String> clinicalServices = new HashSet<String>();
clinicalServices.add("12-Pulmonary");
CreateServiceRequest serviceRequest = CreateServiceRequest.Builder.create().withDescription("service1")
.withCodeRequired("YES").withVisits(5).withClinicalServices(clinicalServices).withBillingCodes(billingCodes)
.build();
List<CreateServiceRequest> serviceList = new ArrayList<CreateServiceRequest>();
serviceList.add(serviceRequest);
Set<String> hptcs = new HashSet<String>();
hptcs.add("hptc101");
String requestJson = SeocObjectGenerator.asJsonString(SeocCreateRequest.Builder.create("SeocTest3", "Radiology")
.withServiceList(serviceList).withDescription("Description").withDisclaimer("Disclaimer").withDuration(5)
.withMaxVisits(5).withRev(true).withProceduralOverview("Procedural Overview")
.withCategoryOfCare("Acupuncture12").withQasp("QASP1").withHptcs(hptcs).build());
HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);
// Create SEOC
ResponseEntity<String> response = restTemplate.exchange(createURLWithPort(V1_ROOT), HttpMethod.POST, request,
String.class);
assertThat(HttpStatus.CREATED).isEqualTo(response.getStatusCode());
int id = deserialize.createResponse(response.getBody()).getUniqueId();
String etagHash = response.getHeaders().getETag();
// Activate SEOC
headers.setIfMatch(etagHash);
requestJson = SeocObjectGenerator.asJsonString(SeocActivateRequest.Builder.create(id, TestUtil.getEffectiveDateString()).build());
request = new HttpEntity<String>(requestJson, headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + ACTIVATE_SEOC),
HttpMethod.POST, request, String.class);
SeocGenericResponse seocGenericResponse = deserialize.genericResponse(response.getBody());
String actualStatus = seocGenericResponse.getStatus();
assertThat(actualStatus).isEqualTo(Constants.SUCCESS);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
etagHash = response.getHeaders().getETag();
HttpEntity<String> entity = new HttpEntity<String>(null, new HttpHeaders());
response = restTemplate.exchange(createURLWithPort(ROOT), HttpMethod.GET, entity,
String.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertThat(response.getBody()).contains("\"name\":\"SeocTest3_REV_PRCT\",");
assertThat(response.getBody()).doesNotContain("activatedTimestamp");
assertThat(response.getBody()).doesNotContain("activatedBy");
assertThat(response.getBody()).doesNotContain("discontinuedTimestamp");
assertThat(response.getBody()).doesNotContain("discontinuedBy");
assertThat(response.getBody()).doesNotContain("codedtimestamp");
assertThat(response.getBody()).doesNotContain("codedBy");
assertThat(response.getBody()).doesNotContain("In-Progress");
assertThat(response.getBody()).contains("PRCT");
// Reverse and Delete the Date Hold SEOC to clean up the data
headers.setIfMatch(etagHash);
request = new HttpEntity<>(headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + REVERSE_SEOC + id), HttpMethod.GET,
request, String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
etagHash = response.getHeaders().getETag();
headers.setIfMatch(etagHash);
request = new HttpEntity<>(headers);
response = restTemplate.exchange(createURLWithPort(V1_ROOT + DELETE_SEOC + id),
HttpMethod.GET, request, String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
}
/**
*
* Description: Set the headers
*/
private void setHeaders() {
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.set(Constants.USERID, vaUserId);
headers.set(Constants.CLIENT_KEY, TestUtil.CLIENT_KEY);
}
/**
* Description: Test url
*
* @param uri
* @return returns test url
*/
private String createURLWithPort(String uri) {
return "http://localhost:" + port + uri;
}
}