aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
authorMateusz Gołuchowski <mateusz.goluchowski@nokia.com>2020-06-01 13:59:14 +0200
committerMateusz Gołuchowski <mateusz.goluchowski@nokia.com>2020-06-01 14:21:45 +0200
commitabe242987a35b162e2386b910c3f0cef6e3fef33 (patch)
tree77adc3c41221289c8eac84752d101629f9b337da /adapters
parentfef8fc7996990a2bf1e25c10c4e4d41412e2802d (diff)
Sonar fixes
Changed input parameter for didCreateAuditFail. Now clients must pass object without Optional wrapper. Issue-ID: SO-1841 Change-Id: I96f7793e7e4d7871908f8dbbc1e4cd3a028498d5 Signed-off-by: Mateusz Goluchowski <mateusz.goluchowski@nokia.com>
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java11
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java13
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java4
4 files changed, 14 insertions, 16 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java
index 96a0ddc328..8cdd37d43f 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java
@@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-import java.util.Optional;
@Component
public abstract class AbstractAuditService extends ExternalTaskUtils {
@@ -53,13 +52,13 @@ public abstract class AbstractAuditService extends ExternalTaskUtils {
* @param auditList
* @return
*/
- protected boolean didCreateAuditFail(Optional<AAIObjectAuditList> auditList) {
- if (auditList.isPresent() && isAuditListNotNullAndNotEmpty(auditList.get())) {
+ protected boolean didCreateAuditFail(AAIObjectAuditList auditList) {
+ if (isAuditListNotNullAndNotEmpty(auditList)) {
if (logger.isInfoEnabled()) {
- logger.info("Audit Results: {}", auditList.get().toString());
+ logger.info("Audit Results: {}", auditList.toString());
}
- return auditList.get().getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist())
- .findFirst().map(v -> true).orElse(false);
+ return auditList.getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist()).findFirst()
+ .map(v -> true).orElse(false);
} else {
return false;
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
index 010475c87a..c06460c386 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
@@ -67,7 +67,7 @@ public class AuditCreateStackService extends AbstractAuditService {
auditListOpt.get().setHeatStackName(auditInventory.getHeatStackName());
GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
variables.put("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditListOpt.get()));
- success = !didCreateAuditFail(auditListOpt);
+ success = !didCreateAuditFail(auditListOpt.get());
}
} catch (Exception e) {
logger.error("Error during audit of stack", e);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java
index a93897f83e..c70e60e9d3 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java
@@ -3,35 +3,34 @@ package org.onap.so.adapters.tasks.audit;
import org.junit.Test;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
-import java.util.Optional;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class AbstractAuditServiceTest extends AbstractAuditService {
- private AAIObjectAuditList getAuditListWithObjectWithExistenceStateOf(boolean existState) {
+ private AAIObjectAuditList getAuditListWithObjectWithExistenceStateOf(boolean existenceState) {
AAIObjectAudit auditObject = new AAIObjectAudit();
AAIObjectAuditList auditList = new AAIObjectAuditList();
- auditObject.setDoesObjectExist(existState);
+ auditObject.setDoesObjectExist(existenceState);
auditList.getAuditList().add(auditObject);
return auditList;
}
@Test
- public void didCreateAuditFail_shouldReturnFalse_whenGivenEmptyAudit() {
- assertFalse(didCreateAuditFail(Optional.empty()));
+ public void didCreateAuditFail_shouldReturnFalse_whenGivenNull() {
+ assertFalse(didCreateAuditFail(null));
}
@Test
public void didCreateAuditFail_shouldReturnTrue_whenGivenNotExistingObject() {
- assertTrue(didCreateAuditFail(Optional.of(getAuditListWithObjectWithExistenceStateOf(false))));
+ assertTrue(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(false)));
}
@Test
public void didCreateAuditFail_shouldReturnFalse_whenGivenExistingObject() {
- assertFalse(didCreateAuditFail(Optional.of(getAuditListWithObjectWithExistenceStateOf(true))));
+ assertFalse(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(true)));
}
@Test
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java
index a10ab4b7df..78dbcd94c2 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java
@@ -179,13 +179,13 @@ public class AuditStackServiceDataTest extends AuditCreateStackService {
@Test
public void determineAuditResult_Test() throws Exception {
- boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess);
+ boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess.get());
assertEquals(false, actual);
}
@Test
public void determineAuditResult_Failure_Test() throws Exception {
- boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure);
+ boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure.get());
assertEquals(true, actual);
}
}