X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2FGroupServletTest.java;h=67687d08ec92b1a9c99f5bf8d90215a23a23d8aa;hp=d6f1e6dc8a0b4bf5bc664683957282273ac3af7e;hb=68a9ca240970fceaf12bbe91b7bad8e1d98ecd93;hpb=c7ddeaab4dd317de91aac32e07404a2ed4ac6567 diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java index d6f1e6dc..67687d08 100755 --- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java +++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java @@ -34,6 +34,7 @@ import org.onap.dmaap.datarouter.authz.AuthorizationResponse; import org.onap.dmaap.datarouter.authz.Authorizer; import org.onap.dmaap.datarouter.provisioning.beans.Insertable; import org.onap.dmaap.datarouter.provisioning.beans.Updateable; +import org.onap.dmaap.datarouter.provisioning.utils.Poker; import org.powermock.modules.junit4.PowerMockRunner; import javax.persistence.EntityManager; @@ -154,7 +155,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_PUT_And_Request_Contains_Badly_Formed_JSON_Then_Bad_Request_Response_Is_Generated() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); ServletInputStream inStream = mock(ServletInputStream.class); when(request.getInputStream()).thenReturn(inStream); groupServlet.doPut(request, response); @@ -163,7 +164,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_PUT_And_Group_Name_Is_Too_Long_Then_Bad_Request_Response_Is_Generated() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); GroupServlet groupServlet = overideGetJSONFromInputToReturnAnInvalidGroup(true); groupServlet.doPut(request, response); verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class))); @@ -171,7 +172,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_PUT_And_PUT_Fails_Then_Internal_Server_Error_Response_Is_Generated() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); GroupServlet groupServlet = overideGetJSONFromInputToReturnAValidGroupWithFail(); groupServlet.doPut(request, response); verify(response).sendError(eq(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), argThat(notNullValue(String.class))); @@ -179,7 +180,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_PUT_And_Request_Succeeds() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); GroupServlet groupServlet = overideGetJSONFromInputToReturnGroupInDb(); ServletOutputStream outStream = mock(ServletOutputStream.class); when(response.getOutputStream()).thenReturn(outStream); @@ -210,7 +211,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_POST_And_Request_Contains_Badly_Formed_JSON_Then_Bad_Request_Response_Is_Generated() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); ServletInputStream inStream = mock(ServletInputStream.class); when(request.getInputStream()).thenReturn(inStream); groupServlet.doPost(request, response); @@ -219,7 +220,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_POST_And_Group_Description_Is_Too_Long_Then_Bad_Request_Response_Is_Generated() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); GroupServlet groupServlet = overideGetJSONFromInputToReturnAnInvalidGroup(false); groupServlet.doPost(request, response); verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class))); @@ -227,7 +228,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_POST_And_Group_Name_Already_Exists_Then_Bad_Request_Response_Is_Generated() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); GroupServlet groupServlet = overideGetJSONFromInputToReturnGroupInDb(); groupServlet.doPost(request, response); verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class))); @@ -235,7 +236,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_POST_And_POST_Fails_Then_Internal_Server_Error_Response_Is_Generated() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); GroupServlet groupServlet = overideGetJSONFromInputToReturnAValidGroupWithFail(); groupServlet.doPost(request, response); verify(response).sendError(eq(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), argThat(notNullValue(String.class))); @@ -243,7 +244,7 @@ public class GroupServletTest { @Test public void Given_Request_Is_HTTP_POST_And_Request_Succeeds() throws Exception { - when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.group; version=1.0"); + when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.group; version=1.0"); GroupServlet groupServlet = overideGetJSONFromInputToReturnNewGroupToInsert(); ServletOutputStream outStream = mock(ServletOutputStream.class); when(response.getOutputStream()).thenReturn(outStream); @@ -294,7 +295,7 @@ public class GroupServletTest { private GroupServlet overideGetJSONFromInputToReturnAnInvalidGroup(Boolean invalidName) { GroupServlet groupServlet = new GroupServlet() { - protected JSONObject getJSONfromInput(HttpServletRequest req) { + public JSONObject getJSONfromInput(HttpServletRequest req) { JSONObject invalidGroup = new JSONObject(); String invalidEntry = "groupNameThatIsTooLongTooBeValidgroupNameThatIsTooLongTooBeValid"; invalidEntry = invalidEntry + invalidEntry + invalidEntry + invalidEntry + invalidEntry; @@ -317,7 +318,7 @@ public class GroupServletTest { private GroupServlet overideGetJSONFromInputToReturnAValidGroupWithFail() { GroupServlet groupServlet = new GroupServlet() { - protected JSONObject getJSONfromInput(HttpServletRequest req) { + public JSONObject getJSONfromInput(HttpServletRequest req) { JSONObject validGroup = new JSONObject(); validGroup.put("name", "groupName"); validGroup.put("groupid", 2); @@ -341,7 +342,7 @@ public class GroupServletTest { private GroupServlet overideGetJSONFromInputToReturnGroupInDb() { GroupServlet groupServlet = new GroupServlet() { - protected JSONObject getJSONfromInput(HttpServletRequest req) { + public JSONObject getJSONfromInput(HttpServletRequest req) { JSONObject validGroup = new JSONObject(); validGroup.put("name", "Group1"); validGroup.put("groupid", 2); @@ -357,7 +358,7 @@ public class GroupServletTest { private GroupServlet overideGetJSONFromInputToReturnNewGroupToInsert() { GroupServlet groupServlet = new GroupServlet() { - protected JSONObject getJSONfromInput(HttpServletRequest req) { + public JSONObject getJSONfromInput(HttpServletRequest req) { JSONObject validGroup = new JSONObject(); validGroup.put("name", "Group2"); validGroup.put("groupid", 2);