diff options
Diffstat (limited to 'controlloop/common/guard/src/test')
-rw-r--r-- | controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java | 3 | ||||
-rw-r--r-- | controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java | 18 |
2 files changed, 14 insertions, 7 deletions
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java index e728d4168..8c7392e71 100644 --- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java +++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java @@ -113,6 +113,9 @@ public class PIPEngineGetHistoryTest { emf.close(); } + /** + * Setup method. + */ @Before public void setUp() { // clear the table diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java index dd1ede49c..9cee0af27 100644 --- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java +++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; + import java.util.UUID; import org.junit.AfterClass; import org.junit.Before; @@ -105,6 +106,9 @@ public class PolicyGuardTest { PolicyGuard.setFactory(saveFactory); } + /** + * Setup method. + */ @Before public void setUp() { mgr = spy(new PolicyResourceLockManager() { @@ -282,14 +286,14 @@ public class PolicyGuardTest { // acquired result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid, dlcb, LOCK_SEC); - verify(mgr).lock(INSTANCENAME, type+":"+uuid, LOCK_SEC); + verify(mgr).lock(INSTANCENAME, type + ":" + uuid, LOCK_SEC); assertEquals(GuardResult.LOCK_ACQUIRED, result.getA()); assertEquals(VMTargetLock.class, result.getB().getClass()); // diff owner - denied UUID uuid2 = UUID.randomUUID(); - result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid2, dlcb, LOCK_SEC+10); - verify(mgr).lock(INSTANCENAME, type+":"+uuid2, LOCK_SEC+10); + result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid2, dlcb, LOCK_SEC + 10); + verify(mgr).lock(INSTANCENAME, type + ":" + uuid2, LOCK_SEC + 10); assertEquals(GuardResult.LOCK_DENIED, result.getA()); assertNull(result.getB()); } @@ -302,21 +306,21 @@ public class PolicyGuardTest { // acquired result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid, dlcb, LOCK_SEC); - verify(mgr).lock(INSTANCENAME, type+":"+uuid, LOCK_SEC); + verify(mgr).lock(INSTANCENAME, type + ":" + uuid, LOCK_SEC); assertEquals(GuardResult.LOCK_ACQUIRED, result.getA()); assertEquals(VMTargetLock.class, result.getB().getClass()); TargetLock lock = result.getB(); // refresh - re-acquired - assertEquals(GuardResult.LOCK_ACQUIRED, PolicyGuard.lockTarget(lock, LOCK_SEC+1)); - verify(mgr).refresh(INSTANCENAME, type+":"+uuid, LOCK_SEC+1); + assertEquals(GuardResult.LOCK_ACQUIRED, PolicyGuard.lockTarget(lock, LOCK_SEC + 1)); + verify(mgr).refresh(INSTANCENAME, type + ":" + uuid, LOCK_SEC + 1); // unlock PolicyGuard.unlockTarget(lock); // refresh - denied, as we no longer own the lock - assertEquals(GuardResult.LOCK_DENIED, PolicyGuard.lockTarget(lock, LOCK_SEC+2)); + assertEquals(GuardResult.LOCK_DENIED, PolicyGuard.lockTarget(lock, LOCK_SEC + 2)); } @Test(expected = IllegalArgumentException.class) |