add test cases after the kafka 11 upgrade changes
[dmaap/messagerouter/messageservice.git] / src / test / java / com / att / nsa / dmaap / service / EventsRestServiceTest.java
index 05d39ba..f8e862d 100644 (file)
@@ -30,18 +30,19 @@ import org.mockito.InjectMocks;
 import org.mockito.Mock;\r
 import org.mockito.Mockito;\r
 import org.mockito.MockitoAnnotations;\r
-import static org.mockito.Mockito.when;\r
+import static org.mockito.Matchers.any;\r
 import org.powermock.core.classloader.annotations.PrepareForTest;\r
 import org.powermock.modules.junit4.PowerMockRunner;\r
 import org.powermock.api.mockito.PowerMockito;\r
+import static org.mockito.Mockito.when;\r
 \r
 import com.att.ajsc.beans.PropertiesMapBean;\r
-import com.att.nsa.cambria.CambriaApiException;\r
-import com.att.nsa.cambria.backends.ConsumerFactory.UnavailableException;\r
-import com.att.nsa.cambria.exception.DMaaPErrorMessages;\r
-import com.att.nsa.cambria.service.EventsService;\r
+import com.att.dmf.mr.CambriaApiException;\r
+import com.att.dmf.mr.backends.ConsumerFactory.UnavailableException;\r
+import com.att.dmf.mr.exception.DMaaPErrorMessages;\r
+import com.att.dmf.mr.service.EventsService;\r
 import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.cambria.utils.Utils;\r
+import com.att.dmf.mr.utils.Utils;\r
 import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;\r
 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
 \r
@@ -55,10 +56,10 @@ import javax.servlet.ServletInputStream;
 import javax.servlet.ServletOutputStream;\r
 import javax.servlet.http.HttpServletRequest;\r
 \r
-import com.att.nsa.cambria.beans.DMaaPContext;\r
-import com.att.nsa.cambria.exception.DMaaPAccessDeniedException;\r
-import com.att.nsa.cambria.exception.ErrorResponse;\r
-import com.att.nsa.cambria.metabroker.Broker.TopicExistsException;\r
+import com.att.dmf.mr.beans.DMaaPContext;\r
+import com.att.dmf.mr.exception.DMaaPAccessDeniedException;\r
+import com.att.dmf.mr.exception.ErrorResponse;\r
+import com.att.dmf.mr.metabroker.Broker.TopicExistsException;\r
 \r
 @RunWith(PowerMockRunner.class)\r
 @PrepareForTest({ PropertiesMapBean.class })\r
@@ -108,8 +109,8 @@ public class EventsRestServiceTest {
        public void testGetEvents_error() {\r
 \r
                try {\r
-                       PowerMockito.doThrow(new IOException()).when(eventsService).getEvents(dmaapContext, "topicName",\r
-                                       "consumergroup", "consumerid");\r
+                       PowerMockito.doThrow(new IOException()).when(eventsService).getEvents(any(), any(),\r
+                                       any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | UnavailableException | IOException excp) {\r
                        assertTrue(false);\r
@@ -124,8 +125,8 @@ public class EventsRestServiceTest {
                }\r
 \r
                try {\r
-                       PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).getEvents(dmaapContext, "topicName",\r
-                                       "consumergroup", "consumerid");\r
+                       PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).getEvents(any(), any(),\r
+                                       any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | UnavailableException | IOException excp) {\r
                        assertTrue(false);\r
@@ -140,8 +141,8 @@ public class EventsRestServiceTest {
                }\r
 \r
                try {\r
-                       PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).getEvents(dmaapContext,\r
-                                       "topicName", "consumergroup", "consumerid");\r
+                       PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).getEvents(any(),\r
+                                       any(), any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | UnavailableException | IOException excp) {\r
                        assertTrue(false);\r
@@ -161,8 +162,8 @@ public class EventsRestServiceTest {
        public void testGetEvents_TopicExistException() throws CambriaApiException, ConfigDbException, TopicExistsException,\r
                        UnavailableException, IOException, AccessDeniedException {\r
 \r
-               Mockito.doThrow(new TopicExistsException("topic exists")).when(eventsService).getEvents(dmaapContext,\r
-                               "topicName", "consumergroup", "consumerid");\r
+               Mockito.doThrow(new TopicExistsException("topic exists")).when(eventsService).getEvents(any(),\r
+                               any(), any(), any());\r
 \r
                eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");\r
 \r
@@ -172,8 +173,8 @@ public class EventsRestServiceTest {
        public void testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException, ConfigDbException,\r
                        TopicExistsException, UnavailableException, IOException, AccessDeniedException {\r
 \r
-               Mockito.doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(dmaapContext,\r
-                               "topicName", "consumergroup", "consumerid");\r
+               Mockito.doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(any(),\r
+                               any(), any(), any());\r
 \r
                eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");\r
 \r
@@ -206,8 +207,8 @@ public class EventsRestServiceTest {
        public void testPushEvents_error() {\r
 \r
                try {\r
-                       PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(dmaapContext, "topicName", iStream,\r
-                                       "partitionKey", null);\r
+                       PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(),\r
+                                       any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | missingReqdSetting | IOException excp) {\r
                        assertTrue(false);\r
@@ -222,8 +223,8 @@ public class EventsRestServiceTest {
                }\r
 \r
                try {\r
-                       PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(dmaapContext, "topicName",\r
-                                       iStream, "partitionKey", null);\r
+                       PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(), any(),\r
+                                       any(), any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | missingReqdSetting | IOException excp) {\r
                        assertTrue(false);\r
@@ -238,8 +239,8 @@ public class EventsRestServiceTest {
                }\r
 \r
                try {\r
-                       PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(dmaapContext,\r
-                                       "topicName", iStream, "partitionKey", null);\r
+                       PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(),\r
+                                       any(), any(), any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | missingReqdSetting | IOException excp) {\r
                        assertTrue(false);\r
@@ -275,8 +276,8 @@ public class EventsRestServiceTest {
                ServletInputStream stream = request.getInputStream();\r
 \r
                try {\r
-                       PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(dmaapContext,\r
-                                       "topicName", stream, "partitionKey", Utils.getFormattedDate(new Date()));\r
+                       PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(),\r
+                                       any(), any(), any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | missingReqdSetting | IOException excp) {\r
                        assertTrue(false);\r
@@ -291,8 +292,8 @@ public class EventsRestServiceTest {
                }\r
 \r
                try {\r
-                       PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(dmaapContext, "topicName",\r
-                                       stream, "partitionKey", Utils.getFormattedDate(new Date()));\r
+                       PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(),any(),\r
+                                       any(), any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | missingReqdSetting | IOException excp) {\r
                        assertTrue(false);\r
@@ -307,8 +308,8 @@ public class EventsRestServiceTest {
                }\r
 \r
                try {\r
-                       PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(dmaapContext, "topicName", stream,\r
-                                       "partitionKey", Utils.getFormattedDate(new Date()));\r
+                       PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(),\r
+                                       any(), any());\r
                } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
                                | missingReqdSetting | IOException excp) {\r
                        assertTrue(false);\r