update the package name
[dmaap/messagerouter/msgrtr.git] / src / test / java / org / onap / dmaap / mr / cambria / service / impl / TopicServiceImplTest.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.Matchers.anyBoolean;\r
-import static org.mockito.Matchers.anyInt;\r
-import static org.mockito.Matchers.anyString;\r
-import static org.mockito.Mockito.times;\r
-import static org.mockito.Mockito.verify;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.io.IOException;\r
-import java.util.Arrays;\r
-import java.util.HashSet;\r
-\r
-import javax.servlet.ServletOutputStream;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.json.JSONArray;\r
-import org.json.JSONException;\r
-import org.json.JSONObject;\r
-import org.junit.Assert;\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
-\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.beans.DMaaPContext;\r
-import com.att.dmf.mr.beans.DMaaPKafkaMetaBroker;\r
-import com.att.dmf.mr.beans.TopicBean;\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.Broker.TopicExistsException;\r
-import com.att.dmf.mr.metabroker.Topic;\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.service.impl.TopicServiceImpl;\r
-import com.att.dmf.mr.utils.ConfigurationReader;\r
-import com.att.dmf.mr.utils.DMaaPResponseBuilder;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.security.NsaAcl;\r
-import com.att.nsa.security.NsaApiKey;\r
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;\r
-\r
-//@RunWith(MockitoJUnitRunner.class)\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ PropertiesMapBean.class, DMaaPAuthenticatorImpl.class,AJSCPropertiesMap.class,DMaaPResponseBuilder.class })\r
-public class TopicServiceImplTest {\r
-\r
-       TopicServiceImpl topicService;\r
-\r
-       @Mock\r
-       private DMaaPErrorMessages errorMessages;\r
-\r
-       @Mock\r
-       DMaaPContext dmaapContext;\r
-\r
-       @Mock\r
-       ConfigurationReader configReader;\r
-\r
-       @Mock\r
-       ServletOutputStream oStream;\r
-\r
-       @Mock\r
-       DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;\r
-\r
-       @Mock\r
-       DMaaPAAFAuthenticator dmaapAAFauthenticator;\r
-       @Mock\r
-       NsaApiKey user;\r
-\r
-       @Mock\r
-       NsaSimpleApiKey nsaSimpleApiKey;\r
-\r
-       @Mock\r
-       HttpServletRequest httpServReq;\r
-\r
-       @Mock\r
-       HttpServletResponse httpServRes;\r
-\r
-       @Mock\r
-       DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;\r
-\r
-       @Mock\r
-       Topic createdTopic;\r
-\r
-       @Mock\r
-       NsaAcl nsaAcl;\r
-\r
-       @Mock\r
-       JSONObject jsonObj;\r
-\r
-       @Mock\r
-       JSONArray jsonArray;\r
-\r
-       @Before\r
-       public void setUp() {\r
-               MockitoAnnotations.initMocks(this);\r
-               topicService = new TopicServiceImpl();\r
-               topicService.setErrorMessages(errorMessages);\r
-               NsaSimpleApiKey user = new NsaSimpleApiKey("admin", "password");\r
-               PowerMockito.mockStatic(DMaaPAuthenticatorImpl.class);\r
-               PowerMockito.when(DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext)).thenReturn(user);\r
-       }\r
-\r
-       @Test(expected = NullPointerException.class)\r
-       public void testCreateTopicWithEnforcedName()\r
-                       throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-               \r
-               Assert.assertNotNull(topicService);\r
-               PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
-               when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
-                               .thenReturn("enfTopicName");\r
-\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-               topicService.createTopic(dmaapContext, topicBean);\r
-       }\r
-\r
-       @Test\r
-       public void testCreateTopicWithTopicNameNotEnforced()\r
-                       throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,IOException,TopicExistsException, com.att.dmf.mr.metabroker.Broker1.TopicExistsException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(PropertiesMapBean.class);\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-\r
-               when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
-                               .thenReturn("enfTopicName");\r
-\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-\r
-               when(nsaAcl.isActive()).thenReturn(true);\r
-               when(nsaAcl.getUsers()).thenReturn(new HashSet<>(Arrays.asList("user1,user2".split(","))));\r
-\r
-               when(createdTopic.getName()).thenReturn("topicName");\r
-               when(createdTopic.getOwner()).thenReturn("Owner");\r
-               when(createdTopic.getDescription()).thenReturn("Description");\r
-               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);\r
-               when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);\r
-\r
-               when(dmaapKafkaMetaBroker.createTopic(anyString(), anyString(), anyString(), anyInt(), anyInt(), anyBoolean()))\r
-                               .thenReturn(createdTopic);\r
-\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("NotEnforcedTopicName");\r
-\r
-               topicService.createTopic(dmaapContext, topicBean);\r
-\r
-               verify(dmaapKafkaMetaBroker, times(1)).createTopic(anyString(), anyString(), anyString(), anyInt(), anyInt(),\r
-                               anyBoolean());\r
-       }\r
-\r
-       @Test(expected = NullPointerException.class)\r
-       public void testCreateTopicNoUserInContextAndNoAuthHeader()\r
-                       throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-               \r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
-               when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
-                               .thenReturn("enfTopicName");\r
-\r
-               when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-               topicService.createTopic(dmaapContext, topicBean);\r
-       }\r
-\r
-       @Test(expected = NullPointerException.class)\r
-       public void testCreateTopicNoUserInContextAndAuthHeaderAndPermitted()\r
-                       throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-               \r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
-               when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
-                               .thenReturn("enfTopicName");\r
-\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
-               // when(dmaapAAFauthenticator.aafAuthentication(httpServReq,\r
-               // anyString())).thenReturn(false);\r
-\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-               topicService.createTopic(dmaapContext, topicBean);\r
-       }\r
-\r
-       @Test(expected = TopicExistsException.class)\r
-       public void testGetTopics_null_topic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
-\r
-               topicService.getTopic(dmaapContext, "topicName");\r
-       }\r
-\r
-       @Test\r
-       public void testGetTopics_NonNull_topic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-\r
-               when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(createdTopic);\r
-\r
-               when(createdTopic.getName()).thenReturn("topicName");\r
-               when(createdTopic.getDescription()).thenReturn("topicDescription");\r
-               when(createdTopic.getOwners()).thenReturn(new HashSet<>(Arrays.asList("user1,user2".split(","))));\r
-\r
-               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);\r
-               when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);\r
-\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(httpServRes.getOutputStream()).thenReturn(oStream);\r
-\r
-               topicService.getTopic(dmaapContext, "topicName");\r
-       }\r
-\r
-       @Test(expected = TopicExistsException.class)\r
-       public void testGetPublishersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);\r
-\r
-               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");\r
-\r
-       }\r
-\r
-       @Test\r
-       public void testGetPublishersByTopicName_nonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
-               when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);\r
-               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");\r
-       }\r
-\r
-       @Test(expected = TopicExistsException.class)\r
-       public void testGetConsumersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);\r
-\r
-               topicService.getConsumersByTopicName(dmaapContext, "topicNamespace.name");\r
-\r
-       }\r
-\r
-       @Test\r
-       public void testGetConsumersByTopicName_nonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
-\r
-               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);\r
-\r
-               topicService.getConsumersByTopicName(dmaapContext, "topicNamespace.name");\r
-       }\r
-\r
-       @Test\r
-       public void testGetPublishersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("topicFactoryAAF");\r
-\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
-\r
-               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);\r
-\r
-               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");\r
-       }\r
-       \r
-       @Test(expected=TopicExistsException.class)\r
-       public void testGetPublishersByTopicNameError() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("topicFactoryAAF");\r
-\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);\r
-\r
-               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);\r
-\r
-               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");\r
-       }\r
-\r
-       @Test\r
-       public void testdeleteTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.deleteTopic(dmaapContext, "topicNamespace.topic");\r
-       }\r
-       \r
-       @Test(expected=TopicExistsException.class)\r
-       public void testdeleteTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.deleteTopic(dmaapContext, "topicNamespace.topic");\r
-       }\r
-       \r
-       /*@Test(expected=DMaaPAccessDeniedException.class)\r
-       public void testdeleteTopic_authHeader() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-               PowerMockito.when(DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext)).thenReturn(null);\r
-               topicService.deleteTopic(dmaapContext, "topicNamespace.topic");\r
-       }*/\r
-       \r
-       @Test\r
-       public void testPermitConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
-       }\r
-       \r
-       @Test(expected=TopicExistsException.class)\r
-       public void testPermitConsumerForTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
-       }\r
-       \r
-       @Test\r
-       public void testdenyConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
-       }\r
-       \r
-       @Test(expected=TopicExistsException.class)\r
-       public void testdenyConsumerForTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
-       }\r
-       \r
-       \r
-       @Test\r
-       public void testPermitPublisherForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
-       }\r
-       \r
-       @Test(expected=TopicExistsException.class)\r
-       public void testPermitPublisherForTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
-       }\r
-       \r
-       @Test\r
-       public void testDenyPublisherForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-               when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.denyPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");;\r
-       }\r
-       \r
-       @Test(expected=TopicExistsException.class)\r
-       public void testDenyPublisherForTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.denyPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");;\r
-       }\r
-       \r
-       @Test\r
-       public void testGetAllTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.getAllTopics(dmaapContext);\r
-       }\r
-       \r
-       @Test\r
-       public void testGetTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
-                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
-\r
-               Assert.assertNotNull(topicService);\r
-\r
-               // PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))\r
-                               .thenReturn("hello");\r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);\r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\r
-               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
-               when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
-               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
-               TopicBean topicBean = new TopicBean();\r
-               topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
-               topicService.getTopics(dmaapContext);\r
-       }\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.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Assert;
+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 com.att.ajsc.beans.PropertiesMapBean;
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+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.Broker.TopicExistsException;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+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.service.impl.TopicServiceImpl;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.NsaAcl;
+import com.att.nsa.security.NsaApiKey;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+
+//@RunWith(MockitoJUnitRunner.class)
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ PropertiesMapBean.class, DMaaPAuthenticatorImpl.class,AJSCPropertiesMap.class,DMaaPResponseBuilder.class })
+public class TopicServiceImplTest {
+
+       TopicServiceImpl topicService;
+
+       @Mock
+       private DMaaPErrorMessages errorMessages;
+
+       @Mock
+       DMaaPContext dmaapContext;
+
+       @Mock
+       ConfigurationReader configReader;
+
+       @Mock
+       ServletOutputStream oStream;
+
+       @Mock
+       DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
+
+       @Mock
+       DMaaPAAFAuthenticator dmaapAAFauthenticator;
+       @Mock
+       NsaApiKey user;
+
+       @Mock
+       NsaSimpleApiKey nsaSimpleApiKey;
+
+       @Mock
+       HttpServletRequest httpServReq;
+
+       @Mock
+       HttpServletResponse httpServRes;
+
+       @Mock
+       DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;
+
+       @Mock
+       Topic createdTopic;
+
+       @Mock
+       NsaAcl nsaAcl;
+
+       @Mock
+       JSONObject jsonObj;
+
+       @Mock
+       JSONArray jsonArray;
+
+       @Before
+       public void setUp() {
+               MockitoAnnotations.initMocks(this);
+               topicService = new TopicServiceImpl();
+               topicService.setErrorMessages(errorMessages);
+               NsaSimpleApiKey user = new NsaSimpleApiKey("admin", "password");
+               PowerMockito.mockStatic(DMaaPAuthenticatorImpl.class);
+               PowerMockito.when(DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext)).thenReturn(user);
+       }
+
+       @Test(expected = NullPointerException.class)
+       public void testCreateTopicWithEnforcedName()
+                       throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
+               
+               Assert.assertNotNull(topicService);
+               PowerMockito.mockStatic(PropertiesMapBean.class);
+
+               when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))
+                               .thenReturn("enfTopicName");
+
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+               topicService.createTopic(dmaapContext, topicBean);
+       }
+
+       @Test
+       public void testCreateTopicWithTopicNameNotEnforced()
+                       throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,IOException,TopicExistsException, org.onap.dmaap.dmf.mr.metabroker.Broker1.TopicExistsException {
+
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(PropertiesMapBean.class);
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+
+               when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))
+                               .thenReturn("enfTopicName");
+
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+
+               when(nsaAcl.isActive()).thenReturn(true);
+               when(nsaAcl.getUsers()).thenReturn(new HashSet<>(Arrays.asList("user1,user2".split(","))));
+
+               when(createdTopic.getName()).thenReturn("topicName");
+               when(createdTopic.getOwner()).thenReturn("Owner");
+               when(createdTopic.getDescription()).thenReturn("Description");
+               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);
+               when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);
+
+               when(dmaapKafkaMetaBroker.createTopic(anyString(), anyString(), anyString(), anyInt(), anyInt(), anyBoolean()))
+                               .thenReturn(createdTopic);
+
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("NotEnforcedTopicName");
+
+               topicService.createTopic(dmaapContext, topicBean);
+
+               verify(dmaapKafkaMetaBroker, times(1)).createTopic(anyString(), anyString(), anyString(), anyInt(), anyInt(),
+                               anyBoolean());
+       }
+
+       @Test(expected = NullPointerException.class)
+       public void testCreateTopicNoUserInContextAndNoAuthHeader()
+                       throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
+               
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(PropertiesMapBean.class);
+
+               when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))
+                               .thenReturn("enfTopicName");
+
+               when(httpServReq.getHeader("Authorization")).thenReturn(null);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+               topicService.createTopic(dmaapContext, topicBean);
+       }
+
+       @Test(expected = NullPointerException.class)
+       public void testCreateTopicNoUserInContextAndAuthHeaderAndPermitted()
+                       throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
+               
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(PropertiesMapBean.class);
+
+               when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))
+                               .thenReturn("enfTopicName");
+
+               when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+
+               // when(dmaapAAFauthenticator.aafAuthentication(httpServReq,
+               // anyString())).thenReturn(false);
+
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+               topicService.createTopic(dmaapContext, topicBean);
+       }
+
+       @Test(expected = TopicExistsException.class)
+       public void testGetTopics_null_topic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException {
+
+               Assert.assertNotNull(topicService);
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);
+
+               topicService.getTopic(dmaapContext, "topicName");
+       }
+
+       @Test
+       public void testGetTopics_NonNull_topic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException {
+
+               Assert.assertNotNull(topicService);
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+
+               when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(createdTopic);
+
+               when(createdTopic.getName()).thenReturn("topicName");
+               when(createdTopic.getDescription()).thenReturn("topicDescription");
+               when(createdTopic.getOwners()).thenReturn(new HashSet<>(Arrays.asList("user1,user2".split(","))));
+
+               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);
+               when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);
+
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(httpServRes.getOutputStream()).thenReturn(oStream);
+
+               topicService.getTopic(dmaapContext, "topicName");
+       }
+
+       @Test(expected = TopicExistsException.class)
+       public void testGetPublishersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
+                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);
+
+               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");
+
+       }
+
+       @Test
+       public void testGetPublishersByTopicName_nonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
+                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);
+               when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);
+               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");
+       }
+
+       @Test(expected = TopicExistsException.class)
+       public void testGetConsumersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
+                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);
+
+               topicService.getConsumersByTopicName(dmaapContext, "topicNamespace.name");
+
+       }
+
+       @Test
+       public void testGetConsumersByTopicName_nonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
+                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);
+
+               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);
+
+               topicService.getConsumersByTopicName(dmaapContext, "topicNamespace.name");
+       }
+
+       @Test
+       public void testGetPublishersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("topicFactoryAAF");
+
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);
+
+               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);
+
+               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");
+       }
+       
+       @Test(expected=TopicExistsException.class)
+       public void testGetPublishersByTopicNameError() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("topicFactoryAAF");
+
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(httpServReq.getMethod()).thenReturn("HEAD");
+
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);
+
+               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);
+
+               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");
+       }
+
+       @Test
+       public void testdeleteTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.deleteTopic(dmaapContext, "topicNamespace.topic");
+       }
+       
+       @Test(expected=TopicExistsException.class)
+       public void testdeleteTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.deleteTopic(dmaapContext, "topicNamespace.topic");
+       }
+       
+       /*@Test(expected=DMaaPAccessDeniedException.class)
+       public void testdeleteTopic_authHeader() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+               PowerMockito.when(DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext)).thenReturn(null);
+               topicService.deleteTopic(dmaapContext, "topicNamespace.topic");
+       }*/
+       
+       @Test
+       public void testPermitConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");
+       }
+       
+       @Test(expected=TopicExistsException.class)
+       public void testPermitConsumerForTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");
+       }
+       
+       @Test
+       public void testdenyConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");
+       }
+       
+       @Test(expected=TopicExistsException.class)
+       public void testdenyConsumerForTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");
+       }
+       
+       
+       @Test
+       public void testPermitPublisherForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");
+       }
+       
+       @Test(expected=TopicExistsException.class)
+       public void testPermitPublisherForTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");
+       }
+       
+       @Test
+       public void testDenyPublisherForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+               when(dmaapContext.getResponse()).thenReturn(httpServRes);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.denyPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");;
+       }
+       
+       @Test(expected=TopicExistsException.class)
+       public void testDenyPublisherForTopic_nulltopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.denyPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");;
+       }
+       
+       @Test
+       public void testGetAllTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.getAllTopics(dmaapContext);
+       }
+       
+       @Test
+       public void testGetTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+               Assert.assertNotNull(topicService);
+
+               // PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.mockStatic(AJSCPropertiesMap.class);
+               PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.topicfactory.aaf"))
+                               .thenReturn("hello");
+               PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(null);
+               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");
+               when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
+               when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+               when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+               when(dmaapContext.getConfigReader()).thenReturn(configReader);
+               when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+               TopicBean topicBean = new TopicBean();
+               topicBean.setTopicName("enfTopicNamePlusExtra");
+
+               topicService.getTopics(dmaapContext);
+       }
+       
+
+
+}