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.onap.aai.champcore.core;
24 import org.junit.Test;
25 import org.onap.aai.champcore.ChampAPI;
26 import org.onap.aai.champcore.ChampGraph;
27 import org.onap.aai.champcore.graph.impl.ChampAPIImpl;
28 import org.onap.aai.champcore.graph.impl.InMemoryChampGraphImpl;
29 import org.onap.aai.champcore.model.ChampObjectConstraint;
30 import org.onap.aai.champcore.model.ChampRelationshipConstraint;
32 import static org.junit.Assert.assertTrue;
34 import java.util.Optional;
36 public class ChampAPITest {
39 public void testChampAPIMemoryInstantiation() {
40 testChampAPIInstantiation(new ChampAPIImpl("IN_MEMORY"), "IN_MEMORY");
43 public void testChampAPIInstantiation(ChampAPI api, String expectedType) {
44 assertTrue(api.getType() == expectedType);
51 throw new AssertionError("Able to call getGraph(String name) after shutdown()");
52 } catch (IllegalStateException e) {
58 public void testChampMemoryGraphInstantiation() throws Exception
60 testChampGraphInstantiation(new InMemoryChampGraphImpl.Builder().build());
63 public void testChampGraphInstantiation(ChampGraph graph) throws Exception {
68 graph.deleteObject(null, Optional.empty());
69 throw new AssertionError("Able to call API method after shutdown was initiated");
70 } catch (IllegalStateException e) {
75 graph.deleteObjectIndex(null);
76 throw new AssertionError("Able to call API method after shutdown was initiated");
77 } catch (IllegalStateException e) {
82 graph.deletePartition(null, Optional.empty());
83 throw new AssertionError("Able to call API method after shutdown was initiated");
84 } catch (IllegalStateException e) {
89 graph.deleteRelationship(null, Optional.empty());
90 throw new AssertionError("Able to call API method after shutdown was initiated");
91 } catch (IllegalStateException e) {
96 graph.deleteRelationshipIndex(null);
97 throw new AssertionError("Able to call API method after shutdown was initiated");
98 } catch (IllegalStateException e) {
103 graph.deleteSchema();
104 throw new AssertionError("Able to call API method after shutdown was initiated");
105 } catch (IllegalStateException e) {
110 graph.queryObjects(null, Optional.empty());
111 throw new AssertionError("Able to call API method after shutdown was initiated");
112 } catch (IllegalStateException e) {
117 graph.queryRelationships(null, Optional.empty());
118 throw new AssertionError("Able to call API method after shutdown was initiated");
119 } catch (IllegalStateException e) {
124 graph.retrieveObject(null, Optional.empty());
125 throw new AssertionError("Able to call API method after shutdown was initiated");
126 } catch (IllegalStateException e) {
131 graph.retrieveObjectIndex(null);
132 throw new AssertionError("Able to call API method after shutdown was initiated");
133 } catch (IllegalStateException e) {
138 graph.retrieveObjectIndices();
139 throw new AssertionError("Able to call API method after shutdown was initiated");
140 } catch (IllegalStateException e) {
145 graph.retrieveRelationship(null, Optional.empty());
146 throw new AssertionError("Able to call API method after shutdown was initiated");
147 } catch (IllegalStateException e) {
152 graph.retrieveRelationshipIndex(null);
153 throw new AssertionError("Able to call API method after shutdown was initiated");
154 } catch (IllegalStateException e) {
159 graph.retrieveRelationshipIndices();
160 throw new AssertionError("Able to call API method after shutdown was initiated");
161 } catch (IllegalStateException e) {
166 graph.retrieveRelationships(null, Optional.empty());
167 throw new AssertionError("Able to call API method after shutdown was initiated");
168 } catch (IllegalStateException e) {
173 graph.retrieveSchema();
174 throw new AssertionError("Able to call API method after shutdown was initiated");
175 } catch (IllegalStateException e) {
180 graph.storeObject(null, Optional.empty());
181 throw new AssertionError("Able to call API method after shutdown was initiated");
182 } catch (IllegalStateException e) {
187 graph.storeObjectIndex(null);
188 throw new AssertionError("Able to call API method after shutdown was initiated");
189 } catch (IllegalStateException e) {
194 graph.storePartition(null, Optional.empty());
195 throw new AssertionError("Able to call API method after shutdown was initiated");
196 } catch (IllegalStateException e) {
201 graph.storeRelationship(null, Optional.empty());
202 throw new AssertionError("Able to call API method after shutdown was initiated");
203 } catch (IllegalStateException e) {
208 graph.storeRelationshipIndex(null);
209 throw new AssertionError("Able to call API method after shutdown was initiated");
210 } catch (IllegalStateException e) {
215 graph.storeSchema(null);
216 throw new AssertionError("Able to call API method after shutdown was initiated");
217 } catch (IllegalStateException e) {
222 graph.updateSchema(new ChampObjectConstraint.Builder("").build());
223 throw new AssertionError("Able to call API method after shutdown was initiated");
224 } catch (IllegalStateException e) {
229 graph.updateSchema(new ChampRelationshipConstraint.Builder("").build());
230 throw new AssertionError("Able to call API method after shutdown was initiated");
231 } catch (IllegalStateException e) {
237 throw new AssertionError("Able to call API method after shutdown was initiated");
238 } catch (IllegalStateException e) {