diff options
author | 2020-09-22 12:16:46 -0400 | |
---|---|---|
committer | 2020-09-22 13:49:05 -0400 | |
commit | 1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch) | |
tree | 4a821659cf3b50cf946cbb535d528be8508e9fff /ms/sdclistener/application/src/test | |
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/application/src/test')
7 files changed, 75 insertions, 59 deletions
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); } |