Remove checkstyle warnings in policy/engine
[policy/engine.git] / ONAP-PDP / src / test / java / org / onap / policy / xacml / pdp / std / functions / FunctionDefinitionCustomRegexpMatchTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PDP
4  * ================================================================================
5  * Copyright (C) 2018 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.xacml.pdp.std.functions;
22
23 import static org.junit.Assert.assertEquals;
24
25 import com.att.research.xacml.api.Identifier;
26 import com.att.research.xacml.api.XACML;
27 import com.att.research.xacml.std.IdentifierImpl;
28 import com.att.research.xacml.std.StdAttributeValue;
29 import com.att.research.xacml.std.datatypes.DataTypes;
30 import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
31 import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
32 import com.att.research.xacmlatt.pdp.policy.FunctionArgumentAttributeValue;
33
34 import java.util.ArrayList;
35 import java.util.List;
36
37 import org.junit.Test;
38
39 public class FunctionDefinitionCustomRegexpMatchTest {
40     @Test
41     public final void testRegexp() {
42         // Setup
43         final String testVal = "testVal";
44         final String testId = "function:testId";
45         final IdentifierImpl testFnId = new IdentifierImpl(testId);
46         final Identifier identifier = XACML.ID_DATATYPE_STRING;
47         final StdAttributeValue<String> attValue = new StdAttributeValue<String>(identifier, testVal);
48         final FunctionArgument fArg = new FunctionArgumentAttributeValue(attValue);
49         final List<FunctionArgument> listFa = new ArrayList<FunctionArgument>();
50         listFa.add(fArg);
51         listFa.add(fArg);
52
53         // Try a match
54         final FunctionDefinitionCustomRegexpMatch<String> regexpMatch =
55                 new FunctionDefinitionCustomRegexpMatch<String>(testFnId, DataTypes.DT_STRING);
56         final ExpressionResult result = regexpMatch.evaluate(null, listFa);
57         assertEquals(result.getStatus().isOk(), true);
58     }
59 }