Test gson in policy-management
[policy/drools-pdp.git] / policy-management / src / test / java / org / onap / policy / drools / controller / internal / NullDroolsControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2018-2019 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.drools.controller.internal;
22
23 import org.junit.Assert;
24 import org.junit.Test;
25 import org.onap.policy.common.utils.gson.GsonTestUtils;
26 import org.onap.policy.drools.controller.DroolsController;
27
28 public class NullDroolsControllerTest {
29
30     @Test
31     public void start() {
32         DroolsController controller = new NullDroolsController();
33         controller.start();
34         Assert.assertFalse(controller.isAlive());
35         controller.stop();
36         Assert.assertFalse(controller.isAlive());
37         controller.shutdown();
38         Assert.assertFalse(controller.isAlive());
39         controller.halt();
40         Assert.assertFalse(controller.isAlive());
41     }
42
43     @Test
44     public void testSerialize() {
45         new GsonTestUtils().compareGson(new NullDroolsController(), NullDroolsControllerTest.class);
46     }
47
48     @Test
49     public void lock() {
50         DroolsController controller = new NullDroolsController();
51         controller.lock();
52         Assert.assertFalse(controller.isLocked());
53         controller.unlock();
54         Assert.assertFalse(controller.isLocked());
55     }
56
57     @Test
58     public void getGroupId() {
59         Assert.assertEquals(new NullDroolsController().getGroupId(), DroolsController.NO_GROUP_ID);
60     }
61
62     @Test
63     public void getArtifactId() {
64         Assert.assertEquals(new NullDroolsController().getArtifactId(), DroolsController.NO_ARTIFACT_ID);
65     }
66
67     @Test
68     public void getVersion() {
69         Assert.assertEquals(new NullDroolsController().getVersion(), DroolsController.NO_VERSION);
70     }
71
72     @Test
73     public void getSessionNames() {
74         Assert.assertTrue(new NullDroolsController().getSessionNames().isEmpty());
75     }
76
77     @Test
78     public void getCanonicalSessionNames() {
79         Assert.assertTrue(new NullDroolsController().getCanonicalSessionNames().isEmpty());
80     }
81
82     @Test
83     public void offer() {
84         Assert.assertFalse(new NullDroolsController().offer(null, null));
85     }
86
87     @Test(expected = IllegalStateException.class)
88     public void deliver() {
89         new NullDroolsController().deliver(null, null);
90     }
91
92     @Test
93     public void getRecentSourceEvents() {
94         Assert.assertTrue(new NullDroolsController().getRecentSourceEvents().length == 0);
95     }
96
97     @Test
98     public void getRecentSinkEvents() {
99         Assert.assertTrue(new NullDroolsController().getRecentSinkEvents().length == 0);
100     }
101
102     @Test
103     public void getContainer() {
104         Assert.assertNull(new NullDroolsController().getContainer());
105     }
106
107     @Test
108     public void getDomains() {
109         Assert.assertTrue(new NullDroolsController().getBaseDomainNames().isEmpty());
110     }
111
112     @Test(expected = IllegalStateException.class)
113     public void ownsCoder() {
114         new NullDroolsController().ownsCoder(null, 0);
115     }
116
117     @Test(expected = IllegalArgumentException.class)
118     public void fetchModelClass() {
119         new NullDroolsController().fetchModelClass(this.getClass().getCanonicalName());
120     }
121
122     @Test
123     public void isBrained() {
124         Assert.assertFalse(new NullDroolsController().isBrained());
125     }
126
127     @Test
128     public void stringify() {
129         Assert.assertNotNull(new NullDroolsController().toString());
130     }
131
132     @Test(expected = IllegalArgumentException.class)
133     public void updateToVersion() {
134         new NullDroolsController().updateToVersion(null, null, null, null, null);
135     }
136
137     @Test
138     public void factClassNames() {
139         Assert.assertTrue(new NullDroolsController().factClassNames(null).isEmpty());
140     }
141
142     @Test
143     public void factCount() {
144         Assert.assertTrue(new NullDroolsController().factCount(null) == 0);
145     }
146
147     @Test
148     public void facts() {
149         Assert.assertTrue(new NullDroolsController().facts(null, null, true).isEmpty());
150     }
151
152     @Test
153     public void factQuery() {
154         Assert.assertTrue(new NullDroolsController().factQuery(null, null, null, false).isEmpty());
155     }
156 }