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

/*
* SeocControllerTest.java
* Copyright (c) 2017 Veterans Affairs.
*/
package gov.va.oneconsult.seoc.api.controller;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import gov.va.oneconsult.seoc.api.Application;
import gov.va.oneconsult.seoc.api.json.CheckNameRequest;
import gov.va.oneconsult.seoc.api.model.BillingCode;
import gov.va.oneconsult.seoc.api.model.CodeRequired;
import gov.va.oneconsult.seoc.api.model.PayableService;
import gov.va.oneconsult.seoc.api.model.Seoc;
import gov.va.oneconsult.seoc.api.service.SeocService;
import gov.va.oneconsult.seoc.api.util.Constants;
import gov.va.oneconsult.seoc.api.util.DeserializeTest;

/**
* @author AbleVets
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = Application.class)
public class SeocControllerTest {

private MockMvc mockMvc;

@Mock
private SeocService seocService;

@InjectMocks
private SeocController seocController;

public static final DeserializeTest deserialize = new DeserializeTest();

public static final String ROOT = "/v1/seoc";

public static final String CHECK_SEOC_NAME = "/checkseocexists";

@Before
public void setup() {

MockitoAnnotations.initMocks(this);
this.mockMvc = MockMvcBuilders.standaloneSetup(seocController).build();
}

/**
* Description: If seoc with name exists then end point returns failure
*
* @throws Exception
*/
@Test
public void testCheckSeocWithNameExists() throws Exception {

CheckNameRequest req = new CheckNameRequest.Builder("Optometry SEOC 1.0.0").withSeocKey(0).build();
Mockito.when(seocService.isSeocAvailable(req.getSeocKey(), req.getName())).thenReturn(false);
RequestBuilder request = MockMvcRequestBuilders.post(ROOT + CHECK_SEOC_NAME).contentType(MediaType.APPLICATION_JSON)
.content(SeocObjectGenerator.asJsonString(req)).accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String actualStatus = deserialize.genericResponse(result.getResponse().getContentAsString()).getStatus();

assertThat(actualStatus).isEqualTo(Constants.FAILURE);

Mockito.verify(seocService, Mockito.times(1)).isSeocAvailable(Mockito.anyInt(), Mockito.anyString());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: If Seoc with name does not exist then end point returns success.
* Ok to proceed for Seoc creation.
*
* @throws Exception
*/
@Test
public void testCheckSeocWithNameNotAvailable() throws Exception {

CheckNameRequest req = new CheckNameRequest.Builder("Optometry SEOC 1.0.0").withSeocKey(0).build();
Mockito.when(seocService.isSeocAvailable(req.getSeocKey(), req.getName())).thenReturn(true);
RequestBuilder request = MockMvcRequestBuilders.post(ROOT + CHECK_SEOC_NAME).contentType(MediaType.APPLICATION_JSON)
.content(SeocObjectGenerator.asJsonString(req)).accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String actualStatus = deserialize.genericResponse(result.getResponse().getContentAsString()).getStatus();

assertThat(actualStatus).isEqualTo(Constants.SUCCESS);

Mockito.verify(seocService, Mockito.times(1)).isSeocAvailable(Mockito.anyInt(), Mockito.anyString());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: If seoc with the Id exists then the method end point success
*
* @throws Exception
*/
@Test
public void testSeocEditExists() throws Exception {

CheckNameRequest req = new CheckNameRequest.Builder("Optometry SEOC 1.0.0").withSeocKey(1).build();
Mockito.when(seocService.isSeocAvailable(req.getSeocKey(), req.getName())).thenReturn(true);
RequestBuilder request = MockMvcRequestBuilders.post(ROOT + CHECK_SEOC_NAME).contentType(MediaType.APPLICATION_JSON)
.content(SeocObjectGenerator.asJsonString(req)).accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String actualStatus = deserialize.genericResponse(result.getResponse().getContentAsString()).getStatus();

assertThat(actualStatus).isEqualTo(Constants.SUCCESS);

Mockito.verify(seocService, Mockito.times(1)).isSeocAvailable(Mockito.anyInt(), Mockito.anyString());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Seoc with Id does not exist then the end point returns failure
*
* @throws Exception
*/
@Test
public void testSeocEditDoesNotExist() throws Exception {

CheckNameRequest req = new CheckNameRequest.Builder("Optometry SEOC 1.0.0").withSeocKey(1).build();
Mockito.when(seocService.isSeocAvailable(req.getSeocKey(), req.getName())).thenReturn(false);
RequestBuilder request = MockMvcRequestBuilders.post(ROOT + CHECK_SEOC_NAME).contentType(MediaType.APPLICATION_JSON)
.content(SeocObjectGenerator.asJsonString(req)).accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String actualStatus = deserialize.genericResponse(result.getResponse().getContentAsString()).getStatus();

assertThat(actualStatus).isEqualTo(Constants.FAILURE);

Mockito.verify(seocService, Mockito.times(1)).isSeocAvailable(Mockito.anyInt(), Mockito.anyString());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Find by seocKey successfully retrieves the Seoc. Response status
* code expected - 200 OK
*
* @throws Exception
*/
@Test
public void testFindBySeocKeySuccess() throws Exception {

Seoc expectedSeoc = SeocObjectGenerator.getDraftSeoc();
expectedSeoc.setDescription("<script>description</script>");
String expectedDescription = "&lt;script&gt;description&lt;/script&gt;";
Set<Seoc> expected = new HashSet<Seoc>();
expected.add(expectedSeoc);
Integer seocKey = expectedSeoc.getSeocKey();

Mockito.when(seocService.getBySeocKey(Mockito.any(Integer.class))).thenReturn(expected);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/seocKey/" + seocKey)
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String responseJson = result.getResponse().getContentAsString();
assertTrue(responseJson.contains("" + seocKey));
assertTrue(responseJson.contains(expectedDescription));

ArgumentCaptor<Integer> argCaptor = ArgumentCaptor.forClass(Integer.class);
Mockito.verify(seocService, Mockito.times(1)).getBySeocKey(argCaptor.capture());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Find by seocKey when no content found. Response status code
* expected - 204 No Content
*
* @throws Exception
*/
@Test
public void testFindBySeocKeyNoContent() throws Exception {
Integer seocKey = 0;

RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/seocKey/" + seocKey)
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON_UTF8);

mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8));
}

/**
* Description: Find by Id successfully retrieves the Seoc. Response status code
* expected - 200 OK
*
* @throws Exception
*/
@Test
public void testFindbyIdSuccess() throws Exception {

Seoc expectedSeoc = SeocObjectGenerator.getActiveSeoc();
int id = expectedSeoc.getId();

Mockito.when(seocService.getSeocById(Mockito.any(Integer.class))).thenReturn(expectedSeoc);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/" + id).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String foundJson = result.getResponse().getContentAsString();

assertTrue(foundJson.contains("" + id));

ArgumentCaptor<Integer> argCaptor = ArgumentCaptor.forClass(Integer.class);
Mockito.verify(seocService, Mockito.times(1)).getSeocById(argCaptor.capture());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Find by Id when no content found. Response status code expected
* - 204 No Content
*
* @throws Exception
*/
@Test
public void testFindbyIdNoContent() throws Exception {

int id = 10;
Mockito.when(seocService.getSeocById(Mockito.any(Integer.class))).thenReturn(null);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/" + id).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8));

ArgumentCaptor<Integer> argCaptor = ArgumentCaptor.forClass(Integer.class);
Mockito.verify(seocService, Mockito.times(1)).getSeocById(argCaptor.capture());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: FindbyName successfully retrieves the Seoc. Response status code
* expected - 200 OK
*
* @throws Exception
*/
@Test
public void testFindbyNameSuccess() throws Exception {

Seoc expectedSeoc = SeocObjectGenerator.getDraftSeoc();
expectedSeoc.setDescription("<script>description</script>");
String expectedDescription = "&lt;script&gt;description&lt;/script&gt;";
Set<Seoc> expected = new HashSet<Seoc>();
expected.add(expectedSeoc);
String name = expectedSeoc.getName();

Mockito.when(seocService.getByNameMatch(Mockito.any(String.class))).thenReturn(expected);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/name/" + name).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String responseJson = result.getResponse().getContentAsString();
assertTrue(responseJson.contains(name));
assertTrue(responseJson.contains(expectedDescription));

ArgumentCaptor<String> argCaptor = ArgumentCaptor.forClass(String.class);
Mockito.verify(seocService, Mockito.times(1)).getByNameMatch(argCaptor.capture());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Find by Name when no content found. Response status code
* expected - 204 No Content
*
* @throws Exception
*/
@Test
public void testFindbyNameNoContent() throws Exception {

String name = "UnknownSeoc";

RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/name/" + name).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8));

}

@Test
public void testFindByIdHtmlEncoding() throws Exception {

Seoc activeSeoc = SeocObjectGenerator.getActiveSeoc();
activeSeoc.setProceduralOverview(
"This is a <p>special charcater</p> <script>test</script> =, ~,', @, ^, #, &, $, *, $, %, -, (, ), + ");
String expectedProcOverview = "This is a &lt;p&gt;special charcater&lt;/p&gt; &lt;script&gt;test&lt;/script&gt; &#x3d;, &#x7e;,', &#x40;, &#x5e;, &#x23;, &, &#x24;, *, &#x24;, &#x25;, -, (, ), + ";
Mockito.when(seocService.getSeocById(1)).thenReturn(activeSeoc);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/1").contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

assertThat(result.getResponse().getContentAsString()).contains(expectedProcOverview);

Mockito.verify(seocService, Mockito.times(1)).getSeocById(Mockito.anyInt());
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Find all Seocs when no content found. Response status code
* expected - 204 No content found
*
* @throws Exception
*/
@Test
public void testFindAllHtmlEncoding() throws Exception {
String expectedName = "Seoc 1+2&#x3d;3";

Seoc draftSeoc = SeocObjectGenerator.getDraftSeoc();
draftSeoc.setName("Seoc 1+2=3");

Set<Seoc> allSeocs = new HashSet<Seoc>();
allSeocs.add(draftSeoc);

Mockito.when(seocService.getAllSeocs()).thenReturn(allSeocs);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/all").contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

assertThat(result.getResponse().getContentAsString()).contains(expectedName);

Mockito.verify(seocService, Mockito.times(1)).getAllSeocs();
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Find Active Seocs successfully retrieves all active seocs.
* Response status code expected - 200 OK
*
* @throws Exception
*/
@Test
public void testActiveSeocs() throws Exception {

Seoc activeSeoc = SeocObjectGenerator.getActiveSeoc();
String controlCharacters = "" +
Character.toString((char)1) +
Character.toString((char)2) +
Character.toString((char)3) +
Character.toString((char)4) +
Character.toString((char)5) +
Character.toString((char)6) +
Character.toString((char)21) +
Character.toString((char)23) +
Character.toString((char)160);
String seocName = "SEOC – Name “left double quote, right double quote” ‘left single quote, right single quote’" + controlCharacters;
String proceduralOverview = "Procedural Overview 1.first \r \n2.second\r\n\n 3.third\r\n 4.fourth\r\n";
String disclaimer = "\r\nDisclaimer\r\n";
String description = "Description\r\n";

String expectedControlCharacters = "" +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" ";
String expectedSeocName = "SEOC - Name \"left double quote, right double quote\" \'left single quote, right single quote\'" + expectedControlCharacters;
String expectedProcOver = "Procedural Overview 1.first \r\n \r\n2.second\r\n 3.third\r\n 4.fourth";
String expectedDisc = "\r\nDisclaimer";
String expectedDescr = "Description";

activeSeoc.setName(seocName);
activeSeoc.setProceduralOverview(proceduralOverview);
activeSeoc.setDisclaimer(disclaimer);
activeSeoc.setDescription(description);

List<Seoc> expectedSeocs = new ArrayList<Seoc>();
expectedSeocs.add(activeSeoc);
Mockito.when(seocService.getActiveSeocs()).thenReturn(expectedSeocs);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/active").contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String actualSeocName = SeocObjectGenerator.getFieldValueFromJson(result.getResponse().getContentAsString(), 0,
"name");
String actualProcOver = SeocObjectGenerator.getFieldValueFromJson(result.getResponse().getContentAsString(), 0,
"proceduralOverview");
String actualDisc = SeocObjectGenerator.getFieldValueFromJson(result.getResponse().getContentAsString(), 0,
"disclaimer");
String actualDescr = SeocObjectGenerator.getFieldValueFromJson(result.getResponse().getContentAsString(), 0,
"description");

assertThat(actualSeocName).isEqualTo(expectedSeocName);
assertThat(actualProcOver).isEqualTo(expectedProcOver);
assertThat(actualDisc).isEqualTo(expectedDisc);
assertThat(actualDescr).isEqualTo(expectedDescr);

Mockito.verify(seocService, Mockito.times(1)).getActiveSeocs();
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Find Seocs with BillingCodes successfully retrieves all active seocs with associated billing codes.
* Response status code expected - 200 OK
*
* @throws Exception
*/
@Test
public void testBillingCodesForSeocs() throws Exception {

Seoc activeSeoc = SeocObjectGenerator.getActiveSeoc();
String seocName = "SEOC - Name";
String seocVersionNumber = "1.0.1";

activeSeoc.setName(seocName);
activeSeoc.setVersionNumber(seocVersionNumber);

PayableService serv1 = SeocObjectGenerator.getPayableService(1, "description", 4, "TEST", 4, CodeRequired.YES.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, activeSeoc);
PayableService serv2 = SeocObjectGenerator.getPayableService(2, "description", 4, "TEST", 4, CodeRequired.YES.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, activeSeoc);
PayableService serv3 = SeocObjectGenerator.getPayableService(3, "description", 4, "TEST", 4, CodeRequired.NO.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, activeSeoc);
PayableService serv4 = SeocObjectGenerator.getPayableService(4, "description", 4, "TEST", 4, CodeRequired.ANY.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, activeSeoc);

BillingCode bc1 = SeocObjectGenerator.getBillingCode(5, "BC1", "CPT", "DESC", true);
BillingCode bc2 = SeocObjectGenerator.getBillingCode(6, "BC2", "CPT", "DESC", true);
BillingCode bc3 = SeocObjectGenerator.getBillingCode(7, "BC3", "CPT", "DESC", true);
BillingCode bc4 = SeocObjectGenerator.getBillingCode(8, "BC4", "CPT", "DESC", true);

serv1.setBillingCodes(new HashSet<BillingCode>());
serv1.getBillingCodes().add(bc1);
serv1.getBillingCodes().add(bc2);
serv1.getBillingCodes().add(bc3);
serv1.getBillingCodes().add(null);

serv2.setBillingCodes(new HashSet<BillingCode>());
serv2.getBillingCodes().add(bc2);
serv2.getBillingCodes().add(bc3);
serv2.getBillingCodes().add(bc4);

serv3.setBillingCodes(new HashSet<BillingCode>());

serv4.setBillingCodes(null);

activeSeoc.setServices(new ArrayList<PayableService>());
activeSeoc.getServices().add(serv1);
activeSeoc.getServices().add(serv2);
activeSeoc.getServices().add(serv3);
activeSeoc.getServices().add(serv4);
activeSeoc.getServices().add(null);

List<Seoc> expectedSeocs = new ArrayList<Seoc>();
expectedSeocs.add(activeSeoc);
Mockito.when(seocService.getActiveSeocs()).thenReturn(expectedSeocs);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/active/billingcodes").contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

JSONArray seocsList = new JSONArray(result.getResponse().getContentAsString());
JSONObject seoc = seocsList.getJSONObject(0);

assertThat(seoc.getString("name")).isEqualTo(seocName);
assertThat(seoc.getString("versionNumber")).isEqualTo(seocVersionNumber);

JSONArray billingCodesList = seoc.getJSONArray("billingCodes");
JSONObject seocBillingCode1 = billingCodesList.getJSONObject(0);
JSONObject seocBillingCode2 = billingCodesList.getJSONObject(1);
JSONObject seocBillingCode3 = billingCodesList.getJSONObject(2);
JSONObject seocBillingCode4 = billingCodesList.getJSONObject(3);

assertThat(billingCodesList.length()).isEqualTo(4);

assertThat(seocBillingCode1.getInt("id")).isEqualTo(bc1.getId());
assertThat(seocBillingCode1.getBoolean("precertRequired")).isEqualTo(bc1.getPrecertRequired());
assertThat(seocBillingCode1.getString("billingCode")).isEqualTo(bc1.getBillingCode());
assertThat(seocBillingCode1.getString("codeType")).isEqualTo(bc1.getCodeType());

assertThat(seocBillingCode2.getInt("id")).isEqualTo(bc2.getId());
assertThat(seocBillingCode2.getBoolean("precertRequired")).isEqualTo(bc2.getPrecertRequired());
assertThat(seocBillingCode2.getString("billingCode")).isEqualTo(bc2.getBillingCode());
assertThat(seocBillingCode2.getString("codeType")).isEqualTo(bc2.getCodeType());

assertThat(seocBillingCode3.getInt("id")).isEqualTo(bc3.getId());
assertThat(seocBillingCode3.getBoolean("precertRequired")).isEqualTo(bc3.getPrecertRequired());
assertThat(seocBillingCode3.getString("billingCode")).isEqualTo(bc3.getBillingCode());
assertThat(seocBillingCode3.getString("codeType")).isEqualTo(bc3.getCodeType());

assertThat(seocBillingCode4.getInt("id")).isEqualTo(bc4.getId());
assertThat(seocBillingCode4.getBoolean("precertRequired")).isEqualTo(bc4.getPrecertRequired());
assertThat(seocBillingCode4.getString("billingCode")).isEqualTo(bc4.getBillingCode());
assertThat(seocBillingCode4.getString("codeType")).isEqualTo(bc4.getCodeType());

Mockito.verify(seocService, Mockito.times(1)).getActiveSeocs();
Mockito.verifyNoMoreInteractions(seocService);
}

/**
* Description: Find Seoc by Id and verify it includes HPTCs object.
*
* @throws Exception
*/
@Test
public void testFindSeocbyId_Includes_HPTCs_Object() throws Exception {

Seoc expectedSeoc = SeocObjectGenerator.getActiveSeoc();
int id = expectedSeoc.getId();

Mockito.when(seocService.getSeocById(Mockito.any(Integer.class))).thenReturn(expectedSeoc);
RequestBuilder request = MockMvcRequestBuilders.get(ROOT + "/" + id).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8);

MvcResult result = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

String foundJson = result.getResponse().getContentAsString();
assertTrue(foundJson.contains("" + id));
assertTrue(foundJson.contains("hptcs"));
ArgumentCaptor<Integer> argCaptor = ArgumentCaptor.forClass(Integer.class);
Mockito.verify(seocService, Mockito.times(1)).getSeocById(argCaptor.capture());
Mockito.verifyNoMoreInteractions(seocService);
}

}