diff options
author | Vijay Venkatesh Kumar <vv770d@att.com> | 2018-10-19 02:08:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-10-19 02:08:41 +0000 |
commit | f964ebd72b28c29d2b00cf09803e2076996376fe (patch) | |
tree | b5b523eb4a0460c90f007903cbc9c4804a8f89e1 /datafile-dmaap-client | |
parent | de72a7eec91acebcd002854bb6fd5c523d1ad571 (diff) | |
parent | ca7b24d35840388970812b4d7433c9e774a7427f (diff) |
Merge "Fixing Sonar issues & Test classes added"1.0.3
Diffstat (limited to 'datafile-dmaap-client')
7 files changed, 135 insertions, 0 deletions
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/io/IOutputStream.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/io/IOutputStream.java index cb9d8572..1ef790c0 100644 --- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/io/IOutputStream.java +++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/io/IOutputStream.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.OutputStream; +@FunctionalInterface public interface IOutputStream { public OutputStream getOutputStream(File file) throws FileNotFoundException; } diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/IFileSystemResource.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/IFileSystemResource.java index 6ecb1c6e..8c419465 100644 --- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/IFileSystemResource.java +++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/IFileSystemResource.java @@ -23,6 +23,7 @@ import java.io.InputStream; * @author * */ +@FunctionalInterface public interface IFileSystemResource { InputStream getInputStream() throws IOException; diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/IRestTemplate.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/IRestTemplate.java index 7f8d3b56..98e6ab46 100644 --- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/IRestTemplate.java +++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/IRestTemplate.java @@ -26,6 +26,7 @@ import org.springframework.http.ResponseEntity; * @author * */ +@FunctionalInterface public interface IRestTemplate { public ResponseEntity<String> exchange(URI url, HttpMethod method, HttpEntity<byte[]> requestEntity, Class<String> responseType); diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/web/IRestTemplate.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/web/IRestTemplate.java index 1102b54e..e7006338 100644 --- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/web/IRestTemplate.java +++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/web/IRestTemplate.java @@ -26,6 +26,7 @@ import org.springframework.http.ResponseEntity; * @author * */ +@FunctionalInterface public interface IRestTemplate { public ResponseEntity<String> exchange(URI url, HttpMethod method, HttpEntity<byte[]> requestEntity, Class<String> responseType); 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); + } +} |