update the package name
[dmaap/messagerouter/msgrtr.git] / src / test / java / org / onap / dmaap / mr / cambria / service / impl / EventsServiceImplTest.java
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.cambria.service.impl;\r
-\r
-import static org.mockito.Mockito.when;\r
-import static org.mockito.Matchers.anyString;\r
-import static org.junit.Assert.assertFalse;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.lang.reflect.Constructor;\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.lang.reflect.Method;\r
-import java.util.ConcurrentModificationException;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.mock.web.MockHttpServletRequest;\r
-import org.springframework.mock.web.MockHttpServletResponse;\r
-\r
-import com.att.ajsc.beans.PropertiesMapBean;\r
-import com.att.ajsc.filemonitor.AJSCPropertiesMap;\r
-import com.att.dmf.mr.CambriaApiException;\r
-import com.att.dmf.mr.security.DMaaPAAFAuthenticator;\r
-import com.att.dmf.mr.security.DMaaPAuthenticator;\r
-import com.att.dmf.mr.security.DMaaPAuthenticatorImpl;\r
-import com.att.dmf.mr.utils.ConfigurationReader;\r
-import com.att.dmf.mr.backends.ConsumerFactory.UnavailableException;\r
-import com.att.dmf.mr.beans.DMaaPCambriaLimiter;\r
-import com.att.dmf.mr.backends.ConsumerFactory;\r
-import com.att.dmf.mr.beans.DMaaPContext;\r
-import com.att.dmf.mr.beans.DMaaPKafkaMetaBroker;\r
-import com.att.dmf.mr.constants.CambriaConstants;\r
-import com.att.dmf.mr.exception.DMaaPAccessDeniedException;\r
-import com.att.dmf.mr.exception.DMaaPErrorMessages;\r
-import com.att.dmf.mr.metabroker.Topic;\r
-import com.att.dmf.mr.metabroker.Broker.TopicExistsException;\r
-import com.att.dmf.mr.service.impl.EventsServiceImpl;\r
-import com.att.dmf.mr.utils.PropertyReader;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.drumlin.till.nv.rrNvReadable.invalidSettingValue;\r
-import com.att.nsa.drumlin.till.nv.rrNvReadable.loadException;\r
-import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;\r
-import com.att.nsa.limits.Blacklist;\r
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
-import com.att.nsa.security.NsaApiKey;\r
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;\r
-\r
-import kafka.admin.AdminUtils;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ DMaaPAuthenticatorImpl.class, AJSCPropertiesMap.class })\r
-public class EventsServiceImplTest {\r
-\r
-       private InputStream iStream = null;\r
-       DMaaPContext dMaapContext = new DMaaPContext();\r
-       EventsServiceImpl service = new EventsServiceImpl();\r
-       DMaaPErrorMessages pErrorMessages = new DMaaPErrorMessages();\r
-       @Mock\r
-       ConfigurationReader configurationReader;\r
-       @Mock\r
-       Blacklist blacklist;\r
-       @Mock\r
-       DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;\r
-       @Mock\r
-       DMaaPAAFAuthenticator dmaapAAFauthenticator;\r
-       @Mock\r
-       NsaApiKey user;\r
-       @Mock\r
-       NsaSimpleApiKey nsaSimpleApiKey;\r
-       @Mock\r
-       DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;\r
-       @Mock\r
-       Topic createdTopic;\r
-       @Mock\r
-       ConsumerFactory factory;\r
-\r
-       @Before\r
-       public void setUp() throws Exception {\r
-               MockitoAnnotations.initMocks(this);\r
-               String source = "source of my InputStream";\r
-               iStream = new ByteArrayInputStream(source.getBytes("UTF-8"));\r
-\r
-               MockHttpServletRequest request = new MockHttpServletRequest();\r
-               MockHttpServletResponse response = new MockHttpServletResponse();\r
-               dMaapContext.setRequest(request);\r
-               dMaapContext.setResponse(response);\r
-               when(blacklist.contains(anyString())).thenReturn(false);\r
-               when(configurationReader.getfIpBlackList()).thenReturn(blacklist);\r
-               dMaapContext.setConfigReader(configurationReader);\r
-\r
-               service.setErrorMessages(pErrorMessages);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "timeout")).thenReturn("100");\r
-\r
-               AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "timeout");\r
-\r
-       }\r
-\r
-       @Test(expected = CambriaApiException.class)\r
-       public void testGetEvents() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-               service.getEvents(dMaapContext, "testTopic", "CG1", "23");\r
-       }\r
-\r
-       @Test(expected = CambriaApiException.class)\r
-       public void testGetEventsBlackListErr() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {\r
-               when(blacklist.contains(anyString())).thenReturn(true);\r
-               when(configurationReader.getfIpBlackList()).thenReturn(blacklist);\r
-               dMaapContext.setConfigReader(configurationReader);\r
-               service.getEvents(dMaapContext, "testTopic", "CG1", "23");\r
-       }\r
-\r
-       @Test(expected = CambriaApiException.class)\r
-       public void testGetEventsNoTopicError() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(null);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-               service.getEvents(dMaapContext, "testTopic", "CG1", "23");\r
-       }\r
-\r
-       @Test(expected = CambriaApiException.class)\r
-       public void testGetEventsuserNull() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(null);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-               MockHttpServletRequest mockRequest = new MockHttpServletRequest();\r
-               mockRequest.addHeader("Authorization", "passed");\r
-               dMaapContext.setRequest(mockRequest);\r
-               dMaapContext.getRequest().getHeader("Authorization");\r
-               service.getEvents(dMaapContext, "testTopic", "CG1", "23");\r
-       }\r
-\r
-       @Test(expected = CambriaApiException.class)\r
-       public void testGetEventsExcp2() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-               when(configurationReader.getfRateLimiter()).thenThrow(new ConcurrentModificationException("Error occurred"));\r
-               service.getEvents(dMaapContext, "testTopic", "CG1", "23");\r
-       }\r
-\r
-       @Test(expected = CambriaApiException.class)\r
-       public void testPushEvents() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,\r
-                       invalidSettingValue, loadException {\r
-\r
-               // AdminUtils.createTopic(configurationReader.getZk(), "testTopic", 10,\r
-               // 1, new Properties());\r
-\r
-               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));\r
-\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-\r
-               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");\r
-\r
-               service.getEvents(dMaapContext, "testTopic", "CG1", "23");\r
-\r
-               /*\r
-                * String trueValue = "True";\r
-                * assertTrue(trueValue.equalsIgnoreCase("True"));\r
-                */\r
-\r
-       }\r
-\r
-       @Test(expected = CambriaApiException.class)\r
-       public void testPushEventsBlackListedIp() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,\r
-                       invalidSettingValue, loadException {\r
-\r
-               // AdminUtils.createTopic(configurationReader.getZk(), "testTopic", 10,\r
-               // 1, new Properties());\r
-               when(blacklist.contains(anyString())).thenReturn(true);\r
-               when(configurationReader.getfIpBlackList()).thenReturn(blacklist);\r
-               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-\r
-               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");\r
-\r
-       }\r
-\r
-       @Test(expected = NullPointerException.class)\r
-       public void testPushEventsNoUser() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,\r
-                       invalidSettingValue, loadException {\r
-\r
-               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));\r
-\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(null);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-               MockHttpServletRequest mockRequest = new MockHttpServletRequest();\r
-               mockRequest.addHeader("Authorization", "passed");\r
-               mockRequest.addHeader("Authorization", "passed");\r
-               dMaapContext.setRequest(mockRequest);\r
-               dMaapContext.getRequest().getHeader("Authorization");\r
-               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");\r
-\r
-       }\r
-\r
-       @Test(expected = CambriaApiException.class)\r
-       public void testPushEventsWtTransaction() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,\r
-                       invalidSettingValue, loadException {\r
-\r
-               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));\r
-\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "transidUEBtopicreqd")).thenReturn("true");\r
-\r
-               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");\r
-\r
-       }\r
-       \r
-       @Test(expected = CambriaApiException.class)\r
-       public void testPushEventsWtTransactionError() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,\r
-                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,\r
-                       invalidSettingValue, loadException {\r
-\r
-               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));\r
-\r
-               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);\r
-               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);\r
-               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "transidUEBtopicreqd")).thenReturn("true");\r
-               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "event.batch.length")).thenReturn("0");\r
-               when(configurationReader.getfPublisher()).thenThrow(new ConcurrentModificationException("Error occurred"));\r
-\r
-               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");\r
-\r
-       }\r
-       \r
-       @Test\r
-       public void testIsTransEnabled1() {\r
-\r
-               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,\r
-                               "transidUEBtopicreqd")).thenReturn("true");\r
-                 assertTrue(service.isTransEnabled());\r
-\r
-       }\r
-       @Test\r
-       public void testIsTransEnabled2() {\r
-\r
-               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,\r
-                               "transidUEBtopicreqd")).thenReturn("false");\r
-                 assertFalse(service.isTransEnabled());\r
-\r
-       }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+ package org.onap.dmaap.mr.cambria.service.impl;
+
+import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.anyString;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ConcurrentModificationException;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+import com.att.ajsc.beans.PropertiesMapBean;
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticatorImpl;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;
+import org.onap.dmaap.dmf.mr.beans.DMaaPCambriaLimiter;
+import org.onap.dmaap.dmf.mr.backends.ConsumerFactory;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
+import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;
+import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
+import org.onap.dmaap.dmf.mr.service.impl.EventsServiceImpl;
+import org.onap.dmaap.dmf.mr.utils.PropertyReader;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.drumlin.till.nv.rrNvReadable.invalidSettingValue;
+import com.att.nsa.drumlin.till.nv.rrNvReadable.loadException;
+import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;
+import com.att.nsa.limits.Blacklist;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import com.att.nsa.security.NsaApiKey;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+
+import kafka.admin.AdminUtils;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ DMaaPAuthenticatorImpl.class, AJSCPropertiesMap.class })
+public class EventsServiceImplTest {
+
+       private InputStream iStream = null;
+       DMaaPContext dMaapContext = new DMaaPContext();
+       EventsServiceImpl service = new EventsServiceImpl();
+       DMaaPErrorMessages pErrorMessages = new DMaaPErrorMessages();
+       @Mock
+       ConfigurationReader configurationReader;
+       @Mock
+       Blacklist blacklist;
+       @Mock
+       DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
+       @Mock
+       DMaaPAAFAuthenticator dmaapAAFauthenticator;
+       @Mock
+       NsaApiKey user;
+       @Mock
+       NsaSimpleApiKey nsaSimpleApiKey;
+       @Mock
+       DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;
+       @Mock
+       Topic createdTopic;
+       @Mock
+       ConsumerFactory factory;
+
+       @Before
+       public void setUp() throws Exception {
+               MockitoAnnotations.initMocks(this);
+               String source = "source of my InputStream";
+               iStream = new ByteArrayInputStream(source.getBytes("UTF-8"));
+
+               MockHttpServletRequest request = new MockHttpServletRequest();
+               MockHttpServletResponse response = new MockHttpServletResponse();
+               dMaapContext.setRequest(request);
+               dMaapContext.setResponse(response);
+               when(blacklist.contains(anyString())).thenReturn(false);
+               when(configurationReader.getfIpBlackList()).thenReturn(blacklist);
+               dMaapContext.setConfigReader(configurationReader);
+
+               service.setErrorMessages(pErrorMessages);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "timeout")).thenReturn("100");
+
+               AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "timeout");
+
+       }
+
+       @Test(expected = CambriaApiException.class)
+       public void testGetEvents() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+               service.getEvents(dMaapContext, "testTopic", "CG1", "23");
+       }
+
+       @Test(expected = CambriaApiException.class)
+       public void testGetEventsBlackListErr() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {
+               when(blacklist.contains(anyString())).thenReturn(true);
+               when(configurationReader.getfIpBlackList()).thenReturn(blacklist);
+               dMaapContext.setConfigReader(configurationReader);
+               service.getEvents(dMaapContext, "testTopic", "CG1", "23");
+       }
+
+       @Test(expected = CambriaApiException.class)
+       public void testGetEventsNoTopicError() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(null);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+               service.getEvents(dMaapContext, "testTopic", "CG1", "23");
+       }
+
+       @Test(expected = CambriaApiException.class)
+       public void testGetEventsuserNull() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(null);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+               MockHttpServletRequest mockRequest = new MockHttpServletRequest();
+               mockRequest.addHeader("Authorization", "passed");
+               dMaapContext.setRequest(mockRequest);
+               dMaapContext.getRequest().getHeader("Authorization");
+               service.getEvents(dMaapContext, "testTopic", "CG1", "23");
+       }
+
+       @Test(expected = CambriaApiException.class)
+       public void testGetEventsExcp2() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException {
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+               when(configurationReader.getfRateLimiter()).thenThrow(new ConcurrentModificationException("Error occurred"));
+               service.getEvents(dMaapContext, "testTopic", "CG1", "23");
+       }
+
+       @Test(expected = CambriaApiException.class)
+       public void testPushEvents() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,
+                       invalidSettingValue, loadException {
+
+               // AdminUtils.createTopic(configurationReader.getZk(), "testTopic", 10,
+               // 1, new Properties());
+
+               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));
+
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+
+               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");
+
+               service.getEvents(dMaapContext, "testTopic", "CG1", "23");
+
+               /*
+                * String trueValue = "True";
+                * assertTrue(trueValue.equalsIgnoreCase("True"));
+                */
+
+       }
+
+       @Test(expected = CambriaApiException.class)
+       public void testPushEventsBlackListedIp() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,
+                       invalidSettingValue, loadException {
+
+               // AdminUtils.createTopic(configurationReader.getZk(), "testTopic", 10,
+               // 1, new Properties());
+               when(blacklist.contains(anyString())).thenReturn(true);
+               when(configurationReader.getfIpBlackList()).thenReturn(blacklist);
+               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+
+               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");
+
+       }
+
+       @Test(expected = NullPointerException.class)
+       public void testPushEventsNoUser() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,
+                       invalidSettingValue, loadException {
+
+               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));
+
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(null);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+               MockHttpServletRequest mockRequest = new MockHttpServletRequest();
+               mockRequest.addHeader("Authorization", "passed");
+               mockRequest.addHeader("Authorization", "passed");
+               dMaapContext.setRequest(mockRequest);
+               dMaapContext.getRequest().getHeader("Authorization");
+               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");
+
+       }
+
+       @Test(expected = CambriaApiException.class)
+       public void testPushEventsWtTransaction() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,
+                       invalidSettingValue, loadException {
+
+               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));
+
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "transidUEBtopicreqd")).thenReturn("true");
+
+               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");
+
+       }
+       
+       @Test(expected = CambriaApiException.class)
+       public void testPushEventsWtTransactionError() throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,
+                       TopicExistsException, AccessDeniedException, UnavailableException, IOException, missingReqdSetting,
+                       invalidSettingValue, loadException {
+
+               configurationReader.setfRateLimiter(new DMaaPCambriaLimiter(new PropertyReader()));
+
+               when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(createdTopic);
+               PowerMockito.when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "transidUEBtopicreqd")).thenReturn("true");
+               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "event.batch.length")).thenReturn("0");
+               when(configurationReader.getfPublisher()).thenThrow(new ConcurrentModificationException("Error occurred"));
+
+               service.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");
+
+       }
+       
+       @Test
+       public void testIsTransEnabled1() {
+
+               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,
+                               "transidUEBtopicreqd")).thenReturn("true");
+                 assertTrue(service.isTransEnabled());
+
+       }
+       @Test
+       public void testIsTransEnabled2() {
+
+               when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,
+                               "transidUEBtopicreqd")).thenReturn("false");
+                 assertFalse(service.isTransEnabled());
+
+       }
+
+}