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 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;
36 public class PolicyControllerTest {
38 private static Logger logger = FlexLogger.getLogger(PolicyControllerTest.class);
39 private static CommonClassDao commonClassDao;
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 = "";
48 ClassLoader classLoader = getClass().getClassLoader();
49 policyData = IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml"));
50 } catch (Exception e1) {
53 PolicyEntity entity = new PolicyEntity();
54 entity.setPolicyName("Config_SampleTest.1.xml");
55 entity.setPolicyData(policyData);
56 entity.setScope("com");
59 when(commonClassDao.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'")).thenReturn(data);
64 System.out.println("Dummy");