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