Update css file name in conf.py
[policy/engine.git] / POLICY-SDK-APP / src / test / java / org / onap / policy / daoImp / SystemLogDbDaoImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2019-2020 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.daoImp;
22
23 import static org.junit.Assert.assertNull;
24 import static org.mockito.Mockito.doThrow;
25 import static org.mockito.Mockito.when;
26
27 import java.util.List;
28
29 import org.hibernate.HibernateException;
30 import org.hibernate.Session;
31 import org.hibernate.SessionFactory;
32 import org.hibernate.Transaction;
33 import org.junit.AfterClass;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36 import org.mockito.Mockito;
37 import org.onap.policy.conf.HibernateSession;
38 import org.onap.policy.controller.PolicyController;
39 import org.onap.policy.rest.jpa.SystemLogDb;
40
41 public class SystemLogDbDaoImplTest {
42     private static Session mockSession = Mockito.mock(Session.class);
43     private static SessionFactory sfMock = Mockito.mock(SessionFactory.class);
44     private static Transaction mockTransaction = Mockito.mock(Transaction.class);
45     private SystemLogDbDaoImpl sysLogImpl = new SystemLogDbDaoImpl();
46
47     @SuppressWarnings("unchecked")
48     @BeforeClass
49     public static void setup() {
50         HibernateSession.setSession(sfMock);
51
52         when(sfMock.openSession()).thenReturn(mockSession);
53         when(mockSession.beginTransaction()).thenReturn(mockTransaction);
54
55         doThrow(HibernateException.class).when(mockTransaction).commit();
56         when(mockSession.close()).thenThrow(HibernateException.class);
57
58         PolicyController.setjUnit(true);
59     }
60
61     @Test
62     public void testGettingLoggingData() {
63         List<SystemLogDb> loggingData = sysLogImpl.getLoggingData();
64         assertNull(loggingData);
65     }
66
67     @Test
68     public void testGetSystemAlertData() {
69         List<SystemLogDb> systemAlertData = sysLogImpl.getSystemAlertData();
70         assertNull(systemAlertData);
71     }
72
73     @AfterClass
74     public static void resetjUnit() {
75         PolicyController.setjUnit(false);
76     }
77 }