summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/test/java
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-04-13 14:03:26 +0200
committerPrzemyslaw Wasala <przemyslaw.wasala@nokia.com>2018-04-13 12:34:10 +0000
commit92f9c348d3e51f4032e858c6ae443b70a74e8699 (patch)
tree52f3266b2bf85a4bd43e52d4504ff9291a9ebb60 /prh-app-server/src/test/java
parentcf292d97e6228677024702dd1391cc5fbe759606 (diff)
Extracted high abstraction for tasks
*First of all, all tasks were defined as implementation. *All tasks class have been injected into spring container. Change-Id: I00337b49ed1de3f1b8cadf64f774f19377ae349e Issue-ID: DCAEGEN2-443 Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
Diffstat (limited to 'prh-app-server/src/test/java')
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java9
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java39
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java9
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskSpy.java40
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java14
5 files changed, 96 insertions, 15 deletions
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 9cc1793a..0c92da77 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
@@ -30,7 +30,7 @@ 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.tasks.ScheduledTask;
+import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -52,7 +52,7 @@ class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests {
private static final int WAIT_FOR_SCHEDULING = 1;
@Autowired
- private ScheduledTask scheduledTask;
+ private ScheduledTasks scheduledTask;
@Test
void testScheduling() {
@@ -61,14 +61,13 @@ class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests {
}
private void verifyDmaapConsumerTask() {
- verify(scheduledTask, atLeast(2)).scheduledTaskAskingDMaaPOfConsumeEvent();
+ verify(scheduledTask, atLeast(2)).scheduleMainPrhEventTask();
}
-
-
}
@Configuration
class ServiceMockProvider {
+
@Bean
public PrhAppConfig getPrhAppConfig() {
return mock(PrhAppConfig.class);
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
new file mode 100644
index 00000000..56565cad
--- /dev/null
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java
@@ -0,0 +1,39 @@
+/*
+ * ============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 static org.mockito.Mockito.spy;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
+ */
+@Configuration
+public class AAIPublisherTaskSpy {
+
+ @Bean
+ @Primary
+ public AAIPublisherTask registerSimpleAAIPublisherTask() {
+ return spy(new AAIPublisherTaskImpl());
+ }
+}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java
index 1f5b858a..d41da169 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java
@@ -20,12 +20,7 @@
package org.onap.dcaegen2.services.prh.tasks;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-import org.junit.runners.Parameterized.UseParametersRunnerFactory;
-import org.onap.dcaegen2.services.prh.configuration.AppConfig;
-import org.onap.dcaegen2.services.prh.configuration.PrhAppConfig;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
@@ -38,7 +33,7 @@ public class DmaapConsumerTaskSpy {
@Bean
@Primary
- public DmaapConsumerTask registerSimpleDmaapConsumerTask() {
- return spy(new DmaapConsumerTask());
+ public DmaapConsumerTaskImpl registerSimpleDmaapConsumerTask() {
+ return spy(new DmaapConsumerTaskImpl());
}
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskSpy.java
new file mode 100644
index 00000000..8bdc7a1d
--- /dev/null
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskSpy.java
@@ -0,0 +1,40 @@
+/*
+ * ============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 static org.mockito.Mockito.spy;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
+ */
+@Configuration
+public class DmaapPublisherTaskSpy {
+
+
+ @Bean
+ @Primary
+ public DmaapPublisherTaskImpl registerSimpleDmaapPublisherTask() {
+ return spy(new DmaapPublisherTaskImpl());
+ }
+}
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 d4975098..0b5f969b 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
@@ -22,6 +22,7 @@ package org.onap.dcaegen2.services.prh.tasks;
import static org.mockito.Mockito.spy;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
@@ -32,12 +33,19 @@ import org.springframework.context.annotation.Primary;
@Configuration
public class ScheduleControllerSpy {
+
+ @Autowired
+ private DmaapConsumerTask dmaapConsumerTaskImplSpy;
+
+ @Autowired
+ private DmaapPublisherTask dmaapPublisherTaskImplSpy;
+
@Autowired
- private DmaapConsumerTask dmaapConsumerTaskSpy;
+ private AAIPublisherTask aaiPublisherTaskImplSpy;
@Bean
@Primary
- public ScheduledTask registerSimpleDmaapConsumerTask() {
- return spy(new ScheduledTask(dmaapConsumerTaskSpy));
+ public ScheduledTasks registerSimpleScheduledTask() {
+ return spy(new ScheduledTasks(dmaapConsumerTaskImplSpy, dmaapPublisherTaskImplSpy, aaiPublisherTaskImplSpy));
}
}