<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>2.1.0</version>
+ <version>3.2.0</version>
</parent>
<properties>
<cxf.version>3.0.4</cxf.version>
<jstl.version>1.2</jstl.version>
<log4j.version>2.13.3</log4j.version>
- <maven.compiler.target>1.7</maven.compiler.target>
- <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>11</maven.compiler.target>
+ <maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
<sonar.language>java</sonar.language>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
- <version>1.2.0</version>
+ <version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <version>1.2.0</version>
+ <version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.11</version>
+ <version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.6</version>
+ <version>1.7.28</version>
</dependency>
<!-- Log4j2 logger -->
<dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
- <version>4.3.18.RELEASE</version>
+ <version>5.2.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
- <version>5.2.3.RELEASE</version>
+ <version>5.2.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
- <version>4.3.18.RELEASE</version>
+ <version>5.2.10.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
+ <version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
- <version>20131018</version>
+ <version>20160810</version>
</dependency>
<!-- Apache Kafka -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>23.6.1-jre</version>
+ <version>30.1.1-jre</version>
</dependency>
<dependency>
<groupId>com.att.eelf</groupId>
<artifactId>eelf-core</artifactId>
- <version>0.0.1</version>
- <scope>compile</scope>
+ <version>1.0.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- our NSA server library -->
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <!-- sun.security.acl? -->
+
<!-- our base client library, for its command line tools -->
<dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.8.11</version>
+ <version>2.12.2</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.11.2</version>
+ <version>2.12.2</version>
</dependency>
-
<dependency>
<groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>2.0.7</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.4</version>
+ <artifactId>powermock-core</artifactId>
+ <version>2.0.7</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4-rule</artifactId>
- <version>1.6.4</version>
+ <version>2.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-support</artifactId>
+ <version>2.0.7</version>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <version>2.0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
</dependencies>
-
<build>
<finalName>DMaaP</finalName>
<resources>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.17</version>
+ <version>3.1.2</version>
<dependencies>
<dependency>
<groupId>org.onap.oparent</groupId>
<artifactId>checkstyle</artifactId>
- <version>2.0.0</version>
+ <version>3.0.0</version>
</dependency>
</dependencies>
<executions>
<includeResources>false</includeResources>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<includeTestResources>false</includeTestResources>
- <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
<excludes>
</excludes>
<consoleOutput>true</consoleOutput>
- <failsOnViolation>false</failsOnViolation>
+ <failOnViolation>false</failOnViolation>
</configuration>
</execution>
<execution>
with minor changes -->
<configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
<!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
- <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
<includeResources>true</includeResources>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<includeTestResources>true</includeTestResources>
<excludes>
</excludes>
<consoleOutput>true</consoleOutput>
- <failsOnViolation>false</failsOnViolation>
+ <failOnViolation>false</failOnViolation>
</configuration>
</execution>
</executions>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.12.4</version>
+ <version>3.0.0-M5</version>
<configuration>
<excludes>
<!-- exclude until junits updated <exclude>**/DME2*.java</exclude> -->
</excludes>
- <!-- <skipTests>true</skipTests> -->
+ <argLine>
+ --illegal-access=permit
+ </argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <argLine>
+ --illegal-access=permit
+ </argLine>
</configuration>
</plugin>
<plugin>
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.dmaap.dmf.mr.CambriaApiException;
import org.onap.dmaap.dmf.mr.backends.Consumer;
import org.onap.dmaap.dmf.mr.backends.ConsumerFactory;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class EventsServiceImplTest {
private InputStream iStream = null;
private MockHttpServletRequest request;
+
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(configurationReader.getfConsumerFactory()).thenReturn(factory);
when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
doThrow(new UnavailableException("Could not acquire consumer lock")).when(factory)
- .getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString());
+ .getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString());
thrown.expect(CambriaApiException.class);
thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_SERVICE_UNAVAILABLE)));
String consumerGroup = "CG5";
String clientId = "7";
givenConfiguredWithMocks(metricsTopicName);
- when(factory.getConsumerFor(eq(metricsTopicName), eq(consumerGroup), eq(clientId), anyInt(), anyString()))
- .thenReturn(consumer);
+ when(factory.getConsumerFor(eq(metricsTopicName), eq(consumerGroup), eq(clientId), anyInt(), any()))
+ .thenReturn(consumer);
doNothing().when(eventsService).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
//when
@Test
public void getEvents_shouldNotAuthorizeClient_whenTopicNoteEnforcedWithAaf_andTopicHasNoOwnerSet()
- throws Exception {
+ throws Exception {
//given
String topicName = "someSimpleTopicName";
String consumerGroup = "CG5";
when(permittedRequest.getHeaders(anyString())).thenReturn(Collections.<String>emptyEnumeration());
dMaapContext.setRequest(permittedRequest);
givenConfiguredWithMocks(topicName);
- when(factory.getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString()))
- .thenReturn(consumer);
+ when(factory.getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), any()))
+ .thenReturn(consumer);
doNothing().when(eventsService).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
when(createdTopic.getOwner()).thenReturn(Strings.EMPTY);
@Test
public void getEvents_shouldFailDmaapAuthorization_whenTopicOwnerIsSet_andUserHasNoReadPermissionToTopic()
- throws Exception {
+ throws Exception {
//given
String topicName = "someSimpleTopicName";
String consumerGroup = "CG5";
dMaapContext.setRequest(permittedRequest);
givenConfiguredWithMocks(topicName);
when(factory.getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString()))
- .thenReturn(consumer);
+ .thenReturn(consumer);
doNothing().when(eventsService).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
when(createdTopic.getOwner()).thenReturn("SimpleTopicOwner");
when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
givenConfiguredWithMocks(topicName);
givenConfiguredWithProperties(messageLimit, timeout, meta, pretty, cacheEnabled);
when(factory.getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString()))
- .thenReturn(consumer);
+ .thenReturn(consumer);
givenUserAuthorizedWithAAF(request, topicName, "sub");
//when
}
private void givenConfiguredWithProperties(String messageLimit, String timeout, String meta, String pretty,
- String cacheEnabled) {
+ String cacheEnabled) {
when(eventsService.getPropertyFromAJSCmap("meta")).thenReturn(meta);
when(eventsService.getPropertyFromAJSCmap("pretty")).thenReturn(pretty);
when(eventsService.getPropertyFromAJSCmap(ConsumerFactory.kSetting_EnableCache)).thenReturn(cacheEnabled);
}
private void verifyInvocationOrderForSuccessCase(String topicName, String consumerGroup, String clientId,
- ArgumentCaptor<CambriaOutboundEventStream> osWriter) throws Exception {
+ ArgumentCaptor<CambriaOutboundEventStream> osWriter) throws Exception {
InOrder inOrder = Mockito.inOrder(configurationReader, factory, metrics, limiter, consumer, eventsService);
inOrder.verify(configurationReader).getfMetrics();
}
-
+
@Test
public void pushEvents_shouldFailDmaapAuthorization_whenTopicOwnerIsSet_andUserHasNoWritePermissionToTopic()
- throws Exception {
+ throws Exception {
//given
String topicName = "someSimpleTopicName";
@Test
public void pushEvents_shouldFailOnAafAuthorization_whenCadiIsEnabled_topicNameEnforced_andUserHasNoPermission()
- throws Exception {
+ throws Exception {
//given
String topicPrefix = "org.onap.aaf.enforced";
String topicName = topicPrefix + ".topicName";
String topicName = "topicWithoutTransaction";
givenConfiguredWithMocks(topicName);
doThrow(new IOException()).when(publisher)
- .sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ .sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
thrown.expect(CambriaApiException.class);
thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_NOT_FOUND)));
doNothing().when(eventsService).respondOk(eq(dMaapContext), any(JSONObject.class));
request.addUserRole("org.onap.dmaap.mr.topic|:topic." + topicName + "|pub");
doThrow(new IOException()).when(publisher)
- .sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ .sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
thrown.expect(CambriaApiException.class);
thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_NOT_FOUND)));
//then
ArgumentCaptor<JSONObject> captor = ArgumentCaptor.forClass(JSONObject.class);
verify(publisher)
- .sendBatchMessageNew(eq(metricsTopicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ .sendBatchMessageNew(eq(metricsTopicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
verify(eventsService).respondOk(eq(dMaapContext), captor.capture());
verify(permittedRequest, never()).isUserInRole(anyString());
verify(createdTopic, never()).checkUserWrite(any(NsaSimpleApiKey.class));
package org.onap.dmaap.dmf.mr.service.impl;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.contains;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
import com.att.nsa.configs.ConfigDbException;
import com.att.nsa.security.NsaAcl;
import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
import com.att.nsa.security.db.simple.NsaSimpleApiKey;
import java.io.IOException;
+import java.nio.file.attribute.UserPrincipal;
import java.util.Arrays;
import java.util.HashSet;
import javax.servlet.ServletOutputStream;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.MockitoRule;
+import org.mockito.quality.Strictness;
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.metabroker.Topic;
import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
-import sun.security.acl.PrincipalImpl;
+import java.security.Principal;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class TopicServiceImplTest {
doNothing().when(topicService).respondOk(any(DMaaPContext.class),anyString());
doNothing().when(topicService).respondOk(any(DMaaPContext.class),any(JSONObject.class));
when(topicService.getPropertyFromAJSCbean("enforced.topic.name.AAF"))
- .thenReturn("org.onap.dmaap.mr");
+ .thenReturn("org.onap.dmaap.mr");
when(topicService.getPropertyFromAJSCmap("msgRtr.topicfactory.aaf"))
- .thenReturn("org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:");
+ .thenReturn("org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:");
}
private void givenTopicBean(String topicName) {
public void createTopic_shouldSkipAAFAuthorization_whenCadiIsEnabled_andTopicNameNotEnforced() throws Exception {
//given
String topicName = "UNAUTHENTICATED.PRH.REGISTRATION";
- givenTopicBean(topicName);
- when(dmaapKafkaMetaBroker.createTopic(eq(topicName), anyString(), anyString(), anyInt(), anyInt(), anyBoolean()))
- .thenReturn(createdTopic);
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(), anyBoolean()))
+ .thenReturn(createdTopic);
+
+ givenTopicBean(topicName);
//when
topicService.createTopic(dmaapContext, topicBean);
//then
- verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), anyString(), anyString(), anyInt(), anyInt(),
- anyBoolean());
+ verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(),
+ anyBoolean());
verify(topicService).respondOk(eq(dmaapContext), any(JSONObject.class));
verify(httpServReq, never()).isUserInRole(TOPIC_CREATE_PEM);
}
String topicName = "org.onap.dmaap.mr.topic-2";
givenTopicBean(topicName);
- when(dmaapKafkaMetaBroker.createTopic(eq(topicName), anyString(), anyString(), anyInt(), anyInt(), anyBoolean()))
- .thenReturn(createdTopic);
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(), anyBoolean()))
+ .thenReturn(createdTopic);
//when
topicService.createTopic(dmaapContext, topicBean);
//then
- verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), anyString(), anyString(), anyInt(), anyInt(),
- anyBoolean());
+ verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(),
+ anyBoolean());
verify(topicService).respondOk(eq(dmaapContext), any(JSONObject.class));
verify(httpServReq, never()).isUserInRole(TOPIC_CREATE_PEM);
}
givenTopicBean(topicName);
doReturn(null).when(topicService).getDmaapAuthenticatedUser(dmaapContext);
- when(dmaapKafkaMetaBroker.createTopic(eq(topicName), anyString(), anyString(), anyInt(), anyInt(), anyBoolean()))
- .thenReturn(createdTopic);
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(), anyBoolean()))
+ .thenReturn(createdTopic);
//when
topicService.createTopic(dmaapContext, topicBean);
//then
- verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), anyString(), anyString(), anyInt(), anyInt(),
- anyBoolean());
+ verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(),
+ anyBoolean());
verify(topicService).respondOk(eq(dmaapContext), any(JSONObject.class));
}
String topicName = "org.onap.dmaap.mr.topic-4";
givenTopicBean(topicName);
+ Principal user = new UserPrincipal(){
+ @Override
+ public String getName(){
+ return "user";
+ }
+ };
when(topicService.isCadiEnabled()).thenReturn(true);
when(httpServReq.isUserInRole(TOPIC_CREATE_PEM)).thenReturn(true);
- when(httpServReq.getUserPrincipal()).thenReturn(new PrincipalImpl("user"));
- when(dmaapKafkaMetaBroker.createTopic(eq(topicName), anyString(), eq("user"), anyInt(), anyInt(), anyBoolean()))
- .thenReturn(createdTopic);
+ when(httpServReq.getUserPrincipal()).thenReturn(user);
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), eq("user"), anyInt(), anyInt(), anyBoolean()))
+ .thenReturn(createdTopic);
//when
topicService.createTopic(dmaapContext, topicBean);
//then
verify(httpServReq).isUserInRole(TOPIC_CREATE_PEM);
- verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), anyString(), eq("user"), anyInt(), anyInt(), anyBoolean());
+ verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), any(), eq("user"), anyInt(), anyInt(), anyBoolean());
verify(topicService).respondOk(eq(dmaapContext), any(JSONObject.class));
verify(topicService, never()).getDmaapAuthenticatedUser(dmaapContext);
}
String topicName = "org.onap.dmaap.mr.topic-5";
givenTopicBean(topicName);
+ Principal user = new Principal(){
+ @Override
+ public String getName(){
+ return "user";
+ }
+ };
when(topicService.isCadiEnabled()).thenReturn(true);
when(httpServReq.isUserInRole(TOPIC_CREATE_PEM)).thenReturn(false);
- when(httpServReq.getUserPrincipal()).thenReturn(new PrincipalImpl("user"));
+ when(httpServReq.getUserPrincipal()).thenReturn(user);
when(dmaapKafkaMetaBroker.createTopic(eq(topicName), anyString(), eq("user"), anyInt(), anyInt(), anyBoolean()))
- .thenReturn(createdTopic);
+ .thenReturn(createdTopic);
//when
topicService.createTopic(dmaapContext, topicBean);
String topicName = "org.onap.dmaap.mr.topic-6";
givenTopicBean(topicName);
- when(dmaapKafkaMetaBroker.createTopic(eq(topicName), anyString(), anyString(), anyInt(), anyInt(), anyBoolean()))
- .thenThrow(new ConfigDbException("fail"));
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), any(), anyInt(), anyInt(), anyBoolean()))
+ .thenThrow(new ConfigDbException("fail"));
//when
topicService.createTopic(dmaapContext, topicBean);
String topicName = "org.onap.dmaap.mr.topic-7";
givenTopicBean(topicName);
- when(dmaapKafkaMetaBroker.createTopic(eq(topicName), anyString(), anyString(), anyInt(), anyInt(), anyBoolean()))
- .thenThrow(new Broker1.TopicExistsException("enfTopicNamePlusExtra"));
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(), anyBoolean()))
+ .thenThrow(new Broker1.TopicExistsException("enfTopicNamePlusExtra"));
//when
topicService.createTopic(dmaapContext, topicBean);
@Test(expected = TopicExistsException.class)
public void testGetTopics_null_topic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException {
+ TopicExistsException, JSONException, ConfigDbException {
Assert.assertNotNull(topicService);
//PowerMockito.mockStatic(DMaaPResponseBuilder.class);
@Test
public void testGetTopics_NonNull_topic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException {
+ TopicExistsException, JSONException, ConfigDbException {
Assert.assertNotNull(topicService);
//PowerMockito.mockStatic(DMaaPResponseBuilder.class);
@Test(expected = TopicExistsException.class)
public void testGetPublishersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
- IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testGetPublishersByTopicName_nonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
- IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test(expected = TopicExistsException.class)
public void testGetConsumersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
- IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testGetConsumersByTopicName_nonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
- IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testGetPublishersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test(expected = TopicExistsException.class)
public void testGetPublishersByTopicNameError() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testPermitConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test(expected = TopicExistsException.class)
public void testPermitConsumerForTopic_nulltopic()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testdenyConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test(expected = TopicExistsException.class)
public void testdenyConsumerForTopic_nulltopic()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testPermitPublisherForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test(expected = TopicExistsException.class)
public void testPermitPublisherForTopic_nulltopic()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testDenyPublisherForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test(expected = TopicExistsException.class)
public void testDenyPublisherForTopic_nulltopic()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testGetAllTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
@Test
public void testGetTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
Assert.assertNotNull(topicService);
}
+