Refactor Prov DB handling
[dmaap/datarouter.git] / datarouter-prov / src / test / java / org / onap / dmaap / datarouter / provisioning / GroupServletTest.java
index d6f1e6d..67687d0 100755 (executable)
@@ -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);