summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-openstack-adapters/src')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java22
-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/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java10
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java51
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java7
10 files changed, 86 insertions, 18 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 2f7155bffc..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
@@ -21,7 +21,6 @@
package org.onap.so.adapters.tasks.audit;
-import java.util.Optional;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.onap.so.utils.ExternalTaskUtils;
@@ -37,8 +36,6 @@ public abstract class AbstractAuditService extends ExternalTaskUtils {
private static final Logger logger = LoggerFactory.getLogger(AbstractAuditService.class);
-
-
protected static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI =
"Unable to find all VServers and L-Interaces in A&AI";
@@ -52,29 +49,27 @@ public abstract class AbstractAuditService extends ExternalTaskUtils {
}
/**
- * @param auditHeatStackFailed
* @param auditList
* @return
*/
- protected boolean didCreateAuditFail(Optional<AAIObjectAuditList> auditList) {
- if (auditList.get().getAuditList() != null && !auditList.get().getAuditList().isEmpty()) {
+ 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;
}
}
/**
- * @param auditHeatStackFailed
* @param auditList
* @return
*/
protected boolean didDeleteAuditFail(AAIObjectAuditList auditList) {
- if (auditList.getAuditList() != null && !auditList.getAuditList().isEmpty()) {
+ if (isAuditListNotNullAndNotEmpty(auditList)) {
if (logger.isInfoEnabled()) {
logger.info("Audit Results: {}", auditList.toString());
}
@@ -84,4 +79,9 @@ public abstract class AbstractAuditService extends ExternalTaskUtils {
return false;
}
}
+
+ private boolean isAuditListNotNullAndNotEmpty(AAIObjectAuditList auditList) {
+ return auditList != null && auditList.getAuditList() != null && !auditList.getAuditList().isEmpty();
+ }
+
}
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/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
index a00b9f9002..32cd92d70e 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
@@ -59,7 +59,6 @@ import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.Vlan;
import org.onap.aai.domain.yang.Vlans;
import org.onap.aai.domain.yang.Vserver;
-import org.onap.logging.filter.base.ErrorCode;
import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.AAISingleTransactionClient;
@@ -69,6 +68,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.ServerType;
import org.onap.so.heatbridge.constants.HeatBridgeConstants;
@@ -263,7 +263,9 @@ public class HeatBridgeImpl implements HeatBridgeApi {
lIf.setInterfaceId(port.getId());
lIf.setInterfaceName(port.getName());
lIf.setMacaddr(port.getMacAddress());
- lIf.setNetworkName((String) port.getProfile().get("physical_network"));
+ if (port.getProfile() != null && port.getProfile().get("physical_network") != null) {
+ lIf.setNetworkName((String) port.getProfile().get("physical_network"));
+ }
lIf.setIsPortMirrored(false);
lIf.setIsIpUnnumbered(false);
lIf.setInMaint(false);
@@ -338,7 +340,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
private void updateLInterfaceVlan(final Port port, final LInterface lIf) {
Vlan vlan = new Vlan();
Network network = osClient.getNetworkById(port.getNetworkId());
- if (network.getNetworkType().equals(NetworkType.VLAN)) {
+ if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) {
vlan.setVlanInterface(network.getName() + network.getProviderSegID());
vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID()));
@@ -352,7 +354,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
lIf.setVlans(vlans);
}
// Build sriov-vf to the l-interface
- if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
+ if (port.getvNicType() != null && port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
SriovVfs sriovVfs = new SriovVfs();
// JAXB does not generate setters for list, however getter ensures its creation.
// Thus, all list manipulations must be made on live list.
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
new file mode 100644
index 0000000000..c70e60e9d3
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java
@@ -0,0 +1,51 @@
+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 static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class AbstractAuditServiceTest extends AbstractAuditService {
+
+ private AAIObjectAuditList getAuditListWithObjectWithExistenceStateOf(boolean existenceState) {
+ AAIObjectAudit auditObject = new AAIObjectAudit();
+ AAIObjectAuditList auditList = new AAIObjectAuditList();
+
+ auditObject.setDoesObjectExist(existenceState);
+ auditList.getAuditList().add(auditObject);
+
+ return auditList;
+ }
+
+ @Test
+ public void didCreateAuditFail_shouldReturnFalse_whenGivenNull() {
+ assertFalse(didCreateAuditFail(null));
+ }
+
+ @Test
+ public void didCreateAuditFail_shouldReturnTrue_whenGivenNotExistingObject() {
+ assertTrue(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(false)));
+ }
+
+ @Test
+ public void didCreateAuditFail_shouldReturnFalse_whenGivenExistingObject() {
+ assertFalse(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(true)));
+ }
+
+ @Test
+ public void didDeleteAuditFail_shouldReturnFalse_whenGivenNull() {
+ assertFalse(didDeleteAuditFail(null));
+ }
+
+ @Test
+ public void didDeleteAuditFail_shouldReturnTrue_whenGivenExistingObject() {
+ assertTrue(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(true)));
+ }
+
+ @Test
+ public void didDeleteAuditFail_shouldReturnFalse_whenGivenNotExistingObject() {
+ assertFalse(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(false)));
+ }
+
+}
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);
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java
index 6e3312b1d3..106a96a091 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java
@@ -16,6 +16,7 @@
package org.onap.so.adapters.tenant.exceptions;
import org.junit.Test;
+import static org.junit.Assert.*;
public class TenantAlreadyExistsTest {
@@ -23,5 +24,6 @@ public class TenantAlreadyExistsTest {
public void test() {
TenantAlreadyExists tar = new TenantAlreadyExists("name", "cloudId", "tenantId");
assert (tar != null);
+ assertNotNull(tar);
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java
index 7314a9f1e2..ece92b4ac0 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java
@@ -19,6 +19,7 @@ import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
+import static org.junit.Assert.*;
public class TenantExceptionBeanTest {
@@ -38,5 +39,6 @@ public class TenantExceptionBeanTest {
teb.setCategory(MsoExceptionCategory.USERDATA);
assert (teb.getMessage().equals("message"));
assert (teb.getCategory() != null);
+ assertNotNull(teb);
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java
index 83eb1f1bdc..1ce4c664ac 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java
@@ -19,6 +19,7 @@ import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
+import static org.junit.Assert.*;
public class TenantExceptionTest {
@@ -40,5 +41,6 @@ public class TenantExceptionTest {
te.setFaultInfo(teb);
assert (te.getFaultInfo() != null);
assert (te.getFaultInfo().equals(teb));
+ assertNotNull(teb);
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
index 1a308b7c4c..92761c8453 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
@@ -36,6 +36,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.so.entity.MsoRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import static org.junit.Assert.assertNotNull;
public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
@@ -90,6 +91,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
msoRequest.setServiceInstanceId("12345");
instance.deleteVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId",
msoRequest, "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");
+ assertNotNull(msoRequest);
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
index 9fc2aba948..909a558cff 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
@@ -57,6 +57,7 @@ import org.onap.so.openstack.utils.MsoHeatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.stubbing.Scenario;
+import static org.junit.Assert.assertNotNull;
public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@@ -86,6 +87,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
"VFMOD", null, null, "b4ea86b4-253f-11e7-93ae-92361f002671", map, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
new Holder<VnfRollback>());
+ assertNotNull(map);
}
@Test
@@ -101,6 +103,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
"VFMOD", null, null, "b4ea86b4-253f-11e7-93ae-92361f002671", map, null, Boolean.TRUE, Boolean.FALSE,
msoRequest, new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
+ assertNotNull(map);
}
@Test
@@ -132,6 +135,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
"VFMOD", null, null, "b4ea86b4-253f-11e7-93ae-92361f002671", map, Boolean.FALSE, Boolean.TRUE,
Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
new Holder<VnfRollback>());
+ assertNotNull(map);
}
@@ -149,6 +153,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
"VFMOD", null, null, "b4ea86b4-253f-11e7-93ae-92361f002671", map, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
new Holder<VnfRollback>());
+ assertNotNull(map);
}
@@ -479,6 +484,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
"volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId",
"b4ea86b4-253f-11e7-93ae-92361f002671", map, msoRequest, new Holder<Map<String, String>>(),
new Holder<VnfRollback>());
+ assertNotNull(msoRequest);
}
@Test
@@ -499,6 +505,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
} catch (Exception e) {
}
+ assertNotNull(outputs);
}
private VfModuleCustomization getVfModuleCustomization() {