From bf6fa5deff9190c14bba2b15271e44f1e3c21ee7 Mon Sep 17 00:00:00 2001 From: pwielebs Date: Thu, 26 Apr 2018 17:04:09 +0200 Subject: AAI tasks added - aaiClients spllitted for consuming and producing - http removed from names of all clients and interfaces - HttpRequestDetails added as a second parameter for tasks - parameters required from dmaap consumer - pnf-name for URI (get request -> aaiConsumer) - pnf-name and ipv4-oam (and or ipv6-oam) (patch request -> aaiProducer) Change-Id: I87a1b46ab419cd00e9573e08c4d89cb384dd75b5 Issue-ID: DCAEGEN2-451 Signed-off-by: pwielebs --- .../services/prh/IT/ScheduledXmlContextITest.java | 11 +++--- .../prh/configuration/PrhAppConfigTest.java | 10 ++--- .../services/prh/tasks/AAIConsumerTaskSpy.java | 44 ++++++++++++++++++++++ .../services/prh/tasks/AAIPublisherTaskSpy.java | 16 ++++---- .../services/prh/tasks/ScheduleControllerSpy.java | 7 +++- 5 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskSpy.java (limited to 'prh-app-server/src/test') diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java index faecec4d..8094c993 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java @@ -23,19 +23,15 @@ import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.onap.dcaegen2.services.prh.IT.junit5.mockito.MockitoExtension; import org.onap.dcaegen2.services.prh.configuration.PrhAppConfig; -import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException; import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks; +import org.onap.dcaegen2.services.utils.HttpRequestDetails; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -77,6 +73,11 @@ class ServiceMockProvider { public PrhAppConfig getPrhAppConfig() { return mock(PrhAppConfig.class); } + + @Bean + public HttpRequestDetails getRequestDetails() { + return mock(HttpRequestDetails.class); + } } diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java index 764bafec..e7d55419 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java @@ -88,13 +88,13 @@ class PrhAppConfigTest { prhAppConfig.initFileStreamReader(); appConfig.dmaapConsumerConfiguration = prhAppConfig.getDmaapConsumerConfiguration(); appConfig.dmaapPublisherConfiguration = prhAppConfig.getDmaapPublisherConfiguration(); - appConfig.aaiHttpClientConfiguration = prhAppConfig.getAAIHttpClientConfiguration(); + appConfig.aaiClientConfiguration = prhAppConfig.getAAIClientConfiguration(); // // Then // verify(prhAppConfig, times(1)).setFilepath(anyString()); verify(prhAppConfig, times(1)).initFileStreamReader(); - Assertions.assertNotNull(prhAppConfig.getAAIHttpClientConfiguration()); + Assertions.assertNotNull(prhAppConfig.getAAIClientConfiguration()); Assertions.assertNotNull(prhAppConfig.getDmaapConsumerConfiguration()); Assertions.assertNotNull(prhAppConfig.getDmaapPublisherConfiguration()); Assertions @@ -102,7 +102,7 @@ class PrhAppConfigTest { Assertions .assertEquals(appConfig.getDmaapConsumerConfiguration(), prhAppConfig.getDmaapConsumerConfiguration()); Assertions - .assertEquals(appConfig.getAAIHttpClientConfiguration(), prhAppConfig.getAAIHttpClientConfiguration()); + .assertEquals(appConfig.getAAIClientConfiguration(), prhAppConfig.getAAIClientConfiguration()); } @@ -122,7 +122,7 @@ class PrhAppConfigTest { // verify(prhAppConfig, times(1)).setFilepath(anyString()); verify(prhAppConfig, times(1)).initFileStreamReader(); - Assertions.assertNull(prhAppConfig.getAAIHttpClientConfiguration()); + Assertions.assertNull(prhAppConfig.getAAIClientConfiguration()); Assertions.assertNull(prhAppConfig.getDmaapConsumerConfiguration()); Assertions.assertNull(prhAppConfig.getDmaapPublisherConfiguration()); @@ -147,7 +147,7 @@ class PrhAppConfigTest { // verify(prhAppConfig, times(1)).setFilepath(anyString()); verify(prhAppConfig, times(1)).initFileStreamReader(); - Assertions.assertNotNull(prhAppConfig.getAAIHttpClientConfiguration()); + Assertions.assertNotNull(prhAppConfig.getAAIClientConfiguration()); Assertions.assertNotNull(prhAppConfig.getDmaapConsumerConfiguration()); Assertions.assertNull(prhAppConfig.getDmaapPublisherConfiguration()); diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskSpy.java new file mode 100644 index 00000000..57c3ce21 --- /dev/null +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskSpy.java @@ -0,0 +1,44 @@ +/* + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. 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.services.prh.tasks; + +import org.onap.dcaegen2.services.config.AAIClientConfiguration; + +import org.onap.dcaegen2.services.prh.configuration.AppConfig; +import org.onap.dcaegen2.services.utils.HttpRequestDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import static org.mockito.Mockito.*; + + +@Configuration +public class AAIConsumerTaskSpy { + + @Bean + @Primary + public AAIConsumerTask registerSimpleAAIPublisherTask() { + AppConfig appConfig = mock(AppConfig.class); + HttpRequestDetails requestDetails = mock(HttpRequestDetails.class); + when(appConfig.getAAIClientConfiguration()).thenReturn(mock(AAIClientConfiguration.class)); + return spy(new AAIConsumerTaskImpl(appConfig, requestDetails)); + } +} \ No newline at end of file diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java index c27c8813..8da7f85d 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java @@ -19,16 +19,15 @@ */ package org.onap.dcaegen2.services.prh.tasks; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration; +import org.onap.dcaegen2.services.config.AAIClientConfiguration; import org.onap.dcaegen2.services.prh.configuration.AppConfig; +import org.onap.dcaegen2.services.utils.HttpRequestDetails; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; +import static org.mockito.Mockito.*; + /** * @author Przemysław Wąsala on 4/13/18 */ @@ -37,9 +36,10 @@ public class AAIPublisherTaskSpy { @Bean @Primary - public AAIPublisherTask registerSimpleAAIPublisherTask() { + public AAIProducerTask registerSimpleAAIPublisherTask() { AppConfig appConfig = mock(AppConfig.class); - when(appConfig.getAAIHttpClientConfiguration()).thenReturn(mock(AAIHttpClientConfiguration.class)); - return spy(new AAIPublisherTaskImpl(appConfig)); + HttpRequestDetails requestDetails = mock(HttpRequestDetails.class); + when(appConfig.getAAIClientConfiguration()).thenReturn(mock(AAIClientConfiguration.class)); + return spy(new AAIProducerTaskImpl(appConfig, requestDetails)); } } diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java index 2d599b23..606b0cb8 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java @@ -40,11 +40,14 @@ public class ScheduleControllerSpy { private DmaapPublisherTask dmaapPublisherTaskImplSpy; @Autowired - private AAIPublisherTask aaiPublisherTaskImplSpy; + private AAIProducerTask aaiPublisherTaskImplSpy; + + @Autowired + private AAIConsumerTask aaiConsumerTaskImplSpy; @Bean @Primary public ScheduledTasks registerSimpleScheduledTask() { - return spy(new ScheduledTasks(dmaapConsumerTaskImplSpy, dmaapPublisherTaskImplSpy, aaiPublisherTaskImplSpy)); + return spy(new ScheduledTasks(dmaapConsumerTaskImplSpy, dmaapPublisherTaskImplSpy, aaiPublisherTaskImplSpy, aaiConsumerTaskImplSpy)); } } -- cgit 1.2.3-korg