aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server/src
diff options
context:
space:
mode:
authorgrabinsk <maciej.grabinski@nokia.com>2019-05-23 14:25:24 +0200
committergrabinsk <maciej.grabinski@nokia.com>2019-05-23 14:25:24 +0200
commit14433b1454dd4b881b8b36f184d63528a43931ba (patch)
tree1b37d5de5dee6d701f43165ca4e35232c47a0129 /prh-app-server/src
parente2f12ecdee8f9320e23b95a1671cb7c8fcacf361 (diff)
Fix sending PNF_READY notification after update to El Alto SDK version usage
Change-Id: I06c1ae2b2a9831a4c31e09fafbe1500c10714caa Issue-ID: DCAEGEN2-1501 Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'prh-app-server/src')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java8
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java29
2 files changed, 17 insertions, 20 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
index 9cec7779..1a528180 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
@@ -20,10 +20,9 @@
package org.onap.dcaegen2.services.prh.tasks;
-import com.google.gson.JsonPrimitive;
import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.services.prh.model.PnfReadyJsonBodyBuilderImpl;
+import org.onap.dcaegen2.services.prh.model.PnfReadyJsonBodyBuilder;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterPublisher;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishRequest;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishResponse;
@@ -42,7 +41,7 @@ public class DmaapPublisherTaskImpl implements DmaapPublisherTask {
private final Supplier<MessageRouterPublishRequest> config;
private final MessageRouterPublisherResolver messageRouterPublisherClientResolver;
- private final PnfReadyJsonBodyBuilderImpl pnfReadyJsonBodyBuilder = new PnfReadyJsonBodyBuilderImpl();
+ private final PnfReadyJsonBodyBuilder pnfReadyJsonBodyBuilder = new PnfReadyJsonBodyBuilder();
public DmaapPublisherTaskImpl(Supplier<MessageRouterPublishRequest> config, MessageRouterPublisherResolver messageRouterPublisherClientResolver) {
@@ -57,9 +56,8 @@ public class DmaapPublisherTaskImpl implements DmaapPublisherTask {
}
MessageRouterPublisher messageRouterPublisher = messageRouterPublisherClientResolver.resolveClient();
LOGGER.info("Method called with arg {}", consumerDmaapModel);
- String json = pnfReadyJsonBodyBuilder.createJsonBody(consumerDmaapModel);
return messageRouterPublisher.put(
config.get(),
- Flux.just(json).map(JsonPrimitive::new));
+ Flux.just(pnfReadyJsonBodyBuilder.createJsonBody(consumerDmaapModel)));
}
} \ No newline at end of file
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
index 6347ad3d..6f38d87d 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
@@ -20,7 +20,8 @@
package org.onap.dcaegen2.services.prh.tasks;
-import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -38,10 +39,8 @@ import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRout
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.ImmutableMessageRouterPublishRequest;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishRequest;
import reactor.core.publisher.Flux;
+import reactor.test.StepVerifier;
-import java.util.function.Supplier;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
@@ -53,30 +52,27 @@ import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
class DmaapPublisherTaskImplTest {
- private static DmaapPublisherTaskImpl dmaapPublisherTask;
+ private DmaapPublisherTaskImpl dmaapPublisherTask;
+
+ private MessageRouterPublishRequest mrRequest = createMRRequest();
@Mock
private static MessageRouterPublisherResolver messageRouterPublisherClientResolver;
@Mock
private static MessageRouterPublisher messageRouterPublisher;
- private Supplier<MessageRouterPublishRequest> configSupplier;
-
-
@Captor
- private ArgumentCaptor<Flux<JsonPrimitive>> fluxCaptor;
+ private ArgumentCaptor<Flux<JsonElement>> fluxCaptor;
@BeforeEach
void beforeEach() {
when(messageRouterPublisherClientResolver.resolveClient()).thenReturn(messageRouterPublisher);
- MessageRouterPublishRequest mrRequest = createMRRequest();
- configSupplier = () -> mrRequest;
}
@Test
void execute_whenPassedObjectDoesntFit_ThrowsPrhTaskException() {
//given
- dmaapPublisherTask = new DmaapPublisherTaskImpl(configSupplier, messageRouterPublisherClientResolver);
+ dmaapPublisherTask = new DmaapPublisherTaskImpl(() -> mrRequest, messageRouterPublisherClientResolver);
//when
Executable executableFunction = () -> dmaapPublisherTask.execute(null);
//then
@@ -86,12 +82,15 @@ class DmaapPublisherTaskImplTest {
@Test
void execute_whenPassedObjectFits_ReturnsCorrectStatus() throws DmaapNotFoundException {
//given
- dmaapPublisherTask = new DmaapPublisherTaskImpl(configSupplier, messageRouterPublisherClientResolver);
+ dmaapPublisherTask = new DmaapPublisherTaskImpl(() -> mrRequest, messageRouterPublisherClientResolver);
//when
dmaapPublisherTask.execute(createConsumerDmaapModel());
//then
- verify(messageRouterPublisher).put(eq(configSupplier.get()), fluxCaptor.capture());
- assertEquals(new JsonPrimitive("{\"correlationId\":\"NOKQTFCOC540002E\"}"), fluxCaptor.getValue().blockFirst());
+ verify(messageRouterPublisher).put(eq(mrRequest), fluxCaptor.capture());
+
+ StepVerifier.create(fluxCaptor.getValue())
+ .expectNext(new JsonParser().parse("{\"correlationId\":\"NOKQTFCOC540002E\"}"))
+ .verifyComplete();
}