[POLICY-73] replace openecomp for policy-engine
[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 org.apache.commons.io.IOUtils;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.policy.common.logging.flexlogger.FlexLogger;
32 import org.onap.policy.common.logging.flexlogger.Logger;
33 import org.onap.policy.rest.dao.CommonClassDao;
34 import org.onap.policy.rest.jpa.PolicyEntity;
35
36 public class PolicyControllerTest {
37
38         private static Logger logger = FlexLogger.getLogger(PolicyControllerTest.class);
39         private static CommonClassDao commonClassDao;
40         
41         @Before
42         public void setUp() throws Exception{
43                 logger.info("setUp: Entering");
44         commonClassDao = mock(CommonClassDao.class);
45         List<Object> data = new ArrayList<>();
46         String policyData = "";
47         try {
48                         ClassLoader classLoader = getClass().getClassLoader();
49                         policyData = IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml"));
50                 } catch (Exception e1) {
51                         e1.printStackTrace();
52                 }
53         PolicyEntity entity = new PolicyEntity();
54         entity.setPolicyName("Config_SampleTest.1.xml");
55         entity.setPolicyData(policyData);
56         entity.setScope("com");
57         data.add(entity);
58         
59         when(commonClassDao.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'")).thenReturn(data);
60         }
61         
62         @Test
63         public void dummy(){
64                 System.out.println("Dummy");
65         }
66 }