import org.json.JSONObject;\r
import org.junit.Assert;\r
import org.junit.Before;\r
-import org.junit.ClassRule;\r
-import org.junit.Rule;\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
import org.powermock.core.classloader.annotations.PrepareForTest;\r
import org.powermock.modules.junit4.PowerMockRunner;\r
-import org.powermock.modules.junit4.rule.PowerMockRule;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\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.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.db.simple.NsaSimpleApiKey;\r
\r
//@RunWith(MockitoJUnitRunner.class)\r
-//@RunWith(PowerMockRunner.class)\r
-//@RunWith(SpringJUnit4ClassRunner.class)\r
-//@ContextConfiguration("classpath:/spring-context.xml")\r
-//@PrepareForTest({ PropertiesMapBean.class })\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ PropertiesMapBean.class, DMaaPAuthenticatorImpl.class,AJSCPropertiesMap.class,DMaaPResponseBuilder.class })\r
public class TopicServiceImplTest {\r
\r
- /*@Rule\r
- public PowerMockRule rule = new PowerMockRule();*/\r
- \r
- //@Autowired\r
- /*TopicServiceImpl topicService;\r
+ TopicServiceImpl topicService;\r
\r
@Mock\r
private DMaaPErrorMessages errorMessages;\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
\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
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
\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
\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
\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
\r
TopicBean topicBean = new TopicBean();\r
topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
topicService.createTopic(dmaapContext, topicBean);\r
}\r
\r
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
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
\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
+ 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.name", "consumerID");\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
+ topicService.getTopics(dmaapContext);\r
+ }\r
+ \r
+\r
\r
- when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);\r
- \r
- \r
- topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.name", "consumerID");\r
- }*/\r
}\r