aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java10
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java7
2 files changed, 13 insertions, 4 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
index 95ed01ee94..96844ff1cb 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
@@ -47,10 +47,12 @@ public class AAIValidatorImpl implements AAIValidator {
List<Pserver> pservers;
boolean isLocked = false;
pservers = client.getPhysicalServerByVnfId(vnfId);
- for (Pserver pserver : pservers) {
- if (pserver.isInMaint()) {
- isLocked = true;
- return isLocked;
+ if (pservers != null) {
+ for (Pserver pserver : pservers) {
+ if (pserver.isInMaint()) {
+ isLocked = true;
+ return isLocked;
+ }
}
}
return isLocked;
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java
index 5fa2ff0295..b91d0e705a 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java
@@ -91,6 +91,13 @@ public class AAIValidatorTest {
}
@Test
+ public void test_IsPhysicalServerLocked_NoServers_False() throws IOException {
+ when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(null);
+ boolean locked = validator.isPhysicalServerLocked(vnfName);
+ assertEquals(false, locked);
+ }
+
+ @Test
public void test_IsVNFLocked_False() {
when(client.getVnfByName(vnfName)).thenReturn(createGenericVnfs(false));
boolean locked = validator.isVNFLocked(vnfName);