aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Determe <sebastien.determe@intl.att.com>2019-11-07 10:03:38 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-07 10:03:38 +0000
commit77b0be1b734ae1f785fb35a59387ac5fbcf19266 (patch)
treee32d06483563dc4a77581a0da43d321548d6bb3b
parentad6322617d0a3630177de53caf04cec51c44464c (diff)
parent1b6a428451709a3daa98d0f1cdee49d791985c0d (diff)
Merge "Move to JDK 13"
-rw-r--r--pom.xml53
-rw-r--r--src/main/docker/backend/Dockerfile2
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java31
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java61
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java4
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java4
-rw-r--r--src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java41
-rw-r--r--src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java12
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java10
-rw-r--r--src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java56
10 files changed, 125 insertions, 149 deletions
diff --git a/pom.xml b/pom.xml
index f97fa65b..cbb21dcb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,14 +75,12 @@
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<clamp.project.version>${project.version}</clamp.project.version>
<clamp.build.timestamp>${maven.build.timestamp}</clamp.build.timestamp>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<eelf.core.version>1.0.0</eelf.core.version>
<camel.version>2.24.0</camel.version>
- <springboot.version>2.1.5.RELEASE</springboot.version>
+ <springboot.version>2.2.0.RELEASE</springboot.version>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
@@ -105,7 +103,7 @@
<docker.skip.tag>true</docker.skip.tag>
<skip.staging.artifacts>false</skip.staging.artifacts>
<python.http.proxy.param />
- <tomcat.version>9.0.20</tomcat.version>
+ <tomcat.version>9.0.27</tomcat.version>
<ui.react.src>ui-react</ui.react.src>
<npm.publish.url>https://nexus3.onap.org/repository/npm.release/</npm.publish.url>
</properties>
@@ -276,6 +274,16 @@
<groupId>com.att.eelf</groupId>
<artifactId>eelf-core</artifactId>
<version>${eelf.core.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
@@ -515,7 +523,19 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
+ <version>2.28.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <version>2.0.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>2.0.4</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -811,7 +831,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.22.1</version>
+ <version>2.22.2</version>
<configuration>
<forkCount>1C</forkCount>
<reuseForks>true</reuseForks>
@@ -823,7 +843,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>2.22.1</version>
+ <version>2.22.2</version>
<executions>
<execution>
<id>integration-tests</id>
@@ -849,7 +869,7 @@
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
- <version>0.27.2</version>
+ <version>0.31.0</version>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
@@ -885,6 +905,9 @@
<ports>
<port>${docker.mariadb.port.host}:3306</port>
</ports>
+ <network>
+ <mode>bridge</mode>
+ </network>
</run>
</image>
<image>
@@ -915,6 +938,9 @@
<shell>./start_http_cache.sh ${python.http.proxy.param}
--python_proxyaddress=localhost:${docker.http-cache.port.host}</shell>
</cmd>
+ <network>
+ <mode>bridge</mode>
+ </network>
</run>
</image>
<image>
@@ -1031,7 +1057,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
- <version>0.8.2</version>
+ <version>0.8.5</version>
<configuration>
<dumpOnExit>true</dumpOnExit>
<append>true</append>
@@ -1143,6 +1169,15 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ <configuration>
+ <source>13</source>
+ <target>13</target>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/src/main/docker/backend/Dockerfile b/src/main/docker/backend/Dockerfile
index 9e5c8d8b..625d5a9b 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 0b64b78e..00000000
--- 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 20e13bc7..3e684f42 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 a1f8897f..10e2790f 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 41d34a22..b8bc1f52 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<String, BlueprintArtifact> 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 ab4421fc..49f17364 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<GrantedAuthority> 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 1e6742c9..1453d0ba 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 63a1fa3e..13f8e3ad 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 773332dd..fbf1f207 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<String> 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("<svg ");
assertThat(loop.getGlobalPropertiesJson().get("dcaeDeployParameters")).isNotNull();
assertThat(loop.getMicroServicePolicies()).hasSize(1);
@@ -207,27 +205,27 @@ public class CsarInstallerItCase {
assertThat(loop.getModelPropertiesJson().get("serviceDetails")).isNotNull();
assertThat(loop.getModelPropertiesJson().get("resourceDetails")).isNotNull();
JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"),
- JsonUtils.GSON.toJson(loop.getModelPropertiesJson()), true);
+ JsonUtils.GSON.toJson(loop.getModelPropertiesJson()), true);
assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty();
loop = loopsRepo
- .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca_3.yaml"))
- .get();
+ .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca_3.yaml"))
+ .get();
assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty();
loop = loopsRepo
- .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE2, "tca_2.yaml"))
- .get();
+ .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE2, "tca_2.yaml"))
+ .get();
assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty();
}
@Test(expected = SdcArtifactInstallerException.class)
@Transactional
- public void shouldThrowSdcArtifactInstallerException() throws SdcArtifactInstallerException,
- SdcToscaParserException, IOException, InterruptedException, PolicyModelException {
+ public void shouldThrowSdcArtifactInstallerException()
+ throws SdcArtifactInstallerException, SdcToscaParserException, IOException, InterruptedException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csarHandler = buildFakeCsarHandler(generatedName);
- Mockito.when(csarHandler.getMapOfBlueprints()).thenThrow(IOException.class);
+ Mockito.when(csarHandler.getPolicyModelYaml()).thenThrow(IOException.class);
csarInstaller.installTheCsar(csarHandler);
}
}