From 91d04c64771832a0b8815ffbe1f0f9920320d94d Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 14 Feb 2017 19:41:00 -0500 Subject: Initial OpenECOMP policy/engine commit Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e Signed-off-by: Pamela Dragosh --- .../pdp/test/conformance/ResultMatchResult.java | 136 +++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/conformance/ResultMatchResult.java (limited to 'ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/conformance/ResultMatchResult.java') diff --git a/ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/conformance/ResultMatchResult.java b/ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/conformance/ResultMatchResult.java new file mode 100644 index 000000000..3da7e1a83 --- /dev/null +++ b/ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/conformance/ResultMatchResult.java @@ -0,0 +1,136 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-TEST + * ================================================================================ + * Copyright (C) 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.pdp.test.conformance; + +import com.att.research.xacml.api.Result; +import com.att.research.xacml.std.StdStatusCode; +import com.att.research.xacml.util.ListUtil; + +/** + * ResultMatchResult provides information about how well a {@link com.att.research.xacml.api.Result} object matches + * another Result object. + * + * @version $Revision: 1.1 $ + */ +public class ResultMatchResult { + private boolean bAssociatedAdviceMatches = true; + private boolean bAttributesMatch = true; + private boolean bDecisionsMatch = true; + private boolean bObligationsMatch = true; + private boolean bPolicyIdentifiersMatch = true; + private boolean bPolicySetIdentifiersMatch = true; + private boolean bStatusCodesMatch = true; + private boolean bUnknownFunction = false; + + protected void setAssociatedAdviceMatches(boolean b) { + this.bAssociatedAdviceMatches = b; + } + protected void setAttributesMatch(boolean b) { + this.bAttributesMatch = b; + } + protected void setDecisionsMatch(boolean b) { + this.bDecisionsMatch = b; + } + protected void setObligationsMatch(boolean b) { + this.bObligationsMatch = b; + } + protected void setPolicyIdentifiersMatch(boolean b) { + this.bPolicyIdentifiersMatch = b; + } + protected void setPolicySetIdentifiersMatch(boolean b) { + this.bPolicySetIdentifiersMatch = b; + } + protected void setStatusCodesMatch(boolean b) { + this.bStatusCodesMatch = b; + } + protected void setUnknownFunction(boolean b) { + this.bUnknownFunction = b; + } + + public ResultMatchResult() { + } + + public static ResultMatchResult newInstance(Result result1, Result result2) { + ResultMatchResult resultMatchResult = new ResultMatchResult(); + if (result2 != null && result2.getStatus() != null && + result2.getStatus().getStatusCode().equals(StdStatusCode.STATUS_CODE_PROCESSING_ERROR) && + result2.getStatus().getStatusMessage() != null && + result2.getStatus().getStatusMessage().contains("Unknown Function") + ) { + resultMatchResult.setUnknownFunction(true); + } + if (result1 == null || result2 == null) { + resultMatchResult.setAssociatedAdviceMatches(false); + resultMatchResult.setAttributesMatch(false); + resultMatchResult.setDecisionsMatch(false); + resultMatchResult.setObligationsMatch(false); + resultMatchResult.setPolicyIdentifiersMatch(false); + resultMatchResult.setPolicySetIdentifiersMatch(false); + resultMatchResult.setStatusCodesMatch(false); + } else { + resultMatchResult.setAssociatedAdviceMatches(ListUtil.equalsAllowNulls(result1.getAssociatedAdvice(), result2.getAssociatedAdvice())); + resultMatchResult.setAttributesMatch(ListUtil.equalsAllowNulls(result1.getAttributes(), result2.getAttributes())); + resultMatchResult.setDecisionsMatch(result1.getDecision() == result2.getDecision()); + resultMatchResult.setObligationsMatch(ListUtil.equalsAllowNulls(result1.getObligations(), result2.getObligations())); + resultMatchResult.setPolicyIdentifiersMatch(ListUtil.equalsAllowNulls(result1.getPolicyIdentifiers(), result2.getPolicyIdentifiers())); + resultMatchResult.setPolicySetIdentifiersMatch(ListUtil.equalsAllowNulls(result1.getPolicySetIdentifiers(), result2.getPolicySetIdentifiers())); + if (result1.getStatus() == null || result1.getStatus().getStatusCode() == null || result2.getStatus() == null || result2.getStatus().getStatusCode() == null) { + resultMatchResult.setStatusCodesMatch(false); + } else { + resultMatchResult.setStatusCodesMatch(result1.getStatus().getStatusCode().equals(result2.getStatus().getStatusCode())); + } + } + return resultMatchResult; + } + + public boolean associatedAdviceMatches() { + return this.bAssociatedAdviceMatches; + } + + public boolean attributesMatch() { + return this.bAttributesMatch; + } + + public boolean decisionsMatch() { + return this.bDecisionsMatch; + } + + public boolean obligationsMatch() { + return this.bObligationsMatch; + } + + public boolean policyIdentifiersMatch() { + return this.bPolicyIdentifiersMatch; + } + + public boolean policySetIdentifiersMatch() { + return this.bPolicySetIdentifiersMatch; + } + + public boolean statusCodesMatch() { + return this.bStatusCodesMatch; + } + + public boolean unknownFunction() { + return this.bUnknownFunction; + } + +} -- cgit 1.2.3-korg