summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-09-11 13:18:42 +0200
committersebdet <sebastien.determe@intl.att.com>2019-09-11 14:21:46 +0200
commitcf87afa1bbf19cdaf8b60f1e689c2b82625c14f8 (patch)
tree805af0faa4a23515a16f0d96f477e189c51f470e /src/test
parent58b44949714b002818d20ba40d01eb50c031614d (diff)
Checkstyle fixes
Checkstyle fixes done to solve the Unstable build Issue-ID: CLAMP-487 Change-Id: I694b13e03dd1e7220988fd0c08bfbf12a808f7f7 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java45
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java30
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java8
-rw-r--r--src/test/java/org/onap/clamp/clds/util/LoggingUtilsTest.java38
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java6
-rw-r--r--src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java63
6 files changed, 82 insertions, 108 deletions
diff --git a/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java b/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java
index 549c9132..a9480421 100644
--- a/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java
+++ b/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java
@@ -27,43 +27,37 @@
package org.onap.clamp.clds.config;
import static org.assertj.core.api.Assertions.assertThat;
+
import org.junit.Test;
import org.onap.clamp.clds.exception.CldsUsersException;
import org.onap.clamp.clds.service.CldsUser;
-
public class CldsUserJsonDecoderTest {
private String user1 = "admin1";
private String user2 = "admin2";
private String password = "5f4dcc3b5aa765d61d8327deb882cf99";
- private String[] normalPermissionsArray = {
- "permission-type-cl|dev|read", "permission-type-cl|dev|update", "permission-type-cl-manage|dev|*",
- "permission-type-filter-vf|dev|*", "permission-type-template|dev|read",
- "permission-type-template|dev|update"
- };
- private String[] incompletePermissionsArray = {
- "permission-type-cl|dev|*", "permission-type-cl|dev|*", "permission-type-cl-manage|dev|*",
- "permission-type-filter-vf|dev|*", "permission-type-template|dev|read",
- "permission-type-template|dev|update"
- };
+ private String[] normalPermissionsArray = { "permission-type-cl|dev|read", "permission-type-cl|dev|update",
+ "permission-type-cl-manage|dev|*", "permission-type-filter-vf|dev|*", "permission-type-template|dev|read",
+ "permission-type-template|dev|update" };
+ private String[] incompletePermissionsArray = { "permission-type-cl|dev|*", "permission-type-cl|dev|*",
+ "permission-type-cl-manage|dev|*", "permission-type-filter-vf|dev|*", "permission-type-template|dev|read",
+ "permission-type-template|dev|update" };
@Test
public void testDecodingDoubleUsers() {
- //when
+ // when
CldsUser[] usersArray = CldsUserJsonDecoder
- .decodeJson(CldsUserJsonDecoderTest.class.getResourceAsStream("/clds/clds-users-two-users.json"));
+ .decodeJson(CldsUserJsonDecoderTest.class.getResourceAsStream("/clds/clds-users-two-users.json"));
- //then
+ // then
assertThat(usersArray).hasSize(2);
- assertThat(usersArray[0])
- .extracting(CldsUser::getUser, CldsUser::getPassword, CldsUser::getPermissionsString)
- .containsExactly(user1, password, normalPermissionsArray);
+ assertThat(usersArray[0]).extracting(CldsUser::getUser, CldsUser::getPassword, CldsUser::getPermissionsString)
+ .containsExactly(user1, password, normalPermissionsArray);
- assertThat(usersArray[1])
- .extracting(CldsUser::getUser, CldsUser::getPassword, CldsUser::getPermissionsString)
- .containsExactly(user2, password, normalPermissionsArray);
+ assertThat(usersArray[1]).extracting(CldsUser::getUser, CldsUser::getPassword, CldsUser::getPermissionsString)
+ .containsExactly(user2, password, normalPermissionsArray);
}
@@ -73,7 +67,7 @@ public class CldsUserJsonDecoderTest {
CldsUser[] usersArray = CldsUserJsonDecoder
.decodeJson(this.getClass().getResourceAsStream("/clds/clds-users-no-permission.json"));
- //then
+ // then
assertThat(usersArray).hasSize(1);
CldsUser user = usersArray[0];
assertThat(user.getUser()).isEqualTo(user1);
@@ -84,11 +78,11 @@ public class CldsUserJsonDecoderTest {
@Test
public void testDecodingIncompletePermissions() {
- //when
+ // when
CldsUser[] usersArray = CldsUserJsonDecoder
.decodeJson(this.getClass().getResourceAsStream("/clds/clds-users-incomplete-permissions.json"));
- //then
+ // then
assertThat(usersArray).hasSize(1);
CldsUser user = usersArray[0];
assertThat(user.getUser()).isEqualTo(user1);
@@ -98,9 +92,8 @@ public class CldsUserJsonDecoderTest {
@Test(expected = CldsUsersException.class)
public void shouldThrowCldsUsersException() {
- //when
- CldsUserJsonDecoder
- .decodeJson(this.getClass().getResourceAsStream("/clds/clds-parse-exception.json"));
+ // when
+ CldsUserJsonDecoder.decodeJson(this.getClass().getResourceAsStream("/clds/clds-parse-exception.json"));
}
}
diff --git a/src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java b/src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java
index fa22b02b..1830115f 100644
--- a/src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java
+++ b/src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java
@@ -28,32 +28,22 @@ import java.util.Map;
public class PermissionTestDefaultHelper extends PermissionTestHelper {
- private static final String[] ALL_ACTION = new String[] {"*"};
- private static final String[] READ_UPDATE_ACTION = new String[] {"read", "update"};
+ private static final String[] ALL_ACTION = new String[] { "*" };
+ private static final String[] READ_UPDATE_ACTION = new String[] { "read", "update" };
private static final String DEV_INSTANCE = "dev";
private static final String TEST_INSTANCE = "test";
- private static final Map<String, Map> defaultPermission = ImmutableMap.of(
- "permission-type-cl", ImmutableMap.of(
- DEV_INSTANCE, ALL_ACTION),
- "permission-type-cl-event", ImmutableMap.of(
- DEV_INSTANCE, ALL_ACTION,
- TEST_INSTANCE, READ_UPDATE_ACTION),
- "permission-type-cl-manage", ImmutableMap.of(
- DEV_INSTANCE, ALL_ACTION,
- TEST_INSTANCE, READ_UPDATE_ACTION),
- "permission-type-filter-vf", ImmutableMap.of(
- DEV_INSTANCE, ALL_ACTION,
- TEST_INSTANCE, READ_UPDATE_ACTION),
- "permission-type-template", ImmutableMap.of(
- DEV_INSTANCE, ALL_ACTION,
- TEST_INSTANCE, READ_UPDATE_ACTION)
- );
+ private static final Map<String, Map<?, ?>> defaultPermission = ImmutableMap.of("permission-type-cl",
+ ImmutableMap.of(DEV_INSTANCE, ALL_ACTION), "permission-type-cl-event",
+ ImmutableMap.of(DEV_INSTANCE, ALL_ACTION, TEST_INSTANCE, READ_UPDATE_ACTION), "permission-type-cl-manage",
+ ImmutableMap.of(DEV_INSTANCE, ALL_ACTION, TEST_INSTANCE, READ_UPDATE_ACTION), "permission-type-filter-vf",
+ ImmutableMap.of(DEV_INSTANCE, ALL_ACTION, TEST_INSTANCE, READ_UPDATE_ACTION), "permission-type-template",
+ ImmutableMap.of(DEV_INSTANCE, ALL_ACTION, TEST_INSTANCE, READ_UPDATE_ACTION));
/**
- * Permission test default helper constructor.
- * This class setup the default permission in the parent PermissionTestHelper class.
+ * Permission test default helper constructor. This class setup the default
+ * permission in the parent PermissionTestHelper class.
*/
public PermissionTestDefaultHelper() {
super(defaultPermission);
diff --git a/src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java b/src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java
index ee073b01..905b7f70 100644
--- a/src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java
+++ b/src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java
@@ -36,14 +36,14 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
public class PermissionTestHelper {
private static final String securityPrefix = CONFIG_PREFIX + PERM_PREFIX;
- private final Map<String, Map> permission;
+ private final Map<String, Map<?, ?>> permission;
private static final List<GrantedAuthority> authList = new LinkedList<>();
/**
- * Permission Test Helper constructor
- * Generate authList base on general permission collection
+ * Permission Test Helper constructor. Generate authList base on general
+ * permission collection.
*/
- public PermissionTestHelper(Map<String, Map> permission) {
+ public PermissionTestHelper(Map<String, Map<?, ?>> permission) {
this.permission = permission;
this.createAuthList();
}
diff --git a/src/test/java/org/onap/clamp/clds/util/LoggingUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/LoggingUtilsTest.java
index 7e2da4d1..27a06b21 100644
--- a/src/test/java/org/onap/clamp/clds/util/LoggingUtilsTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/LoggingUtilsTest.java
@@ -21,10 +21,10 @@
package org.onap.clamp.clds.util;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -58,7 +58,7 @@ public class LoggingUtilsTest {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(LoggingUtilsTest.class);
- private static final String SERVICE_NAME = "LogginUtilsTest: Test Entering method";
+ private static final String SERVICE_NAME = "LogginUtilsTest: Test Entering method";
private LoggingUtils util;
@@ -72,8 +72,6 @@ public class LoggingUtilsTest {
// given
final String userName = "test";
- HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-
UserDetails userDetails = Mockito.mock(UserDetails.class);
Mockito.when(userDetails.getUsername()).thenReturn(userName);
@@ -84,34 +82,29 @@ public class LoggingUtilsTest {
Mockito.when(securityContext.getAuthentication()).thenReturn(localAuth);
SecurityContextHolder.setContext(securityContext);
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
// when
util.entering(request, SERVICE_NAME);
// then
- String[] keys = { ONAPLogConstants.MDCs.PARTNER_NAME,
- ONAPLogConstants.MDCs.ENTRY_TIMESTAMP,
- ONAPLogConstants.MDCs.REQUEST_ID,
- ONAPLogConstants.MDCs.INVOCATION_ID,
- ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS,
- ONAPLogConstants.MDCs.SERVER_FQDN,
- ONAPLogConstants.MDCs.INSTANCE_UUID,
- ONAPLogConstants.MDCs.SERVICE_NAME
- };
+ String[] keys = { OnapLogConstants.Mdcs.PARTNER_NAME, OnapLogConstants.Mdcs.ENTRY_TIMESTAMP,
+ OnapLogConstants.Mdcs.REQUEST_ID, OnapLogConstants.Mdcs.INVOCATION_ID,
+ OnapLogConstants.Mdcs.CLIENT_IP_ADDRESS, OnapLogConstants.Mdcs.SERVER_FQDN,
+ OnapLogConstants.Mdcs.INSTANCE_UUID, OnapLogConstants.Mdcs.SERVICE_NAME };
Map<String, String> mdc = MDC.getMDCAdapter().getCopyOfContextMap();
assertTrue(checkMapKeys(mdc, keys));
- assertEquals(userName,
- mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals(userName, mdc.get(OnapLogConstants.Mdcs.PARTNER_NAME));
}
@Test
public void testExistingLoggingUtils() {
// given
- MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP,
+ MDC.put(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP,
ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
// when
- util.exiting("200", SERVICE_NAME, Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
+ util.exiting("200", SERVICE_NAME, Level.INFO, OnapLogConstants.ResponseStatus.COMPLETED);
// then
Map<String, String> mdc = MDC.getMDCAdapter().getCopyOfContextMap();
@@ -130,16 +123,13 @@ public class LoggingUtilsTest {
// then
assertNotNull(secureConnection);
- String[] keys = {ONAPLogConstants.MDCs.TARGET_ENTITY,
- ONAPLogConstants.MDCs.TARGET_SERVICE_NAME,
- ONAPLogConstants.MDCs.INVOCATIONID_OUT,
- ONAPLogConstants.MDCs.INVOKE_TIMESTAMP
- };
+ String[] keys = { OnapLogConstants.Mdcs.TARGET_ENTITY, OnapLogConstants.Mdcs.TARGET_SERVICE_NAME,
+ OnapLogConstants.Mdcs.INVOCATIONID_OUT, OnapLogConstants.Mdcs.INVOKE_TIMESTAMP };
Map<String, String> mdc = MDC.getMDCAdapter().getCopyOfContextMap();
assertTrue(checkMapKeys(mdc, keys));
- assertEquals(targetEntity, mdc.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
- assertEquals(targetServiceName, mdc.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
+ assertEquals(targetEntity, mdc.get(OnapLogConstants.Mdcs.TARGET_ENTITY));
+ assertEquals(targetServiceName, mdc.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME));
}
private boolean checkMapKeys(Map map, String[] keys) {
diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java
index e46db1a2..4ae0a490 100644
--- a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java
@@ -52,7 +52,7 @@ public class ClampGraphTest {
when(mockDocumentBuilder.getGroupingDocument()).thenReturn(document);
- String actual = new ClampGraph(mockDocumentBuilder).getAsSVG();
+ String actual = new ClampGraph(mockDocumentBuilder).getAsSvg();
Assert.assertEquals(expected.trim(), actual.trim());
}
@@ -64,10 +64,10 @@ public class ClampGraphTest {
when(mockDocumentBuilder.getGroupingDocument()).thenReturn(document);
ClampGraph cg = new ClampGraph(mockDocumentBuilder);
- String actualFirst = cg.getAsSVG();
+ String actualFirst = cg.getAsSvg();
verify(mockDocumentBuilder, times(1)).getGroupingDocument();
- String actualSecond = cg.getAsSVG();
+ String actualSecond = cg.getAsSvg();
verifyNoMoreInteractions(mockDocumentBuilder);
Assert.assertEquals(expected.trim(), actualFirst.trim());
diff --git a/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java b/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
index 16136ae2..648c0330 100644
--- a/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
+++ b/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
@@ -25,13 +25,14 @@ package org.onap.clamp.flow;
import static junit.framework.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.clamp.clds.util.ONAPLogConstants;
+import org.onap.clamp.clds.util.OnapLogConstants;
import org.onap.clamp.flow.log.FlowLogOperation;
import org.slf4j.MDC;
import org.slf4j.spi.MDCAdapter;
@@ -43,57 +44,57 @@ public class FlowLogOperationTest {
@Test
public void testStratLog() {
- //given
- Exchange exchange = new DefaultExchange(mock(CamelContext.class));
+ // given
LoggingUtils loggingUtils = mock(LoggingUtils.class);
ReflectionTestUtils.setField(flowLogOperation, "util", loggingUtils);
- //when
- Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.REQUEST_ID)).thenReturn("MockRequestId");
- Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.INVOCATION_ID)).thenReturn("MockInvocationId");
- Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.PARTNER_NAME)).thenReturn("MockPartnerName");
+ // when
+ Mockito.when(loggingUtils.getProperties(OnapLogConstants.Mdcs.REQUEST_ID)).thenReturn("MockRequestId");
+ Mockito.when(loggingUtils.getProperties(OnapLogConstants.Mdcs.INVOCATION_ID)).thenReturn("MockInvocationId");
+ Mockito.when(loggingUtils.getProperties(OnapLogConstants.Mdcs.PARTNER_NAME)).thenReturn("MockPartnerName");
+ Exchange exchange = new DefaultExchange(mock(CamelContext.class));
flowLogOperation.startLog(exchange, "serviceName");
- //then
- assertThat(exchange.getProperty(ONAPLogConstants.Headers.REQUEST_ID)).isEqualTo("MockRequestId");
- assertThat(exchange.getProperty(ONAPLogConstants.Headers.INVOCATION_ID)).isEqualTo("MockInvocationId");
- assertThat(exchange.getProperty(ONAPLogConstants.Headers.PARTNER_NAME)).isEqualTo("MockPartnerName");
+ // then
+ assertThat(exchange.getProperty(OnapLogConstants.Headers.REQUEST_ID)).isEqualTo("MockRequestId");
+ assertThat(exchange.getProperty(OnapLogConstants.Headers.INVOCATION_ID)).isEqualTo("MockInvocationId");
+ assertThat(exchange.getProperty(OnapLogConstants.Headers.PARTNER_NAME)).isEqualTo("MockPartnerName");
}
@Test
public void testInvokeLog() {
- //given
+ // given
final String mockEntity = "mockEntity";
final String mockServiceName = "mockSerivceName";
MDCAdapter mdcAdapter = MDC.getMDCAdapter();
- //when
+ // when
flowLogOperation.invokeLog(mockEntity, mockServiceName);
- //then
- String entity = mdcAdapter.get(ONAPLogConstants.MDCs.TARGET_ENTITY);
- String serviceName = mdcAdapter.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME);
- assertEquals(entity,mockEntity);
- assertEquals(serviceName,mockServiceName);
+ // then
+ String entity = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_ENTITY);
+ String serviceName = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME);
+ assertEquals(entity, mockEntity);
+ assertEquals(serviceName, mockServiceName);
}
- @Test
+ @Test
public void testEndLog() {
- //given
- MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
- MDCAdapter mdcAdapter = MDC.getMDCAdapter();
- ///when
- flowLogOperation.endLog();
- //then
- assertThat(mdcAdapter.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)).isNull();
+ // given
+ MDC.put(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
+ MDCAdapter mdcAdapter = MDC.getMDCAdapter();
+ /// when
+ flowLogOperation.endLog();
+ // then
+ assertThat(mdcAdapter.get(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP)).isNull();
}
@Test
public void testErrorLog() {
- //given
- MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
+ // given
+ MDC.put(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
MDCAdapter mdcAdapter = MDC.getMDCAdapter();
- //when
+ // when
flowLogOperation.errorLog();
- //then
- assertThat(mdcAdapter.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)).isNull();
+ // then
+ assertThat(mdcAdapter.get(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP)).isNull();
}
} \ No newline at end of file