summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavid.mcweeney <david.mcweeney@est.tech>2021-06-25 11:53:27 +0100
committerdavid.mcweeney <david.mcweeney@est.tech>2021-06-25 11:53:34 +0100
commit5ad0b4d710f20bd7bed96486aa878645d5f8e806 (patch)
treeb926d8e1ad87b611e8781f8feaae10908336f053
parent346db85cc2c56830d9186516bba09166e8dddc1d (diff)
DMAAP-MR Unit test improvements
Signed-off-by: david.mcweeney <david.mcweeney@est.tech> Issue-ID: DMAAP-1634 Change-Id: I5fa5df76374c412232082d346129986f0e4a48d5
-rw-r--r--pom.xml2
-rw-r--r--src/test/java/org/onap/dmaap/service/AdminRestServiceTest.java246
-rw-r--r--src/test/java/org/onap/dmaap/service/ApiKeysRestServiceTest.java237
-rw-r--r--src/test/java/org/onap/dmaap/service/EventsRestServiceTest.java415
-rw-r--r--src/test/java/org/onap/dmaap/service/MMRestServiceTest.java173
-rw-r--r--src/test/java/org/onap/dmaap/service/MetricsRestServiceTest.java48
-rw-r--r--src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java4
-rw-r--r--src/test/java/org/onap/dmaap/service/TransactionRestServiceTest.java24
8 files changed, 487 insertions, 662 deletions
diff --git a/pom.xml b/pom.xml
index c95e686..26809db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -748,7 +748,7 @@
<scope>provided</scope>
</dependency>
- </dependencies>
+ </dependencies>
<profiles>
<!-- Use this profile to run the AJSC locally. This profile can be successfully
shutdown WITHIN eclipse even in a Windows environment. Debugging is also
diff --git a/src/test/java/org/onap/dmaap/service/AdminRestServiceTest.java b/src/test/java/org/onap/dmaap/service/AdminRestServiceTest.java
index 8ba69f3..5001fb3 100644
--- a/src/test/java/org/onap/dmaap/service/AdminRestServiceTest.java
+++ b/src/test/java/org/onap/dmaap/service/AdminRestServiceTest.java
@@ -20,39 +20,31 @@
package org.onap.dmaap.service;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-import static org.mockito.Matchers.any;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.junit.After;
-import org.junit.Before;
+import org.json.JSONException;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.dmaap.dmf.mr.CambriaApiException;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
import org.onap.dmaap.dmf.mr.service.AdminService;
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
import com.att.nsa.configs.ConfigDbException;
import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-@RunWith(PowerMockRunner.class)
-@PowerMockIgnore("jdk.internal.reflect.*")
-@PrepareForTest({ ServiceUtil.class })
+@RunWith(MockitoJUnitRunner.class)
public class AdminRestServiceTest {
@InjectMocks
@@ -66,25 +58,9 @@ public class AdminRestServiceTest {
@Mock
HttpServletRequest httpServReq;
- @Mock
- private HttpServletResponse response;
@Mock
Enumeration headerNames;
- @Mock
- private DMaaPContext dmaaPContext;
- @Mock
- private ConfigurationReader configReader;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
@Test
public void testGetConsumerCache() throws CambriaApiException, AccessDeniedException {
@@ -92,202 +68,132 @@ public class AdminRestServiceTest {
}
- @Test
- public void testGetConsumerCache_error() throws CambriaApiException, AccessDeniedException, IOException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).showConsumerCache(dmaaPContext);
- try {
- adminRestService.getConsumerCache();
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
+ @Test(expected=CambriaApiException.class)
+ public void testGetConsumerCache_IOException() throws CambriaApiException, AccessDeniedException, IOException {
+ doThrow(new IOException("error")).when(adminService).showConsumerCache(ArgumentMatchers.any(DMaaPContext.class));
+ adminRestService.getConsumerCache();
+ fail("Was expecting an exception to be thrown");
}
@Test
public void testDropConsumerCache() throws CambriaApiException, AccessDeniedException {
adminRestService.dropConsumerCache();
-
}
-
- @Test
- public void testDropConsumerCach_error() throws CambriaApiException, AccessDeniedException ,IOException{
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).dropConsumerCache(dmaaPContext);
- try {
- adminRestService.dropConsumerCache();
- }
- catch (CambriaApiException e) {
- assertTrue(true);
- }
-
+ @Test(expected=CambriaApiException.class)
+ public void testDropConsumerCach_IOException() throws CambriaApiException, AccessDeniedException ,IOException{
+ doThrow(new IOException("error")).when(adminService).dropConsumerCache(ArgumentMatchers.any(DMaaPContext.class));
+
+ adminRestService.dropConsumerCache();
+ fail("Was expecting an exception to be thrown");
}
- @Test
- public void testDropConsumerCach_error1() throws CambriaApiException, AccessDeniedException,IOException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).dropConsumerCache(dmaaPContext);
- try {
+
+ @Test(expected=CambriaApiException.class)
+ public void testDropConsumerCache_AccessDeniedException() throws CambriaApiException, AccessDeniedException,IOException {
+ doThrow(new AccessDeniedException("error")).when(adminService).dropConsumerCache(ArgumentMatchers.any(DMaaPContext.class));
+
adminRestService.dropConsumerCache();
- }
- catch (CambriaApiException e) {
- assertTrue(true);
- }
-
+ fail("Was expecting an exception to be thrown");
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testDropConsumerCache_JSONException() throws CambriaApiException, AccessDeniedException,IOException {
+ doThrow(new JSONException("error")).when(adminService).dropConsumerCache(ArgumentMatchers.any(DMaaPContext.class));
+ adminRestService.dropConsumerCache();
+ fail("Was expecting an exception to be thrown");
}
@Test
- public void testGetBlacklist() throws CambriaApiException, AccessDeniedException {
+ public void testGetBlacklist() throws CambriaApiException {
Vector headers = new Vector();
headers.add("Content-type");
Enumeration headerNms = headers.elements();
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
when(httpServReq.getHeaderNames()).thenReturn(headerNms);
- when(headerNames.nextElement()).thenReturn("key");
- when(httpServReq.getHeader("key")).thenReturn("value");
adminRestService.getBlacklist();
-
}
-
- @Test
- public void testGetBlacklist_error() throws CambriaApiException, AccessDeniedException,IOException {
-
- PowerMockito.doThrow(new IOException("error")).when(adminService).getBlacklist(any(DMaaPContext.class));
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+ @Test(expected=CambriaApiException.class)
+ public void testGetBlacklist_AccessDeniedException() throws CambriaApiException, AccessDeniedException, IOException {
+
when(httpServReq.getHeaderNames()).thenReturn(headerNames);
- when(headerNames.nextElement()).thenReturn("key");
- when(httpServReq.getHeader("key")).thenReturn("value");
+ doThrow(new AccessDeniedException("error")).when(adminService).getBlacklist(ArgumentMatchers.any(DMaaPContext.class));
- try {
adminRestService.getBlacklist();
- }
- catch (CambriaApiException e) {
- assertTrue(true);
- }
+ fail("Was expecting an exception to be thrown");
}
-
- @Test
- public void testGetBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException {
-
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).getBlacklist(any(DMaaPContext.class));
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
+
+ @Test(expected=CambriaApiException.class)
+ public void testGetBlacklist_IOException() throws CambriaApiException, AccessDeniedException,IOException {
when(httpServReq.getHeaderNames()).thenReturn(headerNames);
- when(headerNames.nextElement()).thenReturn("key");
- when(httpServReq.getHeader("key")).thenReturn("value");
+ doThrow(new IOException("error")).when(adminService).getBlacklist(ArgumentMatchers.any(DMaaPContext.class));
- try {
adminRestService.getBlacklist();
- }
- catch (CambriaApiException e) {
- assertTrue(true);
- }
-
+ fail("Was expecting an exception to be thrown");
}
@Test
public void testAddToBlacklist() throws CambriaApiException, AccessDeniedException {
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
-
adminRestService.addToBlacklist("120.120.120.120");
}
-
- @Test
- public void testAddToBlacklist_error() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).addToBlacklist(dmaaPContext,"120.120.120.120");
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- try {
- adminRestService.addToBlacklist("120.120.120.120");
- }catch (CambriaApiException e) {
- assertTrue(true);
- }
+ @Test(expected=CambriaApiException.class)
+ public void testAddToBlacklist_IOException() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {
+ doThrow(new IOException("error")).when(adminService).addToBlacklist(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+ adminRestService.addToBlacklist("120.120.120.120");
+ fail("Was expecting an exception to be thrown");
}
-
- @Test
- public void testAddToBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException, ConfigDbException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).addToBlacklist(dmaaPContext,"120.120.120.120");
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- try {
+
+ @Test(expected=CambriaApiException.class)
+ public void testAddToBlacklist_AccessDeniedException() throws CambriaApiException, AccessDeniedException,IOException, ConfigDbException {
+ doThrow(new AccessDeniedException("error")).when(adminService).addToBlacklist(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+
adminRestService.addToBlacklist("120.120.120.120");
- }catch (CambriaApiException e) {
- assertTrue(true);
- }
+ fail("Was expecting an exception to be thrown");
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testAddToBlacklist_ConfigDbException() throws CambriaApiException, AccessDeniedException,IOException, ConfigDbException {
+ doThrow(new ConfigDbException("error")).when(adminService).addToBlacklist(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+ adminRestService.addToBlacklist("120.120.120.120");
+ fail("Was expecting an exception to be thrown");
}
@Test
- public void testRemoveFromBlacklist() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
+ public void testRemoveFromBlacklist() throws CambriaApiException, AccessDeniedException, ConfigDbException {
adminRestService.removeFromBlacklist("120.120.120.120");
}
-
- @Test
- public void testRemoveFromBlacklist_error() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException{
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).removeFromBlacklist(dmaaPContext,"120.120.120.120");
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- try {
+ @Test(expected=CambriaApiException.class)
+ public void testRemoveFromBlacklist_ConfigDbException() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException{
+ doThrow(new ConfigDbException("error")).when(adminService).removeFromBlacklist(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
adminRestService.removeFromBlacklist("120.120.120.120");
- }catch (CambriaApiException e) {
- assertTrue(true);
- }
- catch (AccessDeniedException e) {
- assertTrue(true);
- }
- catch (ConfigDbException e) {
- assertTrue(true);
- }
-
+ fail("Was expecting an exception to be thrown");
}
-
- @Test
- public void testRemoveFromBlacklist_error1() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).removeFromBlacklist(dmaaPContext,"120.120.120.120");
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- try {
+ @Test(expected=CambriaApiException.class)
+ public void testRemoveFromBlacklist_IOException() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException{
+ doThrow(new IOException("error")).when(adminService).removeFromBlacklist(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
adminRestService.removeFromBlacklist("120.120.120.120");
- }catch (CambriaApiException e) {
- assertTrue(true);
- }
- catch (AccessDeniedException e) {
- assertTrue(true);
- }
- catch (ConfigDbException e) {
- assertTrue(true);
- }
+ fail("Was expecting an exception to be thrown");
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testRemoveFromBlacklist_AccessDeniedException() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {
+ doThrow(new AccessDeniedException("error")).when(adminService).removeFromBlacklist(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+ adminRestService.removeFromBlacklist("120.120.120.120");
+ fail("Was expecting an exception to be thrown");
}
} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/service/ApiKeysRestServiceTest.java b/src/test/java/org/onap/dmaap/service/ApiKeysRestServiceTest.java
index b66ccc1..3d96755 100644
--- a/src/test/java/org/onap/dmaap/service/ApiKeysRestServiceTest.java
+++ b/src/test/java/org/onap/dmaap/service/ApiKeysRestServiceTest.java
@@ -20,78 +20,37 @@
package org.onap.dmaap.service;
-import static org.junit.Assert.*;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doThrow;
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
import com.att.nsa.configs.ConfigDbException;
import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
+import com.att.nsa.security.db.NsaApiDb.KeyExistsException;
+import java.io.IOException;
+import org.json.JSONException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.json.JSONException;
-
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
import org.onap.dmaap.dmf.mr.service.ApiKeysService;
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.db.NsaApiDb.KeyExistsException;
-@RunWith(PowerMockRunner.class)
-@PowerMockIgnore("jdk.internal.reflect.*")
-@PrepareForTest({ ServiceUtil.class })
+@RunWith(MockitoJUnitRunner.class)
public class ApiKeysRestServiceTest {
-
@InjectMocks
private ApiKeysRestService service;
@Mock
ApiKeysService apiKeyService;
- @Mock
- DMaaPContext dmaapContext;
-
- @Mock
- HttpServletRequest httpServReq;
- @Mock
- private HttpServletResponse response;
- @Mock
- private ConfigurationReader configReader;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
@Test
public void testGetAllApiKeys() {
-
try {
service.getAllApiKeys();
} catch (CambriaApiException e) {
@@ -103,25 +62,22 @@ public class ApiKeysRestServiceTest {
}
- @Test
- public void testGetAllApiKeys_error() throws ConfigDbException, IOException {
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).getAllApiKeys(dmaapContext);
- try {
- service.getAllApiKeys();
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- assertTrue(true);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
+ @Test(expected=CambriaApiException.class)
+ public void testGetAllApiKeys_IOException() throws ConfigDbException, IOException, CambriaApiException {
+ doThrow(new IOException("error")).when(apiKeyService).getAllApiKeys(ArgumentMatchers.any(DMaaPContext.class));
+ service.getAllApiKeys();
+ fail("Was expecting an exception to be thrown");
+ }
+ @Test(expected=CambriaApiException.class)
+ public void testGetAllApiKeys_ConfigDBException() throws ConfigDbException, IOException, CambriaApiException {
+ doThrow(new ConfigDbException("error")).when(apiKeyService).getAllApiKeys(ArgumentMatchers.any(DMaaPContext.class));
+ service.getAllApiKeys();
+ fail("Was expecting an exception to be thrown");
}
@Test
public void testGetApiKey() {
-
try {
service.getApiKey("apikeyName");
} catch (CambriaApiException e) {
@@ -130,29 +86,28 @@ public class ApiKeysRestServiceTest {
} catch (NullPointerException e) {
assertTrue(true);
}
-
}
- @Test
- public void testGetApiKey_error() throws ConfigDbException, IOException {
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).getApiKey(dmaapContext, "apikeyName");
+ @Test(expected=CambriaApiException.class)
+ public void testGetApiKey_IOException() throws ConfigDbException, IOException, CambriaApiException {
+ String apikeyName = "apikeyName";
+ doThrow(new IOException("error")).when(apiKeyService).getApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
- try {
- service.getApiKey("apikeyName");
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- assertTrue(true);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
+ service.getApiKey(apikeyName);
+ fail("Was expecting an exception to be thrown");
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testGetApiKey_ConfigDBException() throws ConfigDbException, IOException, CambriaApiException {
+ String apikeyName = "apikeyName";
+ doThrow(new ConfigDbException("error")).when(apiKeyService).getApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+ service.getApiKey(apikeyName);
+ fail("Was expecting an exception to be thrown");
}
@Test
public void testCreateApiKey() {
-
try {
service.createApiKey(new ApiKeyBean("hs647a@att.com", "test apikey"));
} catch (CambriaApiException e) {
@@ -161,31 +116,46 @@ public class ApiKeysRestServiceTest {
} catch (NullPointerException e) {
assertTrue(true);
}
-
}
- @Test
- public void testCreateApiKey_error()
+ @Test(expected=CambriaApiException.class)
+ public void testCreateApiKey_ConfigDbException()
throws CambriaApiException, JSONException, KeyExistsException, ConfigDbException, IOException {
ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).createApiKey(dmaapContext, bean);
- try {
- service.createApiKey(bean);
- } catch (CambriaApiException e) {
- assertTrue(true);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
+ doThrow(new ConfigDbException("error")).when(apiKeyService).createApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(ApiKeyBean.class));
+
+ service.createApiKey(bean);
+ fail("Was expecting an exception to be thrown");
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testCreateApiKey_IOException()
+ throws CambriaApiException, JSONException, KeyExistsException, ConfigDbException, IOException {
+ ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
+
+ doThrow(new IOException("error")).when(apiKeyService).createApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(ApiKeyBean.class));
+
+ service.createApiKey(bean);
+ fail("Was expecting an exception to be thrown");
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testCreateApiKey_KeyExistsException()
+ throws CambriaApiException, JSONException, KeyExistsException, ConfigDbException, IOException {
+
+ ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
+
+ doThrow(new KeyExistsException("error")).when(apiKeyService).createApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(ApiKeyBean.class));
+
+ service.createApiKey(bean);
+ fail("Was expecting an exception to be thrown");
}
@Test
public void testUpdateApiKey() {
-
try {
service.updateApiKey("apikeyName", new ApiKeyBean("hs647a@att.com", "test apikey"));
} catch (CambriaApiException e) {
@@ -194,27 +164,39 @@ public class ApiKeysRestServiceTest {
} catch (NullPointerException e) {
assertTrue(true);
}
-
}
- @Test
- public void testUpdateApiKey_error() throws CambriaApiException, JSONException, KeyExistsException,
+ @Test(expected=CambriaApiException.class)
+ public void testUpdateApiKey_ConfigDbException() throws CambriaApiException, JSONException,
ConfigDbException, IOException, AccessDeniedException {
ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).updateApiKey(dmaapContext, "apikeyName",
- bean);
- try {
- service.updateApiKey("apikeyName", bean);
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
+ doThrow(new ConfigDbException("error")).when(apiKeyService).updateApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(ApiKeyBean.class));
+
+ service.updateApiKey("apikeyName", bean);
+ fail("Was expecting an exception to be thrown");
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testUpdateApiKey_IOException() throws CambriaApiException, JSONException,
+ ConfigDbException, IOException, AccessDeniedException {
+
+ ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
+ doThrow(new IOException("error")).when(apiKeyService).updateApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(ApiKeyBean.class));
+
+ service.updateApiKey("apikeyName", bean);
+ fail("Was expecting an exception to be thrown");
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testUpdateApiKey_AccessDeniedException() throws CambriaApiException, JSONException,
+ ConfigDbException, IOException, AccessDeniedException {
+
+ ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
+ doThrow(new AccessDeniedException("error")).when(apiKeyService).updateApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(ApiKeyBean.class));
+ service.updateApiKey("apikeyName", bean);
+ fail("Was expecting an exception to be thrown");
}
@Test
@@ -228,7 +210,38 @@ public class ApiKeysRestServiceTest {
} catch (NullPointerException e) {
assertTrue(true);
}
+ }
+
+ @Test(expected=CambriaApiException.class)
+ public void testDeleteApiKey_AccessDeniedException() throws CambriaApiException, JSONException,
+ ConfigDbException, IOException, AccessDeniedException {
+
+ ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
+ doThrow(new AccessDeniedException("error")).when(apiKeyService).deleteApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+
+ service.deleteApiKey("apikeyName");
+ fail("Was expecting an exception to be thrown");
+ }
+ @Test(expected=CambriaApiException.class)
+ public void testDeleteApiKey_IOException() throws CambriaApiException, JSONException,
+ ConfigDbException, IOException, AccessDeniedException {
+
+ ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
+ doThrow(new IOException("error")).when(apiKeyService).deleteApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+
+ service.deleteApiKey("apikeyName");
+ fail("Was expecting an exception to be thrown");
}
+ @Test(expected=CambriaApiException.class)
+ public void testDeleteApiKey_ConfigDbException() throws CambriaApiException, JSONException,
+ ConfigDbException, IOException, AccessDeniedException {
+
+ ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
+ doThrow(new ConfigDbException("error")).when(apiKeyService).deleteApiKey(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+
+ service.deleteApiKey("apikeyName");
+ fail("Was expecting an exception to be thrown");
+ }
} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/service/EventsRestServiceTest.java b/src/test/java/org/onap/dmaap/service/EventsRestServiceTest.java
index 44cc1a3..44a6593 100644
--- a/src/test/java/org/onap/dmaap/service/EventsRestServiceTest.java
+++ b/src/test/java/org/onap/dmaap/service/EventsRestServiceTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,57 +19,40 @@
*/
package org.onap.dmaap.service;
-import java.util.Date;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
import static org.mockito.Matchers.any;
-
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.api.mockito.PowerMockito;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-import com.att.ajsc.beans.PropertiesMapBean;
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
-import org.onap.dmaap.dmf.mr.service.EventsService;
import com.att.nsa.configs.ConfigDbException;
-import org.onap.dmaap.dmf.mr.utils.Utils;
import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;
import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.io.InputStream;
-import java.util.Date;
-
import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
-
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;
+import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
import org.onap.dmaap.dmf.mr.exception.ErrorResponse;
import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
+import org.onap.dmaap.dmf.mr.service.EventsService;
+import org.springframework.test.context.ContextConfiguration;
-@RunWith(PowerMockRunner.class)
-@PowerMockIgnore("jdk.internal.reflect.*")
-@PrepareForTest({ PropertiesMapBean.class })
+@RunWith(MockitoJUnitRunner.class)
+@ContextConfiguration
public class EventsRestServiceTest {
@InjectMocks
- EventsRestService eventsRestRestService;
+ EventsRestService eventsRestService;
@Mock
private EventsService eventsService;
@@ -78,9 +61,6 @@ public class EventsRestServiceTest {
ErrorResponse errorResponse;
@Mock
- DMaaPContext dmaapContext;
-
- @Mock
InputStream iStream;
@Mock
@@ -90,260 +70,207 @@ public class EventsRestServiceTest {
HttpServletRequest request;
@Mock
- private DMaaPErrorMessages errorMessages;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
+ DMaaPErrorMessages errorMessages;
@Test
public void testGetEvents() throws CambriaApiException {
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");
-
- }
-
- @Test
- public void testGetEvents_error() {
-
- try {
- PowerMockito.doThrow(new IOException()).when(eventsService).getEvents(any(), any(),
- any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | UnavailableException | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).getEvents(any(), any(),
- any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | UnavailableException | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).getEvents(any(),
- any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | UnavailableException | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
+ eventsRestService.getEvents("topicName", "consumergroup", "consumerid");
}
- @Test(expected = TopicExistsException.class)
+ @Test(expected = CambriaApiException.class)
public void testGetEvents_TopicExistException() throws CambriaApiException, ConfigDbException, TopicExistsException,
UnavailableException, IOException, AccessDeniedException {
- Mockito.doThrow(new TopicExistsException("topic exists")).when(eventsService).getEvents(any(),
+ doThrow(new TopicExistsException("topic exists")).when(eventsService).getEvents(any(),
any(), any(), any());
- eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");
-
+ eventsRestService.getEvents("topicName", "consumergroup", "consumerid");
}
- @Test(expected = DMaaPAccessDeniedException.class)
+ @Test(expected = CambriaApiException.class)
public void testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException, ConfigDbException,
TopicExistsException, UnavailableException, IOException, AccessDeniedException {
- Mockito.doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(any(),
+ doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(any(),
any(), any(), any());
- eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");
+ eventsRestService.getEvents("topicName", "consumergroup", "consumerid");
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testGetEvents_AccessDeniedException() throws CambriaApiException,
+ ConfigDbException, TopicExistsException, UnavailableException, IOException, AccessDeniedException {
+ doThrow(new ConfigDbException("error")).when(eventsService).getEvents( ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+
+ eventsRestService.getEvents("topicName", "consumergroup", "consumerid");
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testGetEvents_ConfigDbException() throws CambriaApiException,
+ ConfigDbException, TopicExistsException, UnavailableException, IOException, AccessDeniedException {
+ doThrow(new ConfigDbException("error")).when(eventsService).getEvents( ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+
+ eventsRestService.getEvents("topicName", "consumergroup", "consumerid");
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testGetEvents_UnavailableException() throws CambriaApiException,
+ ConfigDbException, TopicExistsException, UnavailableException, IOException, AccessDeniedException {
+ doThrow(new ConfigDbException("error")).when(eventsService).getEvents( ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+
+ eventsRestService.getEvents("topicName", "consumergroup", "consumerid");
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testGetEvents_IOException() throws CambriaApiException,
+ ConfigDbException, TopicExistsException, UnavailableException, IOException, AccessDeniedException {
+ doThrow(new ConfigDbException("error")).when(eventsService).getEvents( ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+ eventsRestService.getEvents("topicName", "consumergroup", "consumerid");
}
- /*
- * @Test(expected = DMaaPAccessDeniedException.class) public void
- * testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException,
- * ConfigDbException, TopicExistsException, UnavailableException,
- * IOException, AccessDeniedException {
- *
- * Mockito.doThrow(new
- * DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(
- * dmaapContext, "topicName", "consumergroup", "consumerid");
- *
- * eventsService.getEvents(dmaapContext, "topicName", "consumergroup",
- * "consumerid");
- *
- * }
- */
@Test
public void testPushEvents() throws CambriaApiException {
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
+ eventsRestService.pushEvents("topicName", iStream, "partitionKey");
}
- @Test
- public void testPushEvents_error() {
-
- try {
- PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(),
- any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(), any(),
- any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(),
- any(), any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
+ @Test(expected = CambriaApiException.class)
+ public void testPushEvents_TopicExistsException()
+ throws AccessDeniedException, CambriaApiException, IOException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.isNull());
+
+ eventsRestService.pushEvents("topicName", iStream, "partitionKey");
}
- @Test
+ @Test(expected = CambriaApiException.class)
+ public void testPushEvents_DMaaPAccessDeniedException()
+ throws AccessDeniedException, CambriaApiException, IOException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.isNull());
+
+ eventsRestService.pushEvents("topicName", iStream, "partitionKey");
+
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testPushEvents_ConfigDbException()
+ throws AccessDeniedException, CambriaApiException, IOException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ doThrow(new ConfigDbException("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.isNull());
+
+ eventsRestService.pushEvents("topicName", iStream, "partitionKey");
+
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testPushEvents_IOException()
+ throws AccessDeniedException, CambriaApiException, IOException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ doThrow(new IOException("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.isNull());
+
+ eventsRestService.pushEvents("topicName", iStream, "partitionKey");
+
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testPushEvents_missingReqdSetting()
+ throws AccessDeniedException, CambriaApiException, IOException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ doThrow(new missingReqdSetting("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.isNull());
+
+ eventsRestService.pushEvents("topicName", iStream, "partitionKey");
+
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testPushEvents_AccessDeniedException()
+ throws AccessDeniedException, CambriaApiException, IOException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ doThrow(new AccessDeniedException("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.isNull());
+
+ eventsRestService.pushEvents("topicName", iStream, "partitionKey");
+
+ }
+
+ @Test(expected = CambriaApiException.class)
public void testGetEventsToException() throws CambriaApiException {
- try {
- eventsRestRestService.getEventsToException("/topic");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
+
+ eventsRestService.getEventsToException("/topic");
}
-
- @Test
+
+ @Test(expected = CambriaApiException.class)
public void testGetEventsToExceptionWithConsumerGroup() throws CambriaApiException {
- try {
- eventsRestRestService.getEventsToException("/topic", "1234");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
+ eventsRestService.getEventsToException("/topic", "1234");
}
-
+
@Test
- public void testPushEvents_TopicExistException() throws CambriaApiException {
+ public void testPushEventsWithTransaction() throws CambriaApiException, IOException {
+ when(request.getInputStream()).thenReturn(servletInputStream);
+ eventsRestService.pushEventsWithTransaction("topicName", "partitionKey");
+ }
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
+ @Test(expected = CambriaApiException.class)
+ public void testPushEventsWithTransaction_TopicExistsException()
+ throws IOException, CambriaApiException, AccessDeniedException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ when(request.getInputStream()).thenReturn(servletInputStream);
+ doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+ eventsRestService.pushEventsWithTransaction("topicName", "partitionKey");
+ }
+ @Test(expected = CambriaApiException.class)
+ public void testPushEventsWithTransaction_AccessDeniedException()
+ throws IOException, CambriaApiException, AccessDeniedException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ when(request.getInputStream()).thenReturn(servletInputStream);
+ doThrow(new AccessDeniedException("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+ eventsRestService.pushEventsWithTransaction("topicName", "partitionKey");
}
- @Test
- public void tesTPushEventsWithTransaction() throws CambriaApiException, IOException {
+ @Test(expected = CambriaApiException.class)
+ public void testPushEventsWithTransaction_DMaaPAccessDeniedException()
+ throws IOException, CambriaApiException, AccessDeniedException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
when(request.getInputStream()).thenReturn(servletInputStream);
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");
+ doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+ eventsRestService.pushEventsWithTransaction("topicName", "partitionKey");
}
- @Test
- public void tesTPushEventsWithTransaction_error() throws IOException {
+ @Test(expected = CambriaApiException.class)
+ public void testPushEventsWithTransaction_missingReqdSetting()
+ throws IOException, CambriaApiException, AccessDeniedException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ when(request.getInputStream()).thenReturn(servletInputStream);
+ doThrow(new missingReqdSetting("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+
+ eventsRestService.pushEventsWithTransaction("topicName", "partitionKey");
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testPushEventsWithTransaction_IOException()
+ throws IOException, CambriaApiException, AccessDeniedException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
when(request.getInputStream()).thenReturn(servletInputStream);
- ServletInputStream stream = request.getInputStream();
-
- try {
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(),
- any(), any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(),any(),
- any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(),
- any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
+ doThrow(new IOException("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+ eventsRestService.pushEventsWithTransaction("topicName", "partitionKey");
}
+ @Test(expected = CambriaApiException.class)
+ public void testPushEventsWithTransaction_ConfigDbException()
+ throws IOException, CambriaApiException, AccessDeniedException, TopicExistsException, ConfigDbException,
+ missingReqdSetting {
+ when(request.getInputStream()).thenReturn(servletInputStream);
+ doThrow(new ConfigDbException("error")).when(eventsService).pushEvents(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(InputStream.class), ArgumentMatchers.any(String.class), ArgumentMatchers.any(String.class));
+
+ eventsRestService.pushEventsWithTransaction("topicName", "partitionKey");
+ }
}
diff --git a/src/test/java/org/onap/dmaap/service/MMRestServiceTest.java b/src/test/java/org/onap/dmaap/service/MMRestServiceTest.java
index eb4ec57..50211f5 100644
--- a/src/test/java/org/onap/dmaap/service/MMRestServiceTest.java
+++ b/src/test/java/org/onap/dmaap/service/MMRestServiceTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,18 +24,17 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
+import com.att.ajsc.beans.PropertiesMapBean;
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.NsaAcl;
+import com.att.nsa.security.NsaApiKey;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
import java.io.ByteArrayInputStream;
-
-//import static org.mockito.Matchers.anyString;
-//import static org.mockito.Mockito.when;
-
-import java.io.IOException;
import java.io.InputStream;
-
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -47,14 +46,10 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
-import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
import org.onap.dmaap.dmf.mr.metabroker.Topic;
import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator;
import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticatorImpl;
@@ -69,14 +64,6 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import com.att.ajsc.beans.PropertiesMapBean;
-import com.att.ajsc.filemonitor.AJSCPropertiesMap;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.NsaAcl;
-import com.att.nsa.security.NsaApiKey;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;
-
//@RunWith(MockitoJUnitRunner.class)
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("jdk.internal.reflect.*")
@@ -174,7 +161,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
@@ -182,7 +169,7 @@ public class MMRestServiceTest {
try {
prepareForTestCommon();
} catch (Exception e) {
-
+
}
// String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {
@@ -195,7 +182,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
@@ -224,10 +211,10 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallCreateMirrorMaker_error1() {
prepareForTestCommon();
@@ -242,7 +229,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@@ -259,10 +246,10 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallListAllMirrorMaker() {
prepareForTestCommon();
@@ -274,7 +261,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
@@ -289,9 +276,9 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallUpdateMirrorMaker() {
prepareForTestCommon();
@@ -303,9 +290,9 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallUpdateMirrorMaker_error1() {
prepareForTestCommon();
@@ -317,7 +304,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
public void testCallUpdateMirrorMaker_error2() {
@@ -330,7 +317,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
public void testCallUpdateMirrorMaker_error3() {
@@ -343,7 +330,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
public void testCallUpdateMirrorMaker_error4() {
@@ -356,7 +343,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
@@ -365,7 +352,7 @@ public class MMRestServiceTest {
PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeradmin.aaf"))
.thenReturn(null);
-
+
String sampleJson = "{ messageID:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
try {
@@ -373,9 +360,9 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallDeleteMirrorMaker() {
prepareForTestCommon();
@@ -389,10 +376,10 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallDeleteMirrorMakerAafPermissionError() {
prepareForTestCommon();
@@ -407,17 +394,17 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
-
+
+
@Test
public void testListWhiteList() {
prepareForTestCommon();
String sampleJson = "{ name:\"test\", namespace:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
try {
PowerMockito.when(mmservice.subscribe(any(), anyString(), anyString(), anyString())).thenReturn(msgSubscribe);
@@ -425,7 +412,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
@@ -434,7 +421,7 @@ public class MMRestServiceTest {
String sampleJson = "{ name:\"test\", namespace:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
try {
PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf"))
@@ -443,7 +430,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
@@ -452,7 +439,7 @@ public class MMRestServiceTest {
String sampleJson = "{ name:\"test\", namespace:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
try {
PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf.create"))
@@ -461,7 +448,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
public void testListWhiteListJSONError() {
@@ -469,23 +456,23 @@ public class MMRestServiceTest {
String sampleJson = "{ namespace:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
try {
mmRestService.listWhiteList(inputSteam);
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
-
-
-
+
+
+
+
@Test
public void testCreateWhiteList() {
prepareForTestCommon();
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
@@ -494,7 +481,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
@@ -504,7 +491,7 @@ public class MMRestServiceTest {
PowerMockito
.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf.create"))
.thenReturn(null);
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
@@ -513,16 +500,16 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCreateWhiteListAafPermissionError() {
prepareForTestCommon();
PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf"))
.thenReturn(null);
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
@@ -531,9 +518,9 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
- }
-
+
+ }
+
@Test
public void testCreateWhiteListJSONError() {
prepareForTestCommon();
@@ -546,9 +533,9 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
- }
-
+
+ }
+
@Test
public void testDeleteWhiteList() {
prepareForTestCommon();
@@ -560,7 +547,7 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
@@ -576,10 +563,10 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testDeleteWhiteListMirrorMakerAafPermissionError() {
prepareForTestCommon();
@@ -593,10 +580,10 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
-
+
+
@Test
public void testDeleteWhiteListJsonError() {
prepareForTestCommon();
@@ -608,9 +595,9 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
- }
-
+
+ }
+
@Test
public void testDeleteWhiteListJsonFormattingError() {
prepareForTestCommon();
@@ -622,15 +609,15 @@ public class MMRestServiceTest {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallPubSubForWhitelist() {
prepareForTestCommon();
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
try {
PowerMockito.when(mmservice.subscribe(any(), anyString(), anyString(), anyString())).thenReturn(msgSubscribe);
@@ -639,13 +626,13 @@ public class MMRestServiceTest {
assertTrue(true);
}
}
-
+
@Test
public void testCallPubSub() {
prepareForTestCommon();
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
try {
PowerMockito.when(mmservice.subscribe(any(), anyString(), anyString(), anyString())).thenReturn(msgSubscribe);
@@ -654,11 +641,11 @@ public class MMRestServiceTest {
assertTrue(true);
}
}
-
+
@Test
public void testCallPubSubForWhitelistNoMsgFromSubscribe() {
prepareForTestCommon();
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
try {
@@ -672,15 +659,15 @@ public class MMRestServiceTest {
@Test
public void testGetListMirrorMaker() {
prepareForTestCommon();
-
- String sampleJson = "[{ messageID:\"test123\", listMirrorMaker:[\"test\"]}]";
+
+ String sampleJson = "[{ messageID:\"test123\", listMirrorMaker:[\"test\"]}]";
try {
mmRestService.getListMirrorMaker(sampleJson, "test123");
} catch (Exception e) {
assertTrue(true);
- }
+ }
}
-
+
private void prepareForTestCommon() {
Assert.assertNotNull(mmRestService);
@@ -740,7 +727,7 @@ public class MMRestServiceTest {
try {
PowerMockito.when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);
} catch (ConfigDbException e) {
-
+
}
}
diff --git a/src/test/java/org/onap/dmaap/service/MetricsRestServiceTest.java b/src/test/java/org/onap/dmaap/service/MetricsRestServiceTest.java
index a7e88ca..bbcf88e 100644
--- a/src/test/java/org/onap/dmaap/service/MetricsRestServiceTest.java
+++ b/src/test/java/org/onap/dmaap/service/MetricsRestServiceTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,26 +20,23 @@
package org.onap.dmaap.service;
-import org.junit.After;
-import org.junit.Before;
+import static org.mockito.Mockito.doThrow;
+
+import java.io.IOException;
+
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.att.ajsc.beans.PropertiesMapBean;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
import org.onap.dmaap.dmf.mr.CambriaApiException;
import org.onap.dmaap.dmf.mr.service.MetricsService;
-@RunWith(PowerMockRunner.class)
-@PowerMockIgnore("jdk.internal.reflect.*")
-@PrepareForTest({ PropertiesMapBean.class })
+@RunWith(MockitoJUnitRunner.class)
public class MetricsRestServiceTest {
@InjectMocks
@@ -47,15 +44,6 @@ public class MetricsRestServiceTest {
@Mock
private MetricsService metricsService;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
@Test
public void testGetMetrics() throws CambriaApiException {
@@ -63,14 +51,24 @@ public class MetricsRestServiceTest {
metricsRestService.getMetrics();
}
-
+
+ @Test(expected = CambriaApiException.class)
+ public void testGetMetrics_IOException() throws CambriaApiException, IOException {
+ doThrow(new IOException("error")).when(metricsService).get(ArgumentMatchers.any(DMaaPContext.class));
+ metricsRestService.getMetrics();
+ }
+
+
@Test
public void testGetMetricsByName() throws CambriaApiException {
metricsRestService.getMetricsByName("metricsName");
-
}
-
+ @Test(expected = CambriaApiException.class)
+ public void testGetMetricsByName_IOException() throws CambriaApiException, IOException {
+ doThrow(new IOException("error")).when(metricsService).getMetricByName(ArgumentMatchers.any(DMaaPContext.class), ArgumentMatchers.any(String.class));
+ metricsRestService.getMetricsByName("metricsName");
+ }
} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java b/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java
index a3c123b..61c291c 100644
--- a/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java
+++ b/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/org/onap/dmaap/service/TransactionRestServiceTest.java b/src/test/java/org/onap/dmaap/service/TransactionRestServiceTest.java
index a7ac8de..a906a3b 100644
--- a/src/test/java/org/onap/dmaap/service/TransactionRestServiceTest.java
+++ b/src/test/java/org/onap/dmaap/service/TransactionRestServiceTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,12 +20,12 @@
package org.onap.dmaap.service;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+import com.att.aft.dme2.internal.jettison.json.JSONException;
+import com.att.ajsc.beans.PropertiesMapBean;
+import com.att.nsa.configs.ConfigDbException;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -33,19 +33,13 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.att.ajsc.beans.PropertiesMapBean;
import org.onap.dmaap.dmf.mr.CambriaApiException;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-import org.onap.dmaap.dmf.mr.service.EventsService;
import org.onap.dmaap.dmf.mr.service.TransactionService;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-import com.att.aft.dme2.internal.jettison.json.JSONException;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("jdk.internal.reflect.*")