diff options
author | Brinda Santh <brindasanth@in.ibm.com> | 2019-09-09 14:30:16 -0400 |
---|---|---|
committer | Brinda Santh <brindasanth@in.ibm.com> | 2019-09-11 21:00:56 -0400 |
commit | a80bb83c9f6fd4c648abfb273d5b2b28d82a38fa (patch) | |
tree | 50758b10922f546f25e74632e38c6ec4d3fbc256 /ms/sdclistener/application | |
parent | 8b24f42bcba5220f72b6977441867f774aca57df (diff) |
Implement GRPC response payload
Change-Id: I137cb9e2fa15c12f45a412d84e867f0613f15bf8
Issue-ID: CCSDK-1682
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/sdclistener/application')
2 files changed, 50 insertions, 26 deletions
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java index 77f3ea536..1937af75c 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java @@ -15,30 +15,16 @@ */ package org.onap.ccsdk.cds.sdclistener.service; -import static java.lang.String.format; -import static org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.NotificationType.SDC_LISTENER_COMPONENT; -import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_ERROR; -import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK; import com.google.protobuf.ByteString; import io.grpc.ManagedChannel; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Enumeration; -import java.util.List; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; import org.apache.commons.io.FileUtils; import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput; import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk; +import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction; import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor; import org.onap.ccsdk.cds.sdclistener.dto.SdcListenerDto; import org.onap.ccsdk.cds.sdclistener.handler.BluePrintProcesssorHandler; @@ -52,6 +38,22 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Enumeration; +import java.util.List; +import java.util.UUID; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import static java.lang.String.format; +import static org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.NotificationType.SDC_LISTENER_COMPONENT; +import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_ERROR; +import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK; + @Component @ConfigurationProperties("listenerservice") public class ListenerServiceImpl implements ListenerService { @@ -216,6 +218,13 @@ public class ListenerServiceImpl implements ListenerService { FileChunk fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(bytes)).build(); FileUtil.deleteFile(file, path); return BluePrintUploadInput.newBuilder() + .setCommonHeader(CommonHeader.newBuilder() + .setRequestId(UUID.randomUUID().toString()) + .setSubRequestId(UUID.randomUUID().toString()) + .setOriginatorId("SDC-LISTENER") + .build()) + .setActionIdentifiers(ActionIdentifiers.newBuilder() + .setActionName(UploadAction.PUBLISH.toString()).build()) .setFileChunk(fileChunk) .build(); } diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcessorHandlerTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcessorHandlerTest.java index ee20f8771..7a92c0040 100644 --- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcessorHandlerTest.java +++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcessorHandlerTest.java @@ -15,33 +15,39 @@ */ package org.onap.ccsdk.cds.sdclistener.handler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import com.google.protobuf.ByteString; import io.grpc.ManagedChannel; import io.grpc.inprocess.InProcessChannelBuilder; import io.grpc.inprocess.InProcessServerBuilder; import io.grpc.stub.StreamObserver; import io.grpc.testing.GrpcCleanupRule; -import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementOutput; import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase; import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput; import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk; +import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction; +import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.UUID; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @EnableConfigurationProperties({BluePrintProcesssorHandler.class, SdcListenerAuthClientInterceptor.class}) @SpringBootTest(classes = {BluePrintProcessorHandlerTest.class}) @@ -66,7 +72,7 @@ public class BluePrintProcessorHandlerTest { final BluePrintManagementServiceImplBase serviceImplBase = new BluePrintManagementServiceImplBase() { @Override public void uploadBlueprint(BluePrintUploadInput request, - StreamObserver<BluePrintManagementOutput> responseObserver) { + StreamObserver<BluePrintManagementOutput> responseObserver) { responseObserver.onNext(getBluePrintManagementOutput()); responseObserver.onCompleted(); } @@ -77,7 +83,7 @@ public class BluePrintProcessorHandlerTest { // Create a server, add service, start, and register. grpcCleanup.register( - InProcessServerBuilder.forName(serverName).addService(serviceImplBase).directExecutor().build().start()); + InProcessServerBuilder.forName(serverName).addService(serviceImplBase).directExecutor().build().start()); // Create a client channel. channel = grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()); @@ -101,7 +107,16 @@ public class BluePrintProcessorHandlerTest { byte[] bytes = FileUtils.readFileToByteArray(file); FileChunk fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(bytes)).build(); - return BluePrintUploadInput.newBuilder().setFileChunk(fileChunk).build(); + + return BluePrintUploadInput.newBuilder() + .setCommonHeader(CommonHeader.newBuilder() + .setRequestId(UUID.randomUUID().toString()) + .setSubRequestId(UUID.randomUUID().toString()) + .setOriginatorId("SDC-LISTENER") + .build()) + .setActionIdentifiers(ActionIdentifiers.newBuilder() + .setActionName(UploadAction.PUBLISH.toString()).build()) + .setFileChunk(fileChunk).build(); } private BluePrintManagementOutput getBluePrintManagementOutput() { |