summaryrefslogtreecommitdiffstats
path: root/controlloop/common/guard/src/test/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-01-14 14:30:46 -0500
committerJim Hahn <jrh3@att.com>2019-01-14 15:12:11 -0500
commit12fab6215a7a92b4959330ef179d38454dbb6225 (patch)
treec4edaa8ecdf3cfc59e15b20b739a481ed67f9ccd /controlloop/common/guard/src/test/java
parentdd691f02e2caa6028a868915b016a71bf6c1c876 (diff)
Remove guard checkstyle suppressions
Renamed a number of fields and methods, in the Guard classes, to conform to camel-case format. Also updated some toString() methods to return "xxxId=" instead of "xxxID=", if the corresponding field names were also xxxId. Updated license data in one changed file. Change-Id: Idac58f8744b5523d6daed7f369026495dd357bf8 Issue-ID: POLICY-1140 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/guard/src/test/java')
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/CallGuardTaskTest.java4
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardRequestTest.java6
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardResponseTest.java8
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java48
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java26
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlRequestAttributesTest.java32
6 files changed, 64 insertions, 60 deletions
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/CallGuardTaskTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/CallGuardTaskTest.java
index b1b057542..9e4c809c2 100644
--- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/CallGuardTaskTest.java
+++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/CallGuardTaskTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* guard
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@ public class CallGuardTaskTest {
// and has same reqID
PolicyGuardResponse response = (PolicyGuardResponse) obj;
// req ID has form 00000001-0002-0003-0004-000000000005
- return status.equals(response.getResult()) && response.getRequestID().toString().matches(REQ_MATCHER);
+ return status.equals(response.getResult()) && response.getRequestId().toString().matches(REQ_MATCHER);
}));
}
}
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardRequestTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardRequestTest.java
index 7c9aae7b4..3b0441fc2 100644
--- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardRequestTest.java
+++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardRequestTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -37,8 +39,8 @@ public class PolicyGuardRequestTest {
PolicyGuardRequest request = new PolicyGuardRequest("Dorothy", "Kansas", requestId, "GetBackHome");
- request.setRequestID(requestId);
- assertEquals(requestId, request.getRequestID());
+ request.setRequestId(requestId);
+ assertEquals(requestId, request.getRequestId());
request.setActor("Dorothy");
assertEquals("Dorothy", request.getActor());
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardResponseTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardResponseTest.java
index f9bd94795..b30ae0210 100644
--- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardResponseTest.java
+++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardResponseTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -37,8 +39,8 @@ public class PolicyGuardResponseTest {
PolicyGuardResponse response = new PolicyGuardResponse("BackHome", requestId, "GetBackHome");
- response.setRequestID(requestId);
- assertEquals(requestId, response.getRequestID());
+ response.setRequestId(requestId);
+ assertEquals(requestId, response.getRequestId());
response.setResult("BackHome");
assertEquals("BackHome", response.getResult());
@@ -46,6 +48,6 @@ public class PolicyGuardResponseTest {
response.setOperation("GetBackHome");
assertEquals("GetBackHome", response.getOperation());
- assertEquals("PolicyGuardResponse [requestID=", response.toString().substring(0, 31));
+ assertEquals("PolicyGuardResponse [requestId=", response.toString().substring(0, 31));
}
}
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 273d8fb01..87303623c 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* guard
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,9 +39,9 @@ import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.drools.core.lock.PolicyResourceLockManager;
import org.onap.policy.guard.PolicyGuard.Factory;
import org.onap.policy.guard.PolicyGuard.LockResult;
-import org.onap.policy.guard.impl.PNFTargetLock;
-import org.onap.policy.guard.impl.VMTargetLock;
-import org.onap.policy.guard.impl.VNFTargetLock;
+import org.onap.policy.guard.impl.PnfTargetLock;
+import org.onap.policy.guard.impl.VmTargetLock;
+import org.onap.policy.guard.impl.VnfTargetLock;
public class PolicyGuardTest {
private static final String INSTANCENAME = "targetInstance";
@@ -76,7 +76,7 @@ public class PolicyGuardTest {
}
@Override
- public UUID getLockID() {
+ public UUID getLockId() {
return null;
}
@@ -91,7 +91,7 @@ public class PolicyGuardTest {
}
@Override
- public UUID getRequestID() {
+ public UUID getRequestId() {
return reqid;
}
}
@@ -137,13 +137,13 @@ public class PolicyGuardTest {
assertTrue(PolicyGuard.isLocked(type, INSTANCENAME, uuid));
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
- assertEquals(VMTargetLock.class, result.getB().getClass());
+ assertEquals(VmTargetLock.class, result.getB().getClass());
- VMTargetLock vtl = (VMTargetLock) result.getB();
- assertNotNull(vtl.getLockID());
+ VmTargetLock vtl = (VmTargetLock) result.getB();
+ assertNotNull(vtl.getLockId());
assertEquals(INSTANCENAME, vtl.getTargetInstance());
assertEquals(TargetType.VM, vtl.getTargetType());
- assertNotNull(vtl.getRequestID());
+ assertNotNull(vtl.getRequestId());
assertEquals(dlcb, vtl.getCallback());
// Test isLocked after lock removed
@@ -161,13 +161,13 @@ public class PolicyGuardTest {
assertTrue(PolicyGuard.isLocked(type, INSTANCENAME, uuid));
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
- assertEquals(PNFTargetLock.class, result.getB().getClass());
+ assertEquals(PnfTargetLock.class, result.getB().getClass());
- PNFTargetLock ptl = (PNFTargetLock) result.getB();
- assertNotNull(ptl.getLockID());
+ PnfTargetLock ptl = (PnfTargetLock) result.getB();
+ assertNotNull(ptl.getLockId());
assertEquals(INSTANCENAME, ptl.getTargetInstance());
assertEquals(TargetType.PNF, ptl.getTargetType());
- assertNotNull(ptl.getRequestID());
+ assertNotNull(ptl.getRequestId());
assertEquals(dlcb, ptl.getCallback());
// Test isLocked after lock removed
@@ -186,13 +186,13 @@ public class PolicyGuardTest {
assertTrue(PolicyGuard.isLocked(type, INSTANCENAME, uuid));
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
- assertEquals(VNFTargetLock.class, result.getB().getClass());
+ assertEquals(VnfTargetLock.class, result.getB().getClass());
- VNFTargetLock vtl = (VNFTargetLock) result.getB();
- assertNotNull(vtl.getLockID());
+ VnfTargetLock vtl = (VnfTargetLock) result.getB();
+ assertNotNull(vtl.getLockId());
assertEquals(INSTANCENAME, vtl.getTargetInstance());
assertEquals(TargetType.VNF, vtl.getTargetType());
- assertNotNull(vtl.getRequestID());
+ assertNotNull(vtl.getRequestId());
assertEquals(dlcb, vtl.getCallback());
// Test isLocked after lock removed
@@ -227,7 +227,7 @@ public class PolicyGuardTest {
assertTrue(PolicyGuard.isLocked(type, INSTANCENAME, uuid));
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
- assertEquals(VMTargetLock.class, result.getB().getClass());
+ assertEquals(VmTargetLock.class, result.getB().getClass());
// Test isLocked after lock removed
PolicyGuard.unlockTarget(new DummyTargetLock(type, uuid));
@@ -248,7 +248,7 @@ public class PolicyGuardTest {
assertTrue(PolicyGuard.isLocked(type, INSTANCENAME, uuid));
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
- assertEquals(VMTargetLock.class, result.getB().getClass());
+ assertEquals(VmTargetLock.class, result.getB().getClass());
UUID uuid2 = UUID.randomUUID();
result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid2, dlcb, LOCK_SEC);
@@ -272,8 +272,8 @@ public class PolicyGuardTest {
assertFalse(dlcb.releaseLock());
DummyTargetLock dtl = new DummyTargetLock(type, uuid);
- assertNull(dtl.getLockID());
- assertEquals(uuid, dtl.getRequestID());
+ assertNull(dtl.getLockId());
+ assertEquals(uuid, dtl.getRequestId());
assertEquals(INSTANCENAME, dtl.getTargetInstance());
assertEquals(type, dtl.getTargetType());
}
@@ -288,7 +288,7 @@ public class PolicyGuardTest {
result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid, dlcb, LOCK_SEC);
verify(mgr).lock(INSTANCENAME, type + ":" + uuid, LOCK_SEC);
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
- assertEquals(VMTargetLock.class, result.getB().getClass());
+ assertEquals(VmTargetLock.class, result.getB().getClass());
// diff owner - denied
UUID uuid2 = UUID.randomUUID();
@@ -308,7 +308,7 @@ public class PolicyGuardTest {
result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid, dlcb, LOCK_SEC);
verify(mgr).lock(INSTANCENAME, type + ":" + uuid, LOCK_SEC);
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
- assertEquals(VMTargetLock.class, result.getB().getClass());
+ assertEquals(VmTargetLock.class, result.getB().getClass());
TargetLock lock = result.getB();
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java
index e69820a3d..8b007fdcc 100644
--- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java
+++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* guard
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,7 +92,7 @@ public class PolicyGuardXacmlHelperTest {
PolicyGuardXacmlRequestAttributes xacmlReq = new PolicyGuardXacmlRequestAttributes(
org.onap.policy.simulators.GuardSimulatorJaxRs.DENY_CLNAME, "actor", "recipe", "target",
"requestId", VF_COUNT);
- String rawDecision = new PolicyGuardXacmlHelper().callPDP(xacmlReq);
+ String rawDecision = new PolicyGuardXacmlHelper().callPdp(xacmlReq);
assertNotNull(rawDecision);
assertEquals(0, Util.INDETERMINATE.compareToIgnoreCase(rawDecision));
}
@@ -101,13 +101,13 @@ public class PolicyGuardXacmlHelperTest {
public void testSimulator() {
PolicyGuardXacmlRequestAttributes request = new PolicyGuardXacmlRequestAttributes("clname_id", "actor_id",
"operation_id", "target_id", "request_id", VF_COUNT);
- String xacmlResponse = new PolicyGuardXacmlHelper().callPDP(request);
+ String xacmlResponse = new PolicyGuardXacmlHelper().callPdp(request);
assertNotNull(xacmlResponse);
}
@Test
/**
- * Tests PolicyGuardXacmlHelper.callPDP method to determine if it returns DENY, PERMIT, or
+ * Tests PolicyGuardXacmlHelper.callPdp method to determine if it returns DENY, PERMIT, or
* INDETERMINATE as expected.
*/
public void testCallPdp() {
@@ -115,13 +115,13 @@ public class PolicyGuardXacmlHelperTest {
PolicyGuardXacmlRequestAttributes xacmlReq = new PolicyGuardXacmlRequestAttributes(
org.onap.policy.simulators.GuardSimulatorJaxRs.DENY_CLNAME, "actor", "recipe", "target",
"requestId", VF_COUNT);
- String rawDecision = new PolicyGuardXacmlHelper().callPDP(xacmlReq);
+ String rawDecision = new PolicyGuardXacmlHelper().callPdp(xacmlReq);
assertNotNull(rawDecision);
assertTrue(0 == Util.DENY.compareToIgnoreCase(rawDecision));
// Permit Case
xacmlReq = new PolicyGuardXacmlRequestAttributes("clname", "actor", "recipe", "target", "requestId", VF_COUNT);
- rawDecision = new PolicyGuardXacmlHelper().callPDP(xacmlReq);
+ rawDecision = new PolicyGuardXacmlHelper().callPdp(xacmlReq);
assertNotNull(rawDecision);
assertEquals(0, Util.PERMIT.compareToIgnoreCase(rawDecision));
@@ -130,21 +130,21 @@ public class PolicyGuardXacmlHelperTest {
@Test
/**
- * Tests PolicyGuardXacmlHelper.callPDP method to exercise all branches
+ * Tests PolicyGuardXacmlHelper.callPdp method to exercise all branches
*/
public void testCallPdpExtra() {
PolicyGuardXacmlRequestAttributes xacmlReq = new PolicyGuardXacmlRequestAttributes(
org.onap.policy.simulators.GuardSimulatorJaxRs.DENY_CLNAME, "actor", "recipe", "target",
"requestId", VF_COUNT);
- xacmlReq.setClnameID(null);
- String rawDecision = new PolicyGuardXacmlHelper().callPDP(xacmlReq);
+ xacmlReq.setClnameId(null);
+ String rawDecision = new PolicyGuardXacmlHelper().callPdp(xacmlReq);
assertNotNull(rawDecision);
assertEquals(-5, Util.DENY.compareToIgnoreCase(rawDecision));
org.onap.policy.guard.Util.setGuardEnvProps("http://localhost:6669/pdp/api/getDecision", "", "", "", "", "");
- rawDecision = new PolicyGuardXacmlHelper().callPDP(xacmlReq);
+ rawDecision = new PolicyGuardXacmlHelper().callPdp(xacmlReq);
assertNotNull(rawDecision);
org.onap.policy.guard.Util.setGuardEnvProps("http://localhost:6669/pdp/api/getDecision", "python", "test",
@@ -154,14 +154,14 @@ public class PolicyGuardXacmlHelperTest {
@Test
public void testParseXacmlPdpResponse() throws URISyntaxException {
- PolicyGuardResponse pgResponse = PolicyGuardXacmlHelper.parseXACMLPDPResponse(null);
+ PolicyGuardResponse pgResponse = PolicyGuardXacmlHelper.parseXacmlPdpResponse(null);
assertEquals("Indeterminate", pgResponse.getResult());
Decision decision = Decision.PERMIT;
Status status = new StdStatus(StdStatus.STATUS_OK);
Result result = new StdResult(decision, status);
Response xacmlResponse = new StdResponse(result);
- pgResponse = PolicyGuardXacmlHelper.parseXACMLPDPResponse(xacmlResponse);
+ pgResponse = PolicyGuardXacmlHelper.parseXacmlPdpResponse(xacmlResponse);
assertEquals("Permit", pgResponse.getResult());
@@ -193,7 +193,7 @@ public class PolicyGuardXacmlHelperTest {
Result fullResult = new StdResult(Decision.DENY, obligationsIn, adviceIn, attributesIn, policyIdentifiersIn,
policySetIdentifiersIn);
Response fullXacmlResponse = new StdResponse(fullResult);
- PolicyGuardResponse fullPgResponse = PolicyGuardXacmlHelper.parseXACMLPDPResponse(fullXacmlResponse);
+ PolicyGuardResponse fullPgResponse = PolicyGuardXacmlHelper.parseXacmlPdpResponse(fullXacmlResponse);
assertEquals("Deny", fullPgResponse.getResult());
}
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlRequestAttributesTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlRequestAttributesTest.java
index 7b5affd32..b4f8c443a 100644
--- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlRequestAttributesTest.java
+++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlRequestAttributesTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* ================================================================================
- * Modifications Copyright (C) 2018 AT&T. All rights reserved.
+ * Modifications Copyright (C) 2018-2019 AT&T. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,30 +38,30 @@ public class PolicyGuardXacmlRequestAttributesTest {
assertNotNull(attributes);
UUID requestId = UUID.randomUUID();
- attributes.setRequestID(requestId.toString());
- assertEquals(requestId.toString(), attributes.getRequestID());
+ attributes.setRequestId(requestId.toString());
+ assertEquals(requestId.toString(), attributes.getRequestId());
UUID operationId = UUID.randomUUID();
- attributes.setOperationID(operationId.toString());
- assertEquals(operationId.toString(), attributes.getOperationID());
+ attributes.setOperationId(operationId.toString());
+ assertEquals(operationId.toString(), attributes.getOperationId());
UUID actorId = UUID.randomUUID();
- attributes.setActorID(actorId.toString());
- assertEquals(actorId.toString(), attributes.getActorID());
+ attributes.setActorId(actorId.toString());
+ assertEquals(actorId.toString(), attributes.getActorId());
UUID targetId = UUID.randomUUID();
- attributes.setTargetID(targetId.toString());
- assertEquals(targetId.toString(), attributes.getTargetID());
+ attributes.setTargetId(targetId.toString());
+ assertEquals(targetId.toString(), attributes.getTargetId());
- attributes.setTargetID(targetId.toString());
- assertEquals(targetId.toString(), attributes.getTargetID());
+ attributes.setTargetId(targetId.toString());
+ assertEquals(targetId.toString(), attributes.getTargetId());
UUID controlLoopId = UUID.randomUUID();
- attributes.setClnameID(controlLoopId.toString());
- assertEquals(controlLoopId.toString(), attributes.getClnameID());
+ attributes.setClnameId(controlLoopId.toString());
+ assertEquals(controlLoopId.toString(), attributes.getClnameId());
- attributes.setClnameID(null);
- assertEquals(null, attributes.getClnameID());
+ attributes.setClnameId(null);
+ assertEquals(null, attributes.getClnameId());
Integer vfCount = 20;
attributes.setVfCount(vfCount);
@@ -70,6 +70,6 @@ public class PolicyGuardXacmlRequestAttributesTest {
attributes.setVfCount(null);
assertEquals(null, attributes.getVfCount());
- assertEquals("PolicyGuardXacmlRequestAttributes [actorID=", attributes.toString().substring(0, 43));
+ assertEquals("PolicyGuardXacmlRequestAttributes [actorId=", attributes.toString().substring(0, 43));
}
}