2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.policy.controller;
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.when;
25 import java.util.ArrayList;
26 import java.util.List;
28 import javax.script.SimpleBindings;
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;
38 public class PolicyControllerTest {
40 private static Logger logger = FlexLogger.getLogger(PolicyControllerTest.class);
41 private static CommonClassDao commonClassDao;
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 = "";
50 ClassLoader classLoader = getClass().getClassLoader();
51 policyData = IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml"));
52 } catch (Exception e1) {
55 PolicyEntity entity = new PolicyEntity();
56 entity.setPolicyName("Config_SampleTest.1.xml");
57 entity.setPolicyData(policyData);
58 entity.setScope("com");
61 when(commonClassDao.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(data);
66 System.out.println("Dummy");