aboutsummaryrefslogtreecommitdiffstats
path: root/datafile-dmaap-client/src/test/java/org
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2019-01-07 13:48:18 +0100
committerelinuxhenrik <henrik.b.andersson@est.tech>2019-01-25 14:04:43 +0100
commit8a84a9d39fe71984bd5d861e8c865e748ca3df30 (patch)
tree76e50367dffde229a5f2bc427f3544bf60002d3a /datafile-dmaap-client/src/test/java/org
parenta224b4adbe65b476cdbd74efb3169aacbf292382 (diff)
Integration with SDK
* New fields added to DmaapPublisherConfiguraion * New fields added to DmaapConsumerConfiguration * Dmaap Consumer web client replaced by SDK's consumer web client * UTs aligned * Disable enforcer plugin in DFC * Update oparent to 1.2.1 Change-Id: I3569180c15227bc2c8df74fd070571b0aa56fa04 Issue-ID: DCAEGEN2-1096 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'datafile-dmaap-client/src/test/java/org')
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClientTest.java4
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java65
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java57
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java115
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java5
5 files changed, 6 insertions, 240 deletions
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClientTest.java
index 2eac5899..128f78f5 100644
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClientTest.java
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClientTest.java
@@ -25,7 +25,9 @@ import static org.mockito.Mockito.when;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
+
+
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
import org.springframework.web.reactive.function.client.WebClient;
class DmaapReactiveWebClientTest {
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java
deleted file mode 100644
index b67946b2..00000000
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ============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.service.config;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
-
-public class DmaapConsumerConfigurationTest {
-
- @Test
- public void builder_shouldBuildConfigurationObject() {
-
- // Given
- DmaapConsumerConfiguration configuration;
- String consumerId = "1";
- String dmaapHostName = "localhost";
- Integer dmaapPortNumber = 2222;
- String dmaapTopicName = "temp";
- String dmaapProtocol = "http";
- String dmaapUserName = "admin";
- String dmaapUserPassword = "admin";
- String dmaapContentType = "application/json";
- String consumerGroup = "other";
- Integer timeoutMs = 1000;
- Integer messageLimit = 1000;
-
- // When
- configuration = new ImmutableDmaapConsumerConfiguration.Builder().consumerId(consumerId)
- .dmaapHostName(dmaapHostName).dmaapPortNumber(dmaapPortNumber).dmaapTopicName(dmaapTopicName)
- .dmaapProtocol(dmaapProtocol).dmaapUserName(dmaapUserName).dmaapUserPassword(dmaapUserPassword)
- .dmaapContentType(dmaapContentType).consumerGroup(consumerGroup).timeoutMS(timeoutMs)
- .messageLimit(messageLimit).build();
-
- // Then
- Assertions.assertNotNull(configuration);
- Assertions.assertEquals(consumerId, configuration.consumerId());
- Assertions.assertEquals(dmaapHostName, configuration.dmaapHostName());
- Assertions.assertEquals(dmaapPortNumber, configuration.dmaapPortNumber());
- Assertions.assertEquals(dmaapTopicName, configuration.dmaapTopicName());
- Assertions.assertEquals(dmaapProtocol, configuration.dmaapProtocol());
- Assertions.assertEquals(dmaapUserName, configuration.dmaapUserName());
- Assertions.assertEquals(dmaapUserPassword, configuration.dmaapUserPassword());
- Assertions.assertEquals(consumerGroup, configuration.consumerGroup());
- Assertions.assertEquals(timeoutMs, configuration.timeoutMS());
- Assertions.assertEquals(messageLimit, configuration.messageLimit());
- }
-}
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java
deleted file mode 100644
index fb8e8751..00000000
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * ============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.service.config;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapPublisherConfiguration;
-
-public class DmaapPublisherConfigurationTest {
-
-
- @Test
- public void builder_shouldBuildConfigurationObject() {
-
- // Given
- DmaapPublisherConfiguration configuration;
- String dmaapHostName = "localhost";
- Integer dmaapPortNumber = 2222;
- String dmaapTopicName = "temp";
- String dmaapProtocol = "http";
- String dmaapUserName = "admin";
- String dmaapUserPassword = "admin";
- String dmaapContentType = "application/json";
-
- // When
- configuration = new ImmutableDmaapPublisherConfiguration.Builder().dmaapHostName(dmaapHostName)
- .dmaapPortNumber(dmaapPortNumber).dmaapTopicName(dmaapTopicName).dmaapProtocol(dmaapProtocol)
- .dmaapUserName(dmaapUserName).dmaapUserPassword(dmaapUserPassword).dmaapContentType(dmaapContentType)
- .build();
-
- // Then
- Assertions.assertNotNull(configuration);
- Assertions.assertEquals(dmaapHostName, configuration.dmaapHostName());
- Assertions.assertEquals(dmaapPortNumber, configuration.dmaapPortNumber());
- Assertions.assertEquals(dmaapTopicName, configuration.dmaapTopicName());
- Assertions.assertEquals(dmaapProtocol, configuration.dmaapProtocol());
- Assertions.assertEquals(dmaapUserName, configuration.dmaapUserName());
- Assertions.assertEquals(dmaapUserPassword, configuration.dmaapUserPassword());
- }
-}
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java
deleted file mode 100644
index 4568bdde..00000000
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * ============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.service.consumer;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.http.HttpHeaders;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.springframework.web.reactive.function.client.WebClient;
-import org.springframework.web.reactive.function.client.WebClient.RequestHeadersUriSpec;
-import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
-
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 6/27/18
- */
-class DmaapConsumerReactiveHttpClientTest {
-
- private DmaapConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient;
-
- private DmaapConsumerConfiguration consumerConfigurationMock = mock(DmaapConsumerConfiguration.class);
- private static final String JSON_MESSAGE = "{ \"responseFromDmaap\": \"Success\"}";
- private Mono<String> expectedResult = Mono.empty();
- private WebClient webClient;
- private RequestHeadersUriSpec requestHeadersSpecMock;
- private ResponseSpec responseSpecMock;
-
-
- @BeforeEach
- void setUp() {
- when(consumerConfigurationMock.dmaapHostName()).thenReturn("54.45.33.2");
- when(consumerConfigurationMock.dmaapProtocol()).thenReturn("https");
- when(consumerConfigurationMock.dmaapPortNumber()).thenReturn(1234);
- when(consumerConfigurationMock.dmaapUserName()).thenReturn("DATAFILE");
- when(consumerConfigurationMock.dmaapUserPassword()).thenReturn("DATFILE");
- when(consumerConfigurationMock.dmaapContentType()).thenReturn("application/json");
- when(consumerConfigurationMock.dmaapTopicName()).thenReturn("unauthenticated.VES_NOTIFICATION_OUTPUT");
- when(consumerConfigurationMock.consumerGroup()).thenReturn("OpenDCAE-c12");
- when(consumerConfigurationMock.consumerId()).thenReturn("c12");
-
- dmaapConsumerReactiveHttpClient = new DmaapConsumerReactiveHttpClient(consumerConfigurationMock);
- webClient = spy(WebClient.builder()
- .defaultHeader(HttpHeaders.CONTENT_TYPE, consumerConfigurationMock.dmaapContentType())
- .filter(basicAuthentication(consumerConfigurationMock.dmaapUserName(),
- consumerConfigurationMock.dmaapUserPassword()))
- .build());
- requestHeadersSpecMock = mock(RequestHeadersUriSpec.class);
- responseSpecMock = mock(ResponseSpec.class);
- }
-
-
- @Test
- void getHttpResponse_Success() {
- //given
- expectedResult = Mono.just(JSON_MESSAGE);
-
- //when
- mockDependantObjects();
- doReturn(expectedResult).when(responseSpecMock).bodyToMono(String.class);
- dmaapConsumerReactiveHttpClient.createDmaapWebClient(webClient);
-
- Mono<String> response = dmaapConsumerReactiveHttpClient.getDmaapConsumerResponse();
-
- //then
- StepVerifier.create(response).expectSubscription()
- .expectNextMatches(results -> {
- Assertions.assertEquals(results, expectedResult.block());
- return true;
- }).verifyComplete();
- }
-
- @Test
- void getAppropriateUri_whenPassingCorrectedUriData() throws URISyntaxException {
- Assertions.assertEquals(dmaapConsumerReactiveHttpClient.getUri(),
- URI.create("https://54.45.33.2:1234/unauthenticated.VES_NOTIFICATION_OUTPUT/OpenDCAE-c12/c12"));
- }
-
- private void mockDependantObjects() {
- when(webClient.get()).thenReturn(requestHeadersSpecMock);
- when(requestHeadersSpecMock.uri((URI) any())).thenReturn(requestHeadersSpecMock);
- when(requestHeadersSpecMock.headers(any())).thenReturn(requestHeadersSpecMock);
- when(requestHeadersSpecMock.retrieve()).thenReturn(responseSpecMock);
- doReturn(responseSpecMock).when(responseSpecMock).onStatus(any(), any());
- }
-
-} \ No newline at end of file
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java
index bf2f73d6..3fbd57cc 100644
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java
@@ -41,12 +41,13 @@ import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
+
import org.onap.dcaegen2.collectors.datafile.io.IFileSystemResource;
import org.onap.dcaegen2.collectors.datafile.model.CommonFunctions;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
import org.onap.dcaegen2.collectors.datafile.service.HttpUtils;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.util.DefaultUriBuilderFactory;
@@ -127,7 +128,7 @@ class DmaapProducerReactiveHttpClientTest {
HttpPut httpPut = new HttpPut();
httpPut.addHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_OCTET_STREAM_CONTENT_TYPE);
- JsonElement metaData = new JsonParser().parse(CommonFunctions.createJsonBody(consumerDmaapModel));
+ JsonElement metaData = new JsonParser().parse(new CommonFunctions().createJsonBody(consumerDmaapModel));
metaData.getAsJsonObject().remove(NAME_JSON_TAG).getAsString();
metaData.getAsJsonObject().remove(INTERNAL_LOCATION_JSON_TAG);
httpPut.addHeader(X_ATT_DR_META, metaData.toString());