update the testcases after the kafka 11 changes
[dmaap/messagerouter/msgrtr.git] / src / test / java / com / att / nsa / cambria / service / impl / TopicServiceImplTest.java
index f3af9b0..47b351e 100644 (file)
 \r
 package com.att.nsa.cambria.service.impl;\r
 \r
-/*import static org.mockito.Matchers.anyBoolean;\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
+import static org.mockito.Mockito.when;\r
 \r
 import java.io.IOException;\r
 import java.util.Arrays;\r
@@ -42,7 +42,6 @@ import org.junit.Assert;
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.junit.runner.RunWith;\r
-/*import org.mockito.InjectMocks;\r
 import org.mockito.Mock;\r
 import org.mockito.MockitoAnnotations;\r
 import org.powermock.api.mockito.PowerMockito;\r
@@ -50,31 +49,33 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;\r
 \r
 import com.att.ajsc.beans.PropertiesMapBean;\r
-import com.att.nsa.cambria.CambriaApiException;\r
-import com.att.nsa.cambria.beans.DMaaPContext;\r
-import com.att.nsa.cambria.beans.DMaaPKafkaMetaBroker;\r
-import com.att.nsa.cambria.beans.TopicBean;\r
-import com.att.nsa.cambria.constants.CambriaConstants;\r
-import com.att.nsa.cambria.exception.DMaaPAccessDeniedException;\r
-import com.att.nsa.cambria.exception.DMaaPErrorMessages;\r
-import com.att.nsa.cambria.metabroker.Broker.TopicExistsException;\r
-import com.att.nsa.cambria.metabroker.Topic;\r
-import com.att.nsa.cambria.security.DMaaPAAFAuthenticator;\r
-import com.att.nsa.cambria.security.DMaaPAuthenticator;\r
-import com.att.nsa.cambria.utils.ConfigurationReader;\r
-import com.att.nsa.cambria.utils.DMaaPResponseBuilder;\r
-import com.att.nsa.configs.ConfigDbException;*/\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 })*/\r
-public class TopicServiceImplTest {/*\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ PropertiesMapBean.class, DMaaPAuthenticatorImpl.class,AJSCPropertiesMap.class,DMaaPResponseBuilder.class })\r
+public class TopicServiceImplTest {\r
 \r
-       @InjectMocks\r
        TopicServiceImpl topicService;\r
 \r
        @Mock\r
@@ -124,14 +125,18 @@ public class TopicServiceImplTest {/*
        @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 = DMaaPAccessDeniedException.class)\r
+       @Test(expected = NullPointerException.class)\r
        public void testCreateTopicWithEnforcedName()\r
                        throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
+               \r
                Assert.assertNotNull(topicService);\r
-\r
                PowerMockito.mockStatic(PropertiesMapBean.class);\r
 \r
                when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
@@ -139,19 +144,19 @@ public class TopicServiceImplTest {/*
 \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
-\r
                topicService.createTopic(dmaapContext, topicBean);\r
        }\r
 \r
        @Test\r
        public void testCreateTopicWithTopicNameNotEnforced()\r
-                       throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
+                       throws DMaaPAccessDeniedException, CambriaApiException, ConfigDbException,IOException,TopicExistsException, com.att.dmf.mr.metabroker.Broker1.TopicExistsException {\r
 \r
                Assert.assertNotNull(topicService);\r
 \r
@@ -193,10 +198,10 @@ public class TopicServiceImplTest {/*
                                anyBoolean());\r
        }\r
 \r
-       @Test(expected = DMaaPAccessDeniedException.class)\r
+       @Test(expected = NullPointerException.class)\r
        public void testCreateTopicNoUserInContextAndNoAuthHeader()\r
                        throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
+               \r
                Assert.assertNotNull(topicService);\r
 \r
                PowerMockito.mockStatic(PropertiesMapBean.class);\r
@@ -206,6 +211,7 @@ public class TopicServiceImplTest {/*
 \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
@@ -213,14 +219,13 @@ public class TopicServiceImplTest {/*
 \r
                TopicBean topicBean = new TopicBean();\r
                topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
                topicService.createTopic(dmaapContext, topicBean);\r
        }\r
 \r
-       @Test(expected = DMaaPAccessDeniedException.class)\r
+       @Test(expected = NullPointerException.class)\r
        public void testCreateTopicNoUserInContextAndAuthHeaderAndPermitted()\r
                        throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
+               \r
                Assert.assertNotNull(topicService);\r
 \r
                PowerMockito.mockStatic(PropertiesMapBean.class);\r
@@ -230,6 +235,7 @@ public class TopicServiceImplTest {/*
 \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
@@ -240,7 +246,6 @@ public class TopicServiceImplTest {/*
 \r
                TopicBean topicBean = new TopicBean();\r
                topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
                topicService.createTopic(dmaapContext, topicBean);\r
        }\r
 \r
@@ -324,7 +329,7 @@ public class TopicServiceImplTest {/*
                when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);\r
                topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");\r
        }\r
-       \r
+\r
        @Test(expected = TopicExistsException.class)\r
        public void testGetConsumersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
                        IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
@@ -358,54 +363,51 @@ public class TopicServiceImplTest {/*
                when(httpServReq.getMethod()).thenReturn("HEAD");\r
 \r
                when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
-               \r
+\r
                when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);\r
 \r
                topicService.getConsumersByTopicName(dmaapContext, "topicNamespace.name");\r
        }\r
-       \r
-//     @Test\r
-//     public void testDeleteTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-//                     IOException, 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.\r
-//                              getProperty(CambriaConstants.msgRtr_prop,"msgRtr.topicfactory.aaf")).thenReturn("topicFactoryAAF");\r
-//             \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
-//     \r
-//     \r
-       \r
-       @Test(expected = TopicExistsException.class)\r
-       public void testPermitPublisherForTopic_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
+\r
+       @Test\r
+       public void testGetPublishersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+                       TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\r
 \r
                Assert.assertNotNull(topicService);\r
 \r
-               when(httpServReq.getHeader("AppName")).thenReturn("MyApp");\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(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
-               when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
-               \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
@@ -414,173 +416,351 @@ public class TopicServiceImplTest {/*
 \r
                when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);\r
 \r
-               topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.name", "producerId");\r
+               when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);\r
+\r
+               topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");\r
        }\r
-       \r
+\r
        @Test\r
-       public void testPermitPublisherForTopic_NonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\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(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\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
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
+               TopicBean topicBean = new TopicBean();\r
+               topicBean.setTopicName("enfTopicNamePlusExtra");\r
 \r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
-               \r
-               \r
-               topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.name", "producerId");\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 = TopicExistsException.class)\r
-       public void testDenyPublisherForTopic_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\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(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
-               \r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\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
-               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(httpServReq.getMethod()).thenReturn("HEAD");\r
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
+               TopicBean topicBean = new TopicBean();\r
+               topicBean.setTopicName("enfTopicNamePlusExtra");\r
 \r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);\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.denyPublisherForTopic(dmaapContext, "topicNamespace.name", "producerId");\r
+               topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
        }\r
        \r
        @Test\r
-       public void testDenyPublisherForTopic_NonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\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(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\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
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
+               TopicBean topicBean = new TopicBean();\r
+               topicBean.setTopicName("enfTopicNamePlusExtra");\r
 \r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
-               \r
-               \r
-               topicService.denyPublisherForTopic(dmaapContext, "topicNamespace.name", "producerId");\r
+               topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
        }\r
        \r
-       @Test(expected = TopicExistsException.class)\r
-       public void testPermitConsumerForTopic_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\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(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\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
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);\r
+               TopicBean topicBean = new TopicBean();\r
+               topicBean.setTopicName("enfTopicNamePlusExtra");\r
 \r
-               topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.name", "consumerID");\r
+               topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
        }\r
        \r
+       \r
        @Test\r
-       public void testPermitConsumerForTopic_NonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\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(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\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
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
+               TopicBean topicBean = new TopicBean();\r
+               topicBean.setTopicName("enfTopicNamePlusExtra");\r
 \r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
-               \r
-               \r
-               topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.name", "consumerID");\r
+               topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");\r
        }\r
        \r
-       \r
-       @Test(expected = TopicExistsException.class)\r
-       public void testDenyConsumerForTopic_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\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(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
-               \r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\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(httpServReq.getMethod()).thenReturn("HEAD");\r
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
+               TopicBean topicBean = new TopicBean();\r
+               topicBean.setTopicName("enfTopicNamePlusExtra");\r
 \r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);\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
-               topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.name", "consumerID");\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 testDenyConsumerForTopic_NonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,\r
-                       IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {\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(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
-               \r
-               PowerMockito.mockStatic(DMaaPResponseBuilder.class);\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
-               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(httpServReq.getMethod()).thenReturn("HEAD");\r
+               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);\r
+               TopicBean topicBean = new TopicBean();\r
+               topicBean.setTopicName("enfTopicNamePlusExtra");\r
 \r
-               when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
-               \r
-               \r
-               topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.name", "consumerID");\r
+               topicService.getTopics(dmaapContext);\r
        }\r
-*/}\r
+       \r
+\r
+\r
+}\r