Unit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-REST / src / test / java / org / onap / policy / rest / jpa / DecisionDictionaryJpaTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.rest.jpa;
23
24 import static org.junit.Assert.assertTrue;
25
26 import java.util.Date;
27
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.policy.common.logging.flexlogger.FlexLogger;
31 import org.onap.policy.common.logging.flexlogger.Logger;
32
33 /**
34  * The Class DecisionDictionaryJpaTest.
35  */
36 public class DecisionDictionaryJpaTest {
37
38     private static Logger logger = FlexLogger.getLogger(DecisionDictionaryJpaTest.class);
39     private UserInfo userInfo;
40
41     /**
42      * Sets the up.
43      *
44      * @throws Exception the exception
45      */
46     @Before
47     public void setUp() throws Exception {
48         logger.info("setUp: Entering");
49         userInfo = new UserInfo();
50         userInfo.setUserLoginId("Test");
51         userInfo.setUserName("Test");
52         logger.info("setUp: exit");
53     }
54
55     /**
56      * Test decision settings.
57      */
58     @Test
59     public void testDecisionSettings() {
60         DecisionSettings data = new DecisionSettings();
61         data.setId(1);
62         assertTrue(1 == data.getId());
63         data.preUpdate();
64         data.prePersist();
65         data.setDescription("Test");
66         assertTrue("Test".equals(data.getDescription()));
67         data.setXacmlId("Test");
68         assertTrue("Test".equals(data.getXacmlId()));
69         data.setDatatypeBean(new Datatype());
70         assertTrue(data.getDatatypeBean() != null);
71         data.setIssuer("Test");
72         assertTrue("Test".equals(data.getIssuer()));
73         data.setMustBePresent(true);
74         assertTrue(data.isMustBePresent());
75         data.setPriority("Test");
76         assertTrue("Test".equals(data.getPriority()));
77         data.setCreatedDate(new Date());
78         assertTrue(data.getCreatedDate() != null);
79         data.setModifiedDate(new Date());
80         assertTrue(data.getModifiedDate() != null);
81         data.setUserCreatedBy(userInfo);
82         assertTrue(data.getUserCreatedBy() != null);
83         data.setUserModifiedBy(userInfo);
84         assertTrue(data.getUserModifiedBy() != null);
85     }
86
87     /**
88      * Test rainy day treatments.
89      */
90     @Test
91     public void testRainyDayTreatments() {
92         RainyDayTreatments data = new RainyDayTreatments();
93         data.setId(1);
94         assertTrue(1 == data.getId());
95         data.setBbid("Test");
96         assertTrue("Test".equals(data.getBbid()));
97         data.setWorkstep("Test");
98         assertTrue("Test".equals(data.getWorkstep()));
99         data.setTreatments("Test");
100         assertTrue("Test".equals(data.getTreatments()));
101     }
102
103 }