[POLICY-73] replace openecomp for policy-engine
[policy/engine.git] / ONAP-PDP / src / test / java / org / onap / policy / pdp / test / conformance / ConformanceTestResult.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PDP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.pdp.test.conformance;
22
23 import com.att.research.xacml.api.Request;
24 import com.att.research.xacml.api.Response;
25
26 /**
27  * ConformanceTestResult holds all of the objects for a single conformance test run.
28  * 
29  * @version $Revision: 1.1 $
30  */
31 public class ConformanceTestResult {
32         private ConformanceTest         conformanceTest;
33         private Request                         request;
34         private Response                        expectedResponse;
35         private Response                        actualResponse;
36         private ResponseMatchResult     responseMatchResult;
37         private Exception                       error;
38         
39         // performance timings
40         private long                    firstCallTime;
41         private long                    averageTotalLoopTime;
42         
43         // how many non-first-call times the decide() was called
44         private int iterations;
45         
46         public ConformanceTestResult(ConformanceTest conformanceTestIn, int iterations) {
47                 this.conformanceTest    = conformanceTestIn;
48                 this.iterations = iterations;
49         }
50         
51         public ConformanceTestResult(ConformanceTest conformanceTestIn, Exception errorIn) {
52                 this.conformanceTest    = conformanceTestIn;
53                 this.error                              = errorIn;
54         }
55         
56         public int getIterations() {
57                 return this.iterations;
58         }
59
60         public ConformanceTest getConformanceTest() {
61                 return this.conformanceTest;
62         }
63         public void setConformanceTest(ConformanceTest conformanceTestIn) {
64                 this.conformanceTest    = conformanceTestIn;
65         }
66         
67         public Request getRequest() {
68                 return this.request;
69         }
70         public void setRequest(Request requestIn) {
71                 this.request    = requestIn;
72         }
73         
74         public Response getExpectedResponse() {
75                 return this.expectedResponse;
76         }
77         public void setExpectedResponse(Response response) {
78                 this.expectedResponse           = response;
79                 this.responseMatchResult        = null;
80         }
81         
82         public Response getActualResponse() {
83                 return this.actualResponse;
84         }
85         public void setActualResponse(Response response) {
86                 this.actualResponse             = response;
87                 this.responseMatchResult        = null;
88         }
89         
90         public ResponseMatchResult getResponseMatchResult() {
91                 if (this.responseMatchResult == null && (this.actualResponse != null && this.expectedResponse != null)) {
92                         this.computeResponseMatchResult();
93                 }
94                 return this.responseMatchResult;
95         }
96         public void computeResponseMatchResult() {
97                 if (this.expectedResponse != null && this.actualResponse != null) {
98                         this.responseMatchResult        = ResponseMatchResult.newInstance(this.expectedResponse, this.actualResponse);
99                 }
100         }
101         public Exception getError() {
102                 return this.error;
103         }
104         public void setError(Exception ex) {
105                 this.error      = ex;
106         }
107         
108         public long getFirstCallTime() {
109                 return firstCallTime;
110         }
111         public void setFirstCallTime(long t) {
112                 firstCallTime = t;
113         }
114         public long getAverageTotalLoopTime(){
115                 return averageTotalLoopTime;
116         }
117         public void setAverageTotalLoopTime(long t) {
118                 averageTotalLoopTime = t;
119         }
120         
121
122 }