diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2020-09-22 12:16:46 -0400 |
---|---|---|
committer | Singal, Kapil (ks220y) <ks220y@att.com> | 2020-09-22 13:49:05 -0400 |
commit | 1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch) | |
tree | 4a821659cf3b50cf946cbb535d528be8508e9fff /ms/sdclistener | |
parent | d97021cd756d63402545fdc2e14ac7611c3da118 (diff) |
Enabling Code Formatter
Code Formatter was turned off due to java 11 migation
Issue-ID: CCSDK-2852
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8
Diffstat (limited to 'ms/sdclistener')
20 files changed, 123 insertions, 117 deletions
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerApplication.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerApplication.java index 04cbebe7a..6795e8b31 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerApplication.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerApplication.java @@ -23,7 +23,7 @@ import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @EnableConfigurationProperties(SdcListenerConfiguration.class) -@ComponentScan(basePackages = {"org.onap.ccsdk.cds.blueprintsprocessor.healthapi","org.onap.ccsdk.cds.sdclistener"}) +@ComponentScan(basePackages = {"org.onap.ccsdk.cds.blueprintsprocessor.healthapi", "org.onap.ccsdk.cds.sdclistener"}) public class SdcListenerApplication { public static void main(String[] args) { diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerConfiguration.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerConfiguration.java index 686f0aa10..5caac6a5a 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerConfiguration.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerConfiguration.java @@ -23,8 +23,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import java.util.List; /** - * In order to initiate a SDC distribution client we need to supply some pre-configuration values that - * distribution client needs. + * In order to initiate a SDC distribution client we need to supply some pre-configuration values that distribution + * client needs. */ @ConfigurationProperties("listenerservice") public class SdcListenerConfiguration implements IConfiguration { diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java index f379e60a6..b8868325a 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java @@ -79,7 +79,7 @@ public class SdcListenerNotificationCallback implements INotificationCallback { /** * Download the TOSCA CSAR artifact and process it. * - * @param info - Artifact information + * @param info - Artifact information * @param distributionClient - SDC distribution client */ private void downloadCsarArtifacts(IArtifactInfo info, IDistributionClient distributionClient) { @@ -97,9 +97,8 @@ public class SdcListenerNotificationCallback implements INotificationCallback { if (!Objects.equals(result.getDistributionActionResult(), SUCCESS)) { final String errorMessage = String.format("Failed to download the artifact from : %s due to %s ", url, result.getDistributionActionResult()); - listenerStatus - .sendResponseBackToSdc(distributionId, DistributionStatusEnum.DOWNLOAD_ERROR, errorMessage, - url, NotificationType.DOWNLOAD); + listenerStatus.sendResponseBackToSdc(distributionId, DistributionStatusEnum.DOWNLOAD_ERROR, + errorMessage, url, NotificationType.DOWNLOAD); LOGGER.error(errorMessage); } else { listenerStatus.sendResponseBackToSdc(distributionId, DistributionStatusEnum.DOWNLOAD_OK, null, url, @@ -122,7 +121,7 @@ public class SdcListenerNotificationCallback implements INotificationCallback { if (!csarFiles.isEmpty()) { final String archivePath = cbaArchivePath.toString(); - //Extract CBA archive from CSAR package and store it into local disk + // Extract CBA archive from CSAR package and store it into local disk csarFiles.forEach(file -> listenerService.extractBluePrint(file.getAbsolutePath(), archivePath)); csarFiles.forEach(file -> FileUtil.deleteFile(file, csarArchivePath.toString())); } else { diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java index 5389dccc0..5748eda18 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java @@ -40,7 +40,7 @@ public class SdcListenerAuthClientInterceptor implements ClientInterceptor { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> methodDescriptor, - CallOptions callOptions, Channel channel) { + CallOptions callOptions, Channel channel) { Key<String> authHeader = Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER); return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>( channel.newCall(methodDescriptor, callOptions)) { diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerClient.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerClient.java index 030200924..2d8c1fe04 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerClient.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerClient.java @@ -81,8 +81,8 @@ public class SdcListenerClient { result = this.distributionClient.start(); if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { - throw new SdcListenerException( - "Startup of the SDC distribution client failed with reason: " + result.getDistributionMessageResult()); + throw new SdcListenerException("Startup of the SDC distribution client failed with reason: " + + result.getDistributionMessageResult()); } } diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java index 39d03c5bd..b0f8a12e4 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java @@ -28,8 +28,7 @@ import reactor.core.publisher.Mono; public class HealthCheck { @RequestMapping(path = "/healthcheck", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody - Mono<String> ping() { + public @ResponseBody Mono<String> ping() { return Mono.just("{\"status\":\"UP\"}"); } diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java index 19e700153..3ce826ce6 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java @@ -61,10 +61,8 @@ public class SdcListenerDto { } public void setManagedChannelForGrpc() { - managedChannel = ManagedChannelBuilder.forAddress(grpcAddress, grpcPort) - .usePlaintext() - .intercept(sdcListenerAuthClientInterceptor) - .build(); + managedChannel = ManagedChannelBuilder.forAddress(grpcAddress, grpcPort).usePlaintext() + .intercept(sdcListenerAuthClientInterceptor).build(); } public ManagedChannel getManagedChannelForGrpc() { diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/exceptions/SdcListenerException.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/exceptions/SdcListenerException.java index 458d667f3..bc7b57193 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/exceptions/SdcListenerException.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/exceptions/SdcListenerException.java @@ -27,7 +27,7 @@ public class SdcListenerException extends Exception { /** * @param message The message to dump - * @param cause The Throwable cause object + * @param cause The Throwable cause object */ public SdcListenerException(final String message, final Throwable cause) { super(message, cause); diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcesssorHandler.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcesssorHandler.java index 584713a50..b80dd260d 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcesssorHandler.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcesssorHandler.java @@ -38,7 +38,7 @@ public class BluePrintProcesssorHandler implements AutoCloseable { /** * Sending CBA archive to CDS backend to store into its Database. * - * @param request BluePrintManagementInput object holds CBA archive, its version and blueprints. + * @param request BluePrintManagementInput object holds CBA archive, its version and blueprints. * @param managedChannel - ManagedChannel object helps to access the server or application end point. * * @return A response object diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java index 9f0acd544..5fa3fb327 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java @@ -27,14 +27,14 @@ public interface ListenerService { * Get the controller blueprint archive from CSAR package. * * @param csarArchivePath The path where CSAR archive is stored. - * @param cbaArchivePath The destination path where CBA will be stored. + * @param cbaArchivePath The destination path where CBA will be stored. */ void extractBluePrint(String csarArchivePath, String cbaArchivePath); /** * Store the Zip file into CDS database. * - * @param path path where zip file exists. + * @param path path where zip file exists. * @param managedChannel To access the blueprint processor application end point */ void saveBluePrintToCdsDatabase(Path path, ManagedChannel managedChannel); @@ -42,7 +42,7 @@ public interface ListenerService { /** * Extract and store the csar package to local disk. * - * @param result - IDistributionClientDownloadResult contains payload. + * @param result - IDistributionClientDownloadResult contains payload. * @param csarArchivePath The destination path where CSAR will be stored. */ void extractCsarAndStore(IDistributionClientDownloadResult result, Path csarArchivePath); 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 19a62fb1d..ee27a9475 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 @@ -81,7 +81,8 @@ public class ListenerServiceImpl implements ListenerService { @Value("${listenerservice.config.grpcPort}") private int grpcPort; - private static final String CBA_ZIP_PATH = "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip"; + private static final String CBA_ZIP_PATH = + "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip"; private static final int SUCCESS_CODE = 200; private static final Logger LOGGER = LoggerFactory.getLogger(ListenerServiceImpl.class); @@ -105,17 +106,17 @@ public class ListenerServiceImpl implements ListenerService { } if (validPathCount == 0) { - LOGGER - .info("CBA archive doesn't exist in the CSAR Package or it doesn't exist as per the given path {}", - CBA_ZIP_PATH); - listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_OK, null, - artifactUrl, SDC_LISTENER_COMPONENT); + LOGGER.info( + "CBA archive doesn't exist in the CSAR Package or it doesn't exist as per the given path {}", + CBA_ZIP_PATH); + listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_OK, null, artifactUrl, + SDC_LISTENER_COMPONENT); } } catch (Exception e) { final String errorMessage = format("Failed to extract blueprint %s", e.getMessage()); - listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_ERROR, errorMessage, - artifactUrl, SDC_LISTENER_COMPONENT); + listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_ERROR, errorMessage, artifactUrl, + SDC_LISTENER_COMPONENT); LOGGER.error(errorMessage); } } @@ -133,8 +134,8 @@ public class ListenerServiceImpl implements ListenerService { LOGGER.error("Could not able to create file {}", targetZipFile, e); } - try (InputStream inputStream = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream( - targetZipFile)) { + try (InputStream inputStream = zipFile.getInputStream(entry); + OutputStream out = new FileOutputStream(targetZipFile)) { IOUtils.copy(inputStream, out); LOGGER.info("Successfully store the CBA archive {} at this location", targetZipFile); } catch (Exception e) { @@ -200,8 +201,8 @@ public class ListenerServiceImpl implements ListenerService { if (responseStatus.getCode() != SUCCESS_CODE) { final String errorMessage = format("Failed to store the CBA archive into CDS DB due to %s", responseStatus.getErrorMessage()); - listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_ERROR, errorMessage, artifactUrl, - SDC_LISTENER_COMPONENT); + listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_ERROR, errorMessage, + artifactUrl, SDC_LISTENER_COMPONENT); LOGGER.error(errorMessage); } else { LOGGER.info(responseStatus.getMessage()); @@ -223,15 +224,11 @@ 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(); + .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 String getDistributionId() { diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java index a24c0ddad..16cc2f32d 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java @@ -51,27 +51,26 @@ public class SdcListenerStatus { public enum NotificationType { - DOWNLOAD, - SDC_LISTENER_COMPONENT; + DOWNLOAD, SDC_LISTENER_COMPONENT; } /** * Send the component status back to SDC. * * @param distributionID SDC Distribution ID - * @param status Distribution status - * @param errorReason Reason of failure if present - * @param url Artifact URL - * @param type - NotificationType(Download or Component) + * @param status Distribution status + * @param errorReason Reason of failure if present + * @param url Artifact URL + * @param type - NotificationType(Download or Component) */ public void sendResponseBackToSdc(String distributionID, DistributionStatusEnum status, String errorReason, - String url, NotificationType type) { + String url, NotificationType type) { final IDistributionClient distributionClient = sdcListenerDto.getDistributionClient(); switch (type) { case SDC_LISTENER_COMPONENT: - IComponentDoneStatusMessage componentStatusMessage = buildStatusMessage(distributionID, status, url, - COMPONENT_NAME); + IComponentDoneStatusMessage componentStatusMessage = + buildStatusMessage(distributionID, status, url, COMPONENT_NAME); if (errorReason == null) { checkResponseStatusFromSdc(distributionClient.sendComponentDoneStatus(componentStatusMessage)); @@ -82,8 +81,8 @@ public class SdcListenerStatus { break; case DOWNLOAD: - IDistributionStatusMessage downloadStatusMessage = buildStatusMessage(distributionID, status, url, - null); + IDistributionStatusMessage downloadStatusMessage = + buildStatusMessage(distributionID, status, url, null); if (errorReason == null) { checkResponseStatusFromSdc(distributionClient.sendDownloadStatus(downloadStatusMessage)); @@ -97,7 +96,7 @@ public class SdcListenerStatus { } private ComponentStatusMessage buildStatusMessage(String distributionId, DistributionStatusEnum status, String url, - String componentName) { + String componentName) { return new BuilderUtil<>(new ComponentStatusMessage()).build(builder -> { builder.setDistributionID(distributionId); builder.setStatus(status); diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java index f1c1c735d..d8e75e260 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java @@ -62,9 +62,7 @@ public final class FileUtil { try (Stream<Path> fileTree = walk(path)) { // Get the list of files from the path - return fileTree.filter(Files :: isRegularFile) - .map(Path :: toFile) - .collect(Collectors.toList()); + return fileTree.filter(Files::isRegularFile).map(Path::toFile).collect(Collectors.toList()); } catch (IOException e) { LOGGER.error("Failed to find the file due to", e); } diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/SdcListenerClientTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/SdcListenerClientTest.java index d27d1c491..9f0840987 100644 --- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/SdcListenerClientTest.java +++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/SdcListenerClientTest.java @@ -39,11 +39,11 @@ public class SdcListenerClientTest { @Test public void testInitCdsClientSuccesfully(@Injectable IDistributionClient distributionClient, - @Injectable SdcListenerConfiguration configuration, - @Injectable SdcListenerNotificationCallback notification, - @Injectable SdcListenerDto sdcListenerDto) throws SdcListenerException { + @Injectable SdcListenerConfiguration configuration, + @Injectable SdcListenerNotificationCallback notification, @Injectable SdcListenerDto sdcListenerDto) + throws SdcListenerException { - //Arrange + // Arrange new MockUp<DistributionClientFactory>() { @Mock public IDistributionClient createDistributionClient() { @@ -51,24 +51,30 @@ public class SdcListenerClientTest { } }; - new Expectations() {{ - distributionClient.init(configuration, notification); - result = getResult(); - }}; + new Expectations() { + { + distributionClient.init(configuration, notification); + result = getResult(); + } + }; - new Expectations() {{ - distributionClient.start(); - result = getResult(); - }}; + new Expectations() { + { + distributionClient.start(); + result = getResult(); + } + }; // Act sdcListenerClient.initSdcClient(); // Verify - new VerificationsInOrder() {{ - distributionClient.init(configuration, notification); - distributionClient.start(); - }}; + new VerificationsInOrder() { + { + distributionClient.init(configuration, notification); + distributionClient.start(); + } + }; } public IDistributionClientResult getResult() { diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDtoTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDtoTest.java index 1f4ba81f7..f27b22ce6 100644 --- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDtoTest.java +++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDtoTest.java @@ -35,6 +35,7 @@ * * */ + package org.onap.ccsdk.cds.sdclistener.dto; import org.junit.Test; @@ -49,7 +50,7 @@ import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor; import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@EnableConfigurationProperties({SdcListenerDto.class,SdcListenerAuthClientInterceptor.class}) +@EnableConfigurationProperties({SdcListenerDto.class, SdcListenerAuthClientInterceptor.class}) @SpringBootTest(classes = {SdcListenerDtoTest.class}) public class SdcListenerDtoTest { diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/exceptions/SdcListenerExceptionTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/exceptions/SdcListenerExceptionTest.java index 72f0ef289..6f08f0b90 100644 --- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/exceptions/SdcListenerExceptionTest.java +++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/exceptions/SdcListenerExceptionTest.java @@ -35,16 +35,18 @@ * * */ + package org.onap.ccsdk.cds.sdclistener.exceptions; import org.junit.Test; import static org.junit.Assert.assertEquals; + public class SdcListenerExceptionTest { @Test public void testConstructor() { - final String s1="Exception occured"; - SdcListenerException sle=new SdcListenerException(s1); - assertEquals(sle.getMessage(),"Exception occured"); + final String s1 = "Exception occured"; + SdcListenerException sle = new SdcListenerException(s1); + assertEquals(sle.getMessage(), "Exception occured"); } } 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 8a4bb2224..7cde45d9e 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 @@ -73,7 +73,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(); } @@ -83,8 +83,8 @@ public class BluePrintProcessorHandlerTest { String serverName = InProcessServerBuilder.generateName(); // Create a server, add service, start, and register. - grpcCleanup.register( - InProcessServerBuilder.forName(serverName).addService(serviceImplBase).directExecutor().build().start()); + grpcCleanup.register(InProcessServerBuilder.forName(serverName).addService(serviceImplBase).directExecutor() + .build().start()); // Create a client channel. channel = grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()); @@ -109,20 +109,16 @@ public class BluePrintProcessorHandlerTest { FileChunk fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(bytes)).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()) + .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() { return BluePrintManagementOutput.newBuilder() - .setStatus(Status.newBuilder().setMessage(SUCCESS_MSG).setCode(200).build()) - .build(); + .setStatus(Status.newBuilder().setMessage(SUCCESS_MSG).setCode(200).build()).build(); } } diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java index 5d25ac2bf..4179ccab0 100644 --- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java +++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java @@ -50,15 +50,15 @@ import static org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.Notificati import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK; @RunWith(SpringRunner.class) -@EnableConfigurationProperties({SdcListenerAuthClientInterceptor.class, - BluePrintProcesssorHandler.class, SdcListenerDto.class, ListenerServiceImpl.class, SdcListenerStatus.class, - SdcListenerConfiguration.class}) +@EnableConfigurationProperties({SdcListenerAuthClientInterceptor.class, BluePrintProcesssorHandler.class, + SdcListenerDto.class, ListenerServiceImpl.class, SdcListenerStatus.class, SdcListenerConfiguration.class}) @SpringBootTest(classes = {ListenerServiceImplTest.class}) public class ListenerServiceImplTest { private static final String CSAR_SAMPLE = "src/test/resources/service-ServicePnfTest-csar.csar"; private static final String WRONG_CSAR_SAMPLE = "src/test/resources/wrong_csar_pattern.csar"; - private static final String CBA_ZIP_PATH = "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip"; + private static final String CBA_ZIP_PATH = + "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip"; private static final String ZIP_FILE = ".zip"; private static final String CSAR_FILE = ".csar"; private static final String DISTRIBUTION_ID = "1"; @@ -104,15 +104,15 @@ public class ListenerServiceImplTest { // Arrange Mockito.when(listenerDto.getDistributionId()).thenReturn(DISTRIBUTION_ID); Mockito.when(listenerDto.getArtifactUrl()).thenReturn(URL); - Mockito.doCallRealMethod().when(status) - .sendResponseBackToSdc(DISTRIBUTION_ID, COMPONENT_DONE_OK, null, URL, SDC_LISTENER_COMPONENT); + Mockito.doCallRealMethod().when(status).sendResponseBackToSdc(DISTRIBUTION_ID, COMPONENT_DONE_OK, null, URL, + SDC_LISTENER_COMPONENT); // Act listenerService.extractBluePrint(WRONG_CSAR_SAMPLE, tempDirectoryPath.toString()); // Verify - Mockito.verify(status) - .sendResponseBackToSdc(DISTRIBUTION_ID, COMPONENT_DONE_OK, null, URL, SDC_LISTENER_COMPONENT); + Mockito.verify(status).sendResponseBackToSdc(DISTRIBUTION_ID, COMPONENT_DONE_OK, null, URL, + SDC_LISTENER_COMPONENT); } @Test @@ -129,12 +129,7 @@ public class ListenerServiceImplTest { } private String checkFileExists(Path path) throws IOException { - return Files.walk(path) - .filter(Files :: isRegularFile) - .map(Path :: toFile) - .findAny() - .get() - .getName(); + return Files.walk(path).filter(Files::isRegularFile).map(Path::toFile).findAny().get().getName(); } public byte[] convertFileToByteArray(File file) { @@ -146,11 +141,10 @@ public class ListenerServiceImplTest { return null; } - public class DistributionClientDownloadResultStubImpl extends DistributionClientResultStubImpl implements - IDistributionClientDownloadResult { + public class DistributionClientDownloadResultStubImpl extends DistributionClientResultStubImpl + implements IDistributionClientDownloadResult { - public DistributionClientDownloadResultStubImpl() { - } + public DistributionClientDownloadResultStubImpl() {} public byte[] getArtifactPayload() { File file = Paths.get(CSAR_SAMPLE).toFile(); diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessageTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessageTest.java index 898596dfa..c9abfe622 100644 --- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessageTest.java +++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessageTest.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2020 AT&T. + * + * 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. + */ + package org.onap.ccsdk.cds.sdclistener.status; import org.junit.Test; @@ -11,7 +27,7 @@ import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) @SpringBootTest(classes = {ComponentStatusMessageTest.class}) public class ComponentStatusMessageTest { - ComponentStatusMessage componentStatusMsg= new ComponentStatusMessage(); + ComponentStatusMessage componentStatusMsg = new ComponentStatusMessage(); @Test public void testComponentStatusMessage() { diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/util/FileUtilTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/util/FileUtilTest.java index a43e8c072..c368329e4 100644 --- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/util/FileUtilTest.java +++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/util/FileUtilTest.java @@ -35,6 +35,7 @@ * * */ + package org.onap.ccsdk.cds.sdclistener.util; import org.junit.Test; @@ -58,25 +59,25 @@ import static org.junit.Assert.*; @SpringBootTest(classes = {FileUtilTest.class}) public class FileUtilTest { - FileUtil fs; + FileUtil fs; @Test public void testDeleteFile() throws IOException { File tempFile = File.createTempFile("tempFile", ".txt"); -// System.out.println(tempFile.getRoot()); - fs.deleteFile(tempFile,tempFile.getAbsolutePath()); + // System.out.println(tempFile.getRoot()); + fs.deleteFile(tempFile, tempFile.getAbsolutePath()); assertFalse(tempFile.exists()); } @Test - public void testGetFilesFromDisk() throws IOException{ + public void testGetFilesFromDisk() throws IOException { - Path resourceDirectory = Paths.get("src","test","resources"); - int totalfile=resourceDirectory.getNameCount(); - List fileList=fs.getFilesFromDisk(resourceDirectory); + Path resourceDirectory = Paths.get("src", "test", "resources"); + int totalfile = resourceDirectory.getNameCount(); + List fileList = fs.getFilesFromDisk(resourceDirectory); assertNotNull(fileList); - assertEquals(fileList.size(),totalfile); + assertEquals(fileList.size(), totalfile); } |