diff options
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java | 11 | ||||
-rw-r--r-- | common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java | 28 |
2 files changed, 27 insertions, 12 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 6ece8a2620..1bd7720e55 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 @@ -26,8 +26,7 @@ import java.util.List; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Pserver; import org.springframework.beans.factory.annotation.Autowired; - - +import org.springframework.stereotype.Component; public class AAIValidatorImpl implements AAIValidator { @@ -50,10 +49,12 @@ public class AAIValidatorImpl implements AAIValidator { List<Pserver> pservers; boolean isLocked = false; pservers = client.getPhysicalServerByVnfId(vnfId); - for (Pserver pserver : pservers) - if (pserver.isInMaint()) + 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 f32633122d..85d690feaf 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 @@ -49,11 +49,25 @@ public class AAIValidatorTest { validator.setClient(client); } - public List<Pserver> getPservers(boolean locked){ - Pserver pserver = new Pserver(); - pserver.setInMaint(locked); + public List<Pserver> getPserversLocked(){ + Pserver pserver1 = new Pserver(); + pserver1.setInMaint(true); + Pserver pserver2 = new Pserver(); + pserver2.setInMaint(false); List<Pserver> pservers = new ArrayList<Pserver>(); - pservers.add(pserver); + pservers.add(pserver1); + pservers.add(pserver2); + return pservers; + } + + public List<Pserver> getPserversNotLocked(){ + Pserver pserver1 = new Pserver(); + pserver1.setInMaint(false); + Pserver pserver2 = new Pserver(); + pserver2.setInMaint(false); + List<Pserver> pservers = new ArrayList<Pserver>(); + pservers.add(pserver1); + pservers.add(pserver2); return pservers; } @@ -64,15 +78,15 @@ public class AAIValidatorTest { } @Test - public void test_IsPhysicalServerLocked_True() throws IOException{ - when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPservers(true)); + public void test_IsPhysicalServerLocked_True() throws IOException{ + when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPserversLocked()); boolean locked = validator.isPhysicalServerLocked(vnfName); assertEquals(true, locked); } @Test public void test_IsPhysicalServerLocked_False() throws IOException { - when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPservers(false)); + when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPserversNotLocked()); boolean locked = validator.isPhysicalServerLocked(vnfName); assertEquals(false, locked); } |