2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.openecomp.aai.champ.core;
24 import static org.junit.Assert.assertTrue;
26 import org.junit.Test;
27 import org.openecomp.aai.champ.ChampAPI;
28 import org.openecomp.aai.champ.ChampGraph;
29 import org.openecomp.aai.champ.model.ChampObjectConstraint;
30 import org.openecomp.aai.champ.model.ChampRelationshipConstraint;
32 public class ChampAPITest {
35 public void testChampAPIInstantiation() {
37 for (ChampGraph.Type type : ChampGraph.Type.values()) {
39 final ChampAPI api = ChampAPI.Factory.newInstance(type);
41 assertTrue(type == ChampGraph.Type.valueOf(type.name()));
42 assertTrue(api.getType() == type);
49 throw new AssertionError("Able to call getGraph(String name) after shutdown()");
50 } catch (IllegalStateException e) {
57 public void testChampGraphInstantiation() throws Exception {
58 for (ChampGraph.Type type : ChampGraph.Type.values()) {
59 final ChampGraph graph = ChampGraph.Factory.newInstance(type, "foo");
64 graph.deleteObject(null);
65 throw new AssertionError("Able to call API method after shutdown was initiated");
66 } catch (IllegalStateException e) {
71 graph.deleteObjectIndex(null);
72 throw new AssertionError("Able to call API method after shutdown was initiated");
73 } catch (IllegalStateException e) {
78 graph.deletePartition(null);
79 throw new AssertionError("Able to call API method after shutdown was initiated");
80 } catch (IllegalStateException e) {
85 graph.deleteRelationship(null);
86 throw new AssertionError("Able to call API method after shutdown was initiated");
87 } catch (IllegalStateException e) {
92 graph.deleteRelationshipIndex(null);
93 throw new AssertionError("Able to call API method after shutdown was initiated");
94 } catch (IllegalStateException e) {
100 throw new AssertionError("Able to call API method after shutdown was initiated");
101 } catch (IllegalStateException e) {
106 graph.queryObjects(null);
107 throw new AssertionError("Able to call API method after shutdown was initiated");
108 } catch (IllegalStateException e) {
113 graph.queryRelationships(null);
114 throw new AssertionError("Able to call API method after shutdown was initiated");
115 } catch (IllegalStateException e) {
120 graph.retrieveObject(null);
121 throw new AssertionError("Able to call API method after shutdown was initiated");
122 } catch (IllegalStateException e) {
127 graph.retrieveObjectIndex(null);
128 throw new AssertionError("Able to call API method after shutdown was initiated");
129 } catch (IllegalStateException e) {
134 graph.retrieveObjectIndices();
135 throw new AssertionError("Able to call API method after shutdown was initiated");
136 } catch (IllegalStateException e) {
141 graph.retrieveRelationship(null);
142 throw new AssertionError("Able to call API method after shutdown was initiated");
143 } catch (IllegalStateException e) {
148 graph.retrieveRelationshipIndex(null);
149 throw new AssertionError("Able to call API method after shutdown was initiated");
150 } catch (IllegalStateException e) {
155 graph.retrieveRelationshipIndices();
156 throw new AssertionError("Able to call API method after shutdown was initiated");
157 } catch (IllegalStateException e) {
162 graph.retrieveRelationships(null);
163 throw new AssertionError("Able to call API method after shutdown was initiated");
164 } catch (IllegalStateException e) {
169 graph.retrieveSchema();
170 throw new AssertionError("Able to call API method after shutdown was initiated");
171 } catch (IllegalStateException e) {
176 graph.storeObject(null);
177 throw new AssertionError("Able to call API method after shutdown was initiated");
178 } catch (IllegalStateException e) {
183 graph.storeObjectIndex(null);
184 throw new AssertionError("Able to call API method after shutdown was initiated");
185 } catch (IllegalStateException e) {
190 graph.storePartition(null);
191 throw new AssertionError("Able to call API method after shutdown was initiated");
192 } catch (IllegalStateException e) {
197 graph.storeRelationship(null);
198 throw new AssertionError("Able to call API method after shutdown was initiated");
199 } catch (IllegalStateException e) {
204 graph.storeRelationshipIndex(null);
205 throw new AssertionError("Able to call API method after shutdown was initiated");
206 } catch (IllegalStateException e) {
211 graph.storeSchema(null);
212 throw new AssertionError("Able to call API method after shutdown was initiated");
213 } catch (IllegalStateException e) {
218 graph.updateSchema(new ChampObjectConstraint.Builder("").build());
219 throw new AssertionError("Able to call API method after shutdown was initiated");
220 } catch (IllegalStateException e) {
225 graph.updateSchema(new ChampRelationshipConstraint.Builder("").build());
226 throw new AssertionError("Able to call API method after shutdown was initiated");
227 } catch (IllegalStateException e) {
233 throw new AssertionError("Able to call API method after shutdown was initiated");
234 } catch (IllegalStateException e) {