[POLICY-122] Policy GUI Fixes
[policy/engine.git] / ECOMP-PDP / src / test / java / org / openecomp / policy / pdp / test / conformance / ConformanceTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP-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.openecomp.policy.pdp.test.conformance;
22
23 import java.io.File;
24
25 /**
26  * ConformanceTest represents a collection of XACML files with a root Policy document, optional referenced Policy documents, a Request, and a Response.
27  * 
28  * @version $Revision: 1.2 $
29  */
30 public class ConformanceTest {
31         private String testName;
32         private File request;
33         private File response;
34         private ConformanceRepository repository;
35         
36         public ConformanceTest(String name, ConformanceRepository conformanceRepository, File fileRequest, File fileResponse) {
37                 this.testName   = name;
38                 this.request    = fileRequest;
39                 this.response   = fileResponse;
40                 this.repository = conformanceRepository;
41         }
42         
43         public ConformanceTest(String name) {
44                 this.testName   = name;
45         }
46         
47         public String getTestName() {
48                 return this.testName;
49         }
50         public void setTestName(String s) {
51                 this.testName   = s;
52         }
53         public ConformanceRepository getRepository() {
54                 if (this.repository == null) {
55                         this.repository = new ConformanceRepository();
56                 }
57                 return this.repository;
58         }
59         public File getRequest() {
60                 return this.request;
61         }
62         public void setRequest(File f) {
63                 this.request    = f;
64         }
65         public File getResponse() {
66                 return this.response;
67         }
68         public void setResponse(File f) {
69                 this.response   = f;
70         }
71         
72         public boolean isComplete() {
73                 return this.getTestName() != null && this.getRepository() != null && this.getRepository().hasRootPolicy() && this.getRequest() != null && this.getResponse() != null;
74         }
75         
76         @Override
77         public String toString() {
78                 StringBuilder stringBuilder     = new StringBuilder();
79                 boolean needColon                       = false;
80                 if (this.getTestName() != null) {
81                         stringBuilder.append(this.getTestName());
82                         needColon       = true;
83                 }
84                 if (this.getRepository() != null) {
85                         
86                 }
87                 if (this.getRequest() != null) {
88                         if (needColon) {
89                                 stringBuilder.append(':');
90                         }
91                         stringBuilder.append(this.getRequest().getName());
92                         needColon       = true;
93                 }
94                 if (this.getResponse() != null) {
95                         if (needColon) {
96                                 stringBuilder.append(':');
97                         }
98                         stringBuilder.append(this.getResponse().getName());
99                         needColon       = true;
100                 }
101                 return stringBuilder.toString();
102         }
103
104 }