aboutsummaryrefslogtreecommitdiffstats
path: root/datafile-dmaap-client/src/test/java
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-10-16 15:17:51 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-10-18 12:06:43 +0200
commitca7b24d35840388970812b4d7433c9e774a7427f (patch)
tree31cc63b5eed619a309d3d1243eab6a91c1a52c3b /datafile-dmaap-client/src/test/java
parentb47ed92edbf3b4f50b814a4b1912b5ef6185c294 (diff)
Fixing Sonar issues & Test classes added
Change-Id: I88ace2333d9f52fcd81eb4d1b883a04dd329c4cc Issue-ID: DCAEGEN2-835 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'datafile-dmaap-client/src/test/java')
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/PublishRedirectStrategyTest.java42
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/RequestResponseLoggingInterceptorTest.java55
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/RestTemplateWrapperTest.java34
3 files changed, 131 insertions, 0 deletions
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/PublishRedirectStrategyTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/PublishRedirectStrategyTest.java
new file mode 100644
index 00000000..fb0cc294
--- /dev/null
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/PublishRedirectStrategyTest.java
@@ -0,0 +1,42 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. All rights reserved.
+ * ===============================================================================================
+ * 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. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END========================================================================
+ */
+
+package org.onap.dcaegen2.collectors.datafile.web;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+class PublishRedirectStrategyTest {
+
+ private static PublishRedirectStrategy publishRedirectStrategy;
+
+
+ @BeforeAll
+ static void setUp() {
+ publishRedirectStrategy = new PublishRedirectStrategy();
+ }
+
+ @Test
+ void isRedirectable_shouldReturnTrue() {
+ Assertions.assertTrue(publishRedirectStrategy.isRedirectable("Put"));
+ }
+
+ @Test
+ void isRedirectable_shouldReturnFalse() {
+ Assertions.assertFalse(publishRedirectStrategy.isRedirectable("not valid method"));
+ }
+}
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/RequestResponseLoggingInterceptorTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/RequestResponseLoggingInterceptorTest.java
new file mode 100644
index 00000000..b0f5c931
--- /dev/null
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/RequestResponseLoggingInterceptorTest.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. All rights reserved.
+ * ===============================================================================================
+ * 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. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END========================================================================
+ */
+
+package org.onap.dcaegen2.collectors.datafile.web;
+
+
+import org.junit.jupiter.api.Test;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.client.ClientHttpRequestExecution;
+import org.springframework.http.client.ClientHttpResponse;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
+class RequestResponseLoggingInterceptorTest {
+
+ @Test
+ void intercept_shouldReturnObject() throws URISyntaxException, IOException {
+
+ //given
+ RequestResponseLoggingInterceptor requestResponseLoggingInterceptor = new RequestResponseLoggingInterceptor();
+
+ ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class);
+ HttpRequest request = mock(HttpRequest.class);
+ ClientHttpResponse response = mock(ClientHttpResponse.class);
+
+ byte[] BODY = new byte[] { (byte)0xe0, 0x4f, (byte)0xd0, 0x20, (byte)0xa2 };
+ URI uri = new URI("www.someuri.com");
+
+ //when
+ when(execution.execute(request, BODY)).thenReturn(response);
+
+ //then
+ assertNotNull(requestResponseLoggingInterceptor.intercept(request, BODY, execution));
+ }
+}
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/RestTemplateWrapperTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/RestTemplateWrapperTest.java
new file mode 100644
index 00000000..3a0701ff
--- /dev/null
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/web/RestTemplateWrapperTest.java
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. All rights reserved.
+ * ===============================================================================================
+ * 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. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END========================================================================
+ */
+
+package org.onap.dcaegen2.collectors.datafile.web;
+
+import org.junit.jupiter.api.Test;
+
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class RestTemplateWrapperTest {
+
+ @Test
+ void constructor_shouldReturnNotNullObject() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
+ RestTemplateWrapper restTemplateWrapper = new RestTemplateWrapper();
+ assertNotNull(restTemplateWrapper);
+ }
+}