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