Merge "Fixes for eclipse warnings unused variables"
[policy/engine.git] / POLICY-SDK-APP / src / test / java / org / onap / policy / controller / PolicyControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
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 package org.onap.policy.controller;
21
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.when;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28 import javax.script.SimpleBindings;
29
30 import org.apache.commons.io.IOUtils;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.onap.policy.common.logging.flexlogger.FlexLogger;
34 import org.onap.policy.common.logging.flexlogger.Logger;
35 import org.onap.policy.rest.dao.CommonClassDao;
36 import org.onap.policy.rest.jpa.PolicyEntity;
37
38 public class PolicyControllerTest {
39
40         private static Logger logger = FlexLogger.getLogger(PolicyControllerTest.class);
41         private static CommonClassDao commonClassDao;
42         
43         @Before
44         public void setUp() throws Exception{
45                 logger.info("setUp: Entering");
46         commonClassDao = mock(CommonClassDao.class);
47         List<Object> data = new ArrayList<>();
48         String policyData = "";
49         try {
50                         ClassLoader classLoader = getClass().getClassLoader();
51                         policyData = IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml"));
52                 } catch (Exception e1) {
53                         e1.printStackTrace();
54                 }
55         PolicyEntity entity = new PolicyEntity();
56         entity.setPolicyName("Config_SampleTest.1.xml");
57         entity.setPolicyData(policyData);
58         entity.setScope("com");
59         data.add(entity);
60         
61         when(commonClassDao.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(data);
62         }
63         
64         @Test
65         public void dummy(){
66                 System.out.println("Dummy");
67         }
68 }