summaryrefslogtreecommitdiffstats
path: root/controlloop/common/guard/src
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-08-14 14:22:34 -0400
committerPamela Dragosh <pdragosh@research.att.com>2018-08-14 14:22:41 -0400
commitdbe1d23be5420a5efa4d3977fee974c452bbfd29 (patch)
treecf5ab051e698d9278e6fd28022acbd5c1a9a91a2 /controlloop/common/guard/src
parent6f9976df27dccb2dcaedeb9106166f62a435b050 (diff)
Fix checkstyle issues
Spacing, missing javadoc Issue-ID: POLICY-883 Change-Id: Ice65c6c1baf0bb7c6273411f078bacfe3496b89b Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'controlloop/common/guard/src')
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java20
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java2
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java3
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java18
4 files changed, 27 insertions, 16 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
index e9ff01072..e4fd27415 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
@@ -64,6 +64,8 @@ public class PolicyGuard {
}
/**
+ * Get the factory.
+ *
* @return the factory used to access various objects
*/
protected static Factory getFactory() {
@@ -72,7 +74,7 @@ public class PolicyGuard {
/**
* Sets the factory to be used by junit tests.
- * @param factory
+ * @param factory factory
*/
protected static void setFactory(Factory factory) {
PolicyGuard.factory = factory;
@@ -95,7 +97,7 @@ public class PolicyGuard {
String owner = makeOwner(targetType, requestID);
boolean result = factory.getManager().lock(targetInstance, owner, holdSec);
- if(!result) {
+ if (!result) {
return LockResult.createLockResult(GuardResult.LOCK_DENIED, null);
}
@@ -145,7 +147,7 @@ public class PolicyGuard {
boolean result = factory.getManager().refresh(lock.getTargetInstance(), owner, holdSec);
logger.debug("Lock {} extend {}", lock, result);
- return(result ? GuardResult.LOCK_ACQUIRED : GuardResult.LOCK_DENIED);
+ return (result ? GuardResult.LOCK_ACQUIRED : GuardResult.LOCK_DENIED);
}
/**
@@ -160,7 +162,7 @@ public class PolicyGuard {
String owner = makeOwner(lock.getTargetType(), lock.getRequestID());
boolean result = factory.getManager().unlock(lock.getTargetInstance(), owner);
- if(result) {
+ if (result) {
logger.debug("Unlocked {}", lock);
return true;
}
@@ -184,17 +186,17 @@ public class PolicyGuard {
/**
* Combines the target type and request ID to yield a single, "owner" string.
- * @param targetType
- * @param requestID
+ * @param targetType target type
+ * @param requestID request id
* @return the "owner" of a resource
* @throws IllegalArgumentException if either argument is null
*/
private static String makeOwner(TargetType targetType, UUID requestID) {
- if(targetType == null) {
+ if (targetType == null) {
throw new IllegalArgumentException("null targetType for lock request id " + requestID);
}
- if(requestID == null) {
+ if (requestID == null) {
throw new IllegalArgumentException("null requestID for lock type " + targetType);
}
@@ -207,6 +209,8 @@ public class PolicyGuard {
public static class Factory {
/**
+ * Get the manager.
+ *
* @return the lock manager to be used
*/
public PolicyResourceLockManager getManager() {
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
index 233fc0b49..46a815cdd 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
@@ -135,7 +135,7 @@ public final class Util {
/**
* Sets Guard Properties.
*
- * @see /guard/src/test/java/org/onap/policy/guard/UtilTest.java for setting test properties
+ * <p>see /guard/src/test/java/org/onap/policy/guard/UtilTest.java for setting test properties
*/
public static void setGuardEnvProps(String url, String username, String password, String clientName,
String clientPassword, String environment) {
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)