From 1b6a428451709a3daa98d0f1cdee49d791985c0d Mon Sep 17 00:00:00 2001 From: sebdet Date: Tue, 5 Nov 2019 13:44:53 +0100 Subject: Move to JDK 13 Do the required changes to move to JDK 13 Issue-ID: CLAMP-327 Change-Id: Ia7840851eeefc6c00e3e49eacb2e49cc27a0b2f0 Signed-off-by: sebdet --- pom.xml | 53 +++++++++++++++---- src/main/docker/backend/Dockerfile | 2 +- .../exception/policy/PolicyModelException.java | 31 ----------- .../clds/sdc/controller/SdcSingleController.java | 61 +++++++++------------- .../sdc/controller/installer/CsarInstaller.java | 4 +- .../org/onap/clamp/loop/LoopCsarInstaller.java | 4 +- .../clds/it/AuthorizationControllerItCase.java | 41 ++++++--------- .../org/onap/clamp/clds/util/CryptoUtilsTest.java | 12 ++--- .../clds/util/drawing/DocumentBuilderTest.java | 10 ++-- .../org/onap/clamp/loop/CsarInstallerItCase.java | 56 ++++++++++---------- 10 files changed, 125 insertions(+), 149 deletions(-) delete mode 100644 src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java diff --git a/pom.xml b/pom.xml index 76a0e4f1d..7c1b6d524 100644 --- a/pom.xml +++ b/pom.xml @@ -75,14 +75,12 @@ yyyyMMdd'T'HHmmss'Z' ${project.version} ${maven.build.timestamp} - 1.8 - 1.8 UTF-8 UTF-8 1.0.0 2.24.0 - 2.1.5.RELEASE + 2.2.0.RELEASE jacoco ${project.build.directory}/surefire-reports @@ -105,7 +103,7 @@ true false - 9.0.20 + 9.0.27 ui-react https://nexus3.onap.org/repository/npm.release/ @@ -276,6 +274,16 @@ com.att.eelf eelf-core ${eelf.core.version} + + + org.powermock + powermock-module-junit4 + + + org.powermock + powermock-api-mockito + + org.codehaus.janino @@ -515,7 +523,19 @@ org.mockito mockito-core - 1.10.19 + 2.28.2 + test + + + org.powermock + powermock-api-mockito2 + 2.0.4 + test + + + org.powermock + powermock-module-junit4 + 2.0.4 test @@ -795,7 +815,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.1 + 2.22.2 1C true @@ -807,7 +827,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.22.1 + 2.22.2 integration-tests @@ -833,7 +853,7 @@ io.fabric8 docker-maven-plugin - 0.27.2 + 0.31.0 org.apache.httpcomponents @@ -869,6 +889,9 @@ ${docker.mariadb.port.host}:3306 + + bridge + @@ -899,6 +922,9 @@ ./start_http_cache.sh ${python.http.proxy.param} --python_proxyaddress=localhost:${docker.http-cache.port.host} + + bridge + @@ -1015,7 +1041,7 @@ org.jacoco jacoco-maven-plugin - 0.8.2 + 0.8.5 true true @@ -1127,6 +1153,15 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 13 + 13 + + diff --git a/src/main/docker/backend/Dockerfile b/src/main/docker/backend/Dockerfile index 9e5c8d8b1..625d5a9b9 100644 --- a/src/main/docker/backend/Dockerfile +++ b/src/main/docker/backend/Dockerfile @@ -21,7 +21,7 @@ # ### -FROM openjdk:8u191-jdk-alpine3.9 +FROM openjdk:13-alpine3.10 MAINTAINER "The Onap Team" LABEL Description="This immage contains alpine, openjdk 11 and clamp" diff --git a/src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java b/src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java deleted file mode 100644 index 0b64b78ea..000000000 --- a/src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 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.clamp.clds.exception.policy; - -public class PolicyModelException extends Exception { - - public PolicyModelException(String msg, Throwable throwable) { - super(msg, throwable); - } -} diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java index 20e13bc7c..3e684f425 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java @@ -33,7 +33,6 @@ import java.util.concurrent.ThreadLocalRandom; import org.onap.clamp.clds.config.ClampProperties; import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfiguration; -import org.onap.clamp.clds.exception.policy.PolicyModelException; import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; import org.onap.clamp.clds.exception.sdc.controller.SdcControllerException; @@ -160,8 +159,7 @@ public class SdcSingleController { * @param distributionClient the distribution client */ public SdcSingleController(ClampProperties clampProp, CsarInstaller csarInstaller, - SdcSingleControllerConfiguration sdcSingleConfig, - IDistributionClient distributionClient) { + SdcSingleControllerConfiguration sdcSingleConfig, IDistributionClient distributionClient) { this.distributionClient = distributionClient; isSdcClientAutoManaged = (distributionClient == null); this.sdcConfig = sdcSingleConfig; @@ -172,8 +170,9 @@ public class SdcSingleController { /** * This method initializes the SDC Controller and the SDC Client. * - * @throws SdcControllerException It throws an exception if the SDC Client cannot be instantiated or if - * an init attempt is done when already initialized + * @throws SdcControllerException It throws an exception if the SDC Client + * cannot be instantiated or if an init attempt + * is done when already initialized */ public void initSdc() throws SdcControllerException { logger.info("Attempt to initialize the SDC Controller: " + sdcConfig.getSdcControllerName()); @@ -183,14 +182,12 @@ public class SdcSingleController { if (distributionClient == null) { distributionClient = DistributionClientFactory.createDistributionClient(); } - IDistributionClientResult result = distributionClient.init(sdcConfig, - new SdcNotificationCallBack(this)); + IDistributionClientResult result = distributionClient.init(sdcConfig, new SdcNotificationCallBack(this)); if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { logger.error("SDC distribution client init failed with reason:" + result.getDistributionMessageResult()); this.changeControllerStatus(SdcSingleControllerStatus.STOPPED); - throw new SdcControllerException( - "Initialization of the SDC Controller failed with reason: " - + result.getDistributionMessageResult()); + throw new SdcControllerException("Initialization of the SDC Controller failed with reason: " + + result.getDistributionMessageResult()); } logger.info("SDC Controller successfully initialized: " + sdcConfig.getSdcControllerName()); logger.info("Attempt to start the SDC Controller: " + sdcConfig.getSdcControllerName()); @@ -206,11 +203,12 @@ public class SdcSingleController { } /** - * This method closes the SDC Controller and the SDC Client. - * - * @throws SdcControllerException It throws an exception if the SDC Client cannot be closed because - * it's currently BUSY in processing notifications. - */ + * This method closes the SDC Controller and the SDC Client. + * + * @throws SdcControllerException It throws an exception if the SDC Client + * cannot be closed because it's currently BUSY + * in processing notifications. + */ public void closeSdc() throws SdcControllerException { if (this.getControllerStatus() == SdcSingleControllerStatus.BUSY) { throw new SdcControllerException("Cannot close the SDC controller as it's currently in BUSY state"); @@ -229,8 +227,7 @@ public class SdcSingleController { } private void sendAllNotificationForCsarHandler(INotificationData notificationData, CsarHandler csar, - NotificationType notificationType, - DistributionStatusEnum distributionStatus, String errorMessage) { + NotificationType notificationType, DistributionStatusEnum distributionStatus, String errorMessage) { if (csar != null) { // Notify for the CSAR this.sendSdcNotification(notificationType, csar.getArtifactElement().getArtifactURL(), @@ -244,13 +241,11 @@ public class SdcSingleController { this.sendSdcNotification(notificationType, blueprint.getValue().getResourceAttached().getArtifacts().get(0).getArtifactURL(), sdcConfig.getConsumerID(), notificationData.getDistributionID(), distributionStatus, - errorMessage, - System.currentTimeMillis()); + errorMessage, System.currentTimeMillis()); } } else { this.sendSdcNotification(notificationType, null, sdcConfig.getConsumerID(), - notificationData.getDistributionID(), - distributionStatus, errorMessage, System.currentTimeMillis()); + notificationData.getDistributionID(), distributionStatus, errorMessage, System.currentTimeMillis()); } } @@ -290,10 +285,6 @@ public class SdcSingleController { logger.error("SdcDownloadException exception caught during the notification processing", e); sendAllNotificationForCsarHandler(notificationData, csar, NotificationType.DOWNLOAD, DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage()); - } catch (PolicyModelException e) { - logger.error("PolicyModelException exception caught during the notification processing", e); - sendAllNotificationForCsarHandler(notificationData, csar, NotificationType.DEPLOY, - DistributionStatusEnum.DEPLOY_ERROR, e.getMessage()); } catch (InterruptedException e) { logger.error("Interrupt exception caught during the notification processing", e); sendAllNotificationForCsarHandler(notificationData, csar, NotificationType.DEPLOY, @@ -303,7 +294,7 @@ public class SdcSingleController { logger.error("Unexpected exception caught during the notification processing", e); sendAllNotificationForCsarHandler(notificationData, csar, NotificationType.DEPLOY, DistributionStatusEnum.DEPLOY_ERROR, e.getMessage()); - } finally { + } finally { this.changeControllerStatus(SdcSingleControllerStatus.IDLE); } } @@ -320,9 +311,8 @@ public class SdcSingleController { } private IDistributionClientDownloadResult downloadTheArtifact(IArtifactInfo artifact) throws SdcDownloadException { - logger.info( - "Trying to download the artifact : " + artifact.getArtifactURL() + " UUID: " - + artifact.getArtifactUUID()); + logger.info("Trying to download the artifact : " + artifact.getArtifactURL() + " UUID: " + + artifact.getArtifactUUID()); IDistributionClientDownloadResult downloadResult; try { downloadResult = distributionClient.download(artifact); @@ -337,19 +327,16 @@ public class SdcSingleController { logger.info("Successfully downloaded the artifact " + artifact.getArtifactURL() + " UUID " + artifact.getArtifactUUID() + "Size of payload " + downloadResult.getArtifactPayload().length); } else { - throw new SdcDownloadException( - "Artifact " + artifact.getArtifactName() + " could not be downloaded from SDC URL " - + artifact.getArtifactURL() + " UUID " + artifact.getArtifactUUID() + ")" - + System.lineSeparator() - + "Error message is " + downloadResult.getDistributionMessageResult() - + System.lineSeparator()); + throw new SdcDownloadException("Artifact " + artifact.getArtifactName() + + " could not be downloaded from SDC URL " + artifact.getArtifactURL() + " UUID " + + artifact.getArtifactUUID() + ")" + System.lineSeparator() + "Error message is " + + downloadResult.getDistributionMessageResult() + System.lineSeparator()); } return downloadResult; } private void sendSdcNotification(NotificationType notificationType, String artifactUrl, String consumerId, - String distributionId, DistributionStatusEnum status, String errorReason, - long timestamp) { + String distributionId, DistributionStatusEnum status, String errorReason, long timestamp) { String event = "Sending " + notificationType.name() + "(" + status.name() + ")" + " notification to SDC for artifact:" + artifactUrl; if (errorReason != null) { diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java index a1f8897fb..10e2790f6 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java @@ -23,7 +23,6 @@ package org.onap.clamp.clds.sdc.controller.installer; -import org.onap.clamp.clds.exception.policy.PolicyModelException; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; public interface CsarInstaller { @@ -31,6 +30,5 @@ public interface CsarInstaller { boolean isCsarAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException; - public void installTheCsar(CsarHandler csar) - throws SdcArtifactInstallerException, InterruptedException, PolicyModelException; + public void installTheCsar(CsarHandler csar) throws SdcArtifactInstallerException, InterruptedException; } diff --git a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java index 41d34a224..b8bc1f524 100644 --- a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java +++ b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java @@ -36,7 +36,6 @@ import java.util.Map.Entry; import org.json.simple.parser.ParseException; import org.onap.clamp.clds.client.DcaeInventoryServices; -import org.onap.clamp.clds.exception.policy.PolicyModelException; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse; import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact; @@ -109,8 +108,7 @@ public class LoopCsarInstaller implements CsarInstaller { @Override @Transactional(propagation = Propagation.REQUIRED) - public void installTheCsar(CsarHandler csar) - throws SdcArtifactInstallerException, InterruptedException, PolicyModelException { + public void installTheCsar(CsarHandler csar) throws SdcArtifactInstallerException, InterruptedException { try { logger.info("Installing the CSAR " + csar.getFilePath()); for (Entry blueprint : csar.getMapOfBlueprints().entrySet()) { diff --git a/src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java b/src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java index ab4421fca..49f173644 100644 --- a/src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java @@ -35,16 +35,13 @@ import org.apache.camel.Exchange; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; import org.mockito.Mockito; -import org.mockito.Spy; import org.onap.clamp.authorization.AuthorizationController; -import org.onap.clamp.clds.config.ClampProperties; import org.onap.clamp.clds.exception.NotAuthorizedException; import org.onap.clamp.clds.service.SecureServicePermission; import org.onap.clamp.util.PrincipalUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.mock.env.MockEnvironment; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContext; @@ -61,14 +58,10 @@ public class AuthorizationControllerItCase { private PermissionTestDefaultHelper permissionTestHelper = new PermissionTestDefaultHelper(); - @Spy - MockEnvironment env; + // @Spy + // MockEnvironment env; - @Spy - @InjectMocks - private ClampProperties clampProp = new ClampProperties(); - - @InjectMocks + @Autowired private AuthorizationController auth; /** @@ -76,34 +69,30 @@ public class AuthorizationControllerItCase { */ @Before public void setupBefore() { - permissionTestHelper.setupMockEnv(env); + // permissionTestHelper.setupMockEnv(env); List authList = permissionTestHelper.getAuthList(); SecurityContext securityContext = Mockito.mock(SecurityContext.class); - Mockito.when(securityContext.getAuthentication()).thenReturn( - new UsernamePasswordAuthenticationToken(new User("admin", "", authList), - "", authList) - ); + Mockito.when(securityContext.getAuthentication()) + .thenReturn(new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList)); PrincipalUtils.setSecurityContext(securityContext); } @Test public void testIsUserPermitted() { - assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl","dev","read"))); - assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl-manage","dev","DEPLOY"))); - assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-filter-vf","dev", - "12345-55555-55555-5555"))); - assertFalse(auth.isUserPermitted(new SecureServicePermission("permission-type-cl","test","read"))); + assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl", "dev", "read"))); + assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl-manage", "dev", "DEPLOY"))); + assertTrue(auth.isUserPermitted( + new SecureServicePermission("permission-type-filter-vf", "dev", "12345-55555-55555-5555"))); + assertFalse(auth.isUserPermitted(new SecureServicePermission("permission-type-cl", "test", "read"))); } @Test public void testIfUserAuthorize() { Exchange ex = Mockito.mock(Exchange.class); try { - permissionTestHelper.doActionOnAllPermissions(((type, instance, action) -> - auth.authorize(ex, type, instance, action) - ) - ); + permissionTestHelper + .doActionOnAllPermissions(((type, instance, action) -> auth.authorize(ex, type, instance, action))); } catch (NotAuthorizedException e) { fail(e.getMessage()); } @@ -112,6 +101,6 @@ public class AuthorizationControllerItCase { @Test(expected = NotAuthorizedException.class) public void testIfAuthorizeThrowException() { Exchange ex = Mockito.mock(Exchange.class); - auth.authorize(ex,"permission-type-cl","test","read"); + auth.authorize(ex, "cl", "test", "read"); } } diff --git a/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java index 1e6742c98..1453d0baa 100644 --- a/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java +++ b/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java @@ -28,7 +28,7 @@ package org.onap.clamp.clds.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import java.security.InvalidKeyException; @@ -45,13 +45,13 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PowerMockIgnore({"javax.crypto.*"}) +@PowerMockIgnore({ "javax.crypto.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*" }) public class CryptoUtilsTest { private final String data = "This is a test string"; @Test - @PrepareForTest({CryptoUtils.class}) + @PrepareForTest({ CryptoUtils.class }) public final void testEncryption() throws Exception { String encodedString = CryptoUtils.encrypt(data); assertNotNull(encodedString); @@ -59,7 +59,7 @@ public class CryptoUtilsTest { } @Test - @PrepareForTest({CryptoUtils.class}) + @PrepareForTest({ CryptoUtils.class }) public final void testEncryptedStringIsDifferent() throws Exception { String encodedString1 = CryptoUtils.encrypt(data); String encodedString2 = CryptoUtils.encrypt(data); @@ -74,7 +74,7 @@ public class CryptoUtilsTest { } @Test - @PrepareForTest({CryptoUtils.class}) + @PrepareForTest({ CryptoUtils.class }) public final void testEncryptionBaseOnRandomKey() throws Exception { SecretKey secretKey = KeyGenerator.getInstance("AES").generateKey(); final String encryptionKey = String.valueOf(Hex.encodeHex(secretKey.getEncoded())); @@ -86,7 +86,7 @@ public class CryptoUtilsTest { } @Test(expected = InvalidKeyException.class) - @PrepareForTest({CryptoUtils.class}) + @PrepareForTest({ CryptoUtils.class }) public final void testEncryptionBadKey() throws Exception { final String badEncryptionKey = "93210sd"; setAesEncryptionKeyEnv(badEncryptionKey); diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java index 63a1fa3e7..13f8e3ad6 100644 --- a/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java +++ b/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java @@ -23,11 +23,13 @@ package org.onap.clamp.clds.util.drawing; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import java.io.IOException; + import javax.xml.parsers.ParserConfigurationException; + import org.apache.batik.svggen.SVGGraphics2D; import org.apache.batik.util.SVGConstants; import org.junit.Assert; @@ -57,15 +59,15 @@ public class DocumentBuilderTest { Node newNode = document.createElement(newNodeTag); newNode.appendChild(document.createTextNode(newNodeText)); - when(mockG2d.getRoot(any(Element.class))).then(a -> a.getArgumentAt(0, Element.class).appendChild(newNode)); + when(mockG2d.getRoot(any(Element.class))).then(a -> a.getArgument(0, Element.class).appendChild(newNode)); DocumentBuilder db = new DocumentBuilder(document, document); db.pushChangestoDocument(mockG2d, dataElementId); Document actualDocument = db.getGroupingDocument(); Node addedActualNode = actualDocument.getDocumentElement().getLastChild(); - String actualDataElementId = - addedActualNode.getAttributes().getNamedItem(DocumentBuilder.DATA_ELEMENT_ID_ATTRIBUTE).getTextContent(); + String actualDataElementId = addedActualNode.getAttributes() + .getNamedItem(DocumentBuilder.DATA_ELEMENT_ID_ATTRIBUTE).getTextContent(); Assert.assertEquals(dataElementId, actualDataElementId); Assert.assertEquals(SVGConstants.SVG_G_TAG, addedActualNode.getNodeName()); diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index 773332ddd..fbf1f2079 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -44,7 +44,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.onap.clamp.clds.Application; -import org.onap.clamp.clds.exception.policy.PolicyModelException; import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact; @@ -88,13 +87,13 @@ public class CsarInstallerItCase { private CsarInstaller csarInstaller; private BlueprintArtifact buildFakeBuildprintArtifact(String instanceName, String invariantResourceUuid, - String blueprintFilePath, String artifactName, String invariantServiceUuid) throws IOException { + String blueprintFilePath, String artifactName, String invariantServiceUuid) throws IOException { IResourceInstance resource = Mockito.mock(IResourceInstance.class); Mockito.when(resource.getResourceInstanceName()).thenReturn(instanceName); Mockito.when(resource.getResourceInvariantUUID()).thenReturn(invariantResourceUuid); BlueprintArtifact blueprintArtifact = Mockito.mock(BlueprintArtifact.class); Mockito.when(blueprintArtifact.getDcaeBlueprint()) - .thenReturn(ResourceFileUtil.getResourceAsString(blueprintFilePath)); + .thenReturn(ResourceFileUtil.getResourceAsString(blueprintFilePath)); Mockito.when(blueprintArtifact.getBlueprintArtifactName()).thenReturn(artifactName); Mockito.when(blueprintArtifact.getBlueprintInvariantServiceUuid()).thenReturn(invariantServiceUuid); Mockito.when(blueprintArtifact.getResourceAttached()).thenReturn(resource); @@ -113,19 +112,19 @@ public class CsarInstallerItCase { Mockito.when(csarHandler.getMapOfBlueprints()).thenReturn(blueprintMap); // Create fake blueprint artifact 1 on resource1 BlueprintArtifact blueprintArtifact = buildFakeBuildprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, - INVARIANT_RESOURCE1_UUID, "example/sdc/blueprint-dcae/tca.yaml", "tca.yaml", INVARIANT_SERVICE_UUID); + INVARIANT_RESOURCE1_UUID, "example/sdc/blueprint-dcae/tca.yaml", "tca.yaml", INVARIANT_SERVICE_UUID); listResources.add(blueprintArtifact.getResourceAttached()); blueprintMap.put(blueprintArtifact.getBlueprintArtifactName(), blueprintArtifact); // Create fake blueprint artifact 2 on resource2 blueprintArtifact = buildFakeBuildprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE2, INVARIANT_RESOURCE2_UUID, - "example/sdc/blueprint-dcae/tca_2.yaml", "tca_2.yaml", INVARIANT_SERVICE_UUID); + "example/sdc/blueprint-dcae/tca_2.yaml", "tca_2.yaml", INVARIANT_SERVICE_UUID); listResources.add(blueprintArtifact.getResourceAttached()); blueprintMap.put(blueprintArtifact.getBlueprintArtifactName(), blueprintArtifact); // Create fake blueprint artifact 3 on resource 1 so that it's possible to // test multiple CL deployment per Service/vnf blueprintArtifact = buildFakeBuildprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, INVARIANT_RESOURCE1_UUID, - "example/sdc/blueprint-dcae/tca_3.yaml", "tca_3.yaml", INVARIANT_SERVICE_UUID); + "example/sdc/blueprint-dcae/tca_3.yaml", "tca_3.yaml", INVARIANT_SERVICE_UUID); blueprintMap.put(blueprintArtifact.getBlueprintArtifactName(), blueprintArtifact); // Build fake csarhandler @@ -146,7 +145,7 @@ public class CsarInstallerItCase { // Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(csarHelper); Mockito.when(csarHandler.getPolicyModelYaml()) - .thenReturn(Optional.ofNullable(ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"))); + .thenReturn(Optional.ofNullable(ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"))); return csarHandler; } @@ -162,16 +161,16 @@ public class CsarInstallerItCase { CsarHandler csarHandler = new CsarHandler(notificationData, "", ""); csarHandler - .setFilePath(Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME).getFile()); + .setFilePath(Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME).getFile()); Optional testyaml = csarHandler.getPolicyModelYaml(); - Assert.assertEquals(testyaml, - Optional.ofNullable(ResourceFileUtil.getResourceAsString("example/sdc/expected-result/policy-data.yaml"))); + Assert.assertEquals(testyaml, Optional + .ofNullable(ResourceFileUtil.getResourceAsString("example/sdc/expected-result/policy-data.yaml"))); } @Test @Transactional public void testIsCsarAlreadyDeployedTca() throws SdcArtifactInstallerException, SdcToscaParserException, - CsarHandlerException, IOException, InterruptedException, PolicyModelException { + CsarHandlerException, IOException, InterruptedException { String generatedName = RandomStringUtils.randomAlphanumeric(5); CsarHandler csarHandler = buildFakeCsarHandler(generatedName); assertThat(csarInstaller.isCsarAlreadyDeployed(csarHandler)).isFalse(); @@ -183,23 +182,22 @@ public class CsarInstallerItCase { @Transactional @Rollback(value = false) public void testInstallTheCsarTca() throws SdcArtifactInstallerException, SdcToscaParserException, - CsarHandlerException, IOException, JSONException, InterruptedException, PolicyModelException { + CsarHandlerException, IOException, JSONException, InterruptedException { String generatedName = RandomStringUtils.randomAlphanumeric(5); CsarHandler csar = buildFakeCsarHandler(generatedName); csarInstaller.installTheCsar(csar); assertThat(loopsRepo - .existsById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca.yaml"))) - .isTrue(); - assertThat(loopsRepo - .existsById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca_3.yaml"))) - .isTrue(); - assertThat(loopsRepo - .existsById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE2, "tca_2.yaml"))) - .isTrue(); + .existsById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca.yaml"))) + .isTrue(); + assertThat(loopsRepo.existsById( + Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca_3.yaml"))).isTrue(); + assertThat(loopsRepo.existsById( + Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE2, "tca_2.yaml"))).isTrue(); // Verify now that policy and json representation, global properties are well // set Loop loop = loopsRepo - .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca.yaml")).get(); + .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca.yaml")) + .get(); assertThat(loop.getSvgRepresentation()).startsWith("