2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 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============================================
21 package org.onap.aai.champcore.core;
23 import org.junit.Test;
24 import org.onap.aai.champcore.ChampAPI;
25 import org.onap.aai.champcore.ChampGraph;
26 import org.onap.aai.champcore.graph.impl.ChampAPIImpl;
27 import org.onap.aai.champcore.graph.impl.InMemoryChampGraphImpl;
28 import org.onap.aai.champcore.model.ChampObjectConstraint;
29 import org.onap.aai.champcore.model.ChampRelationshipConstraint;
31 import static org.junit.Assert.assertTrue;
33 import java.util.Optional;
35 public class ChampAPITest {
38 public void testChampAPIMemoryInstantiation() {
39 testChampAPIInstantiation(new ChampAPIImpl("IN_MEMORY"), "IN_MEMORY");
42 public void testChampAPIInstantiation(ChampAPI api, String expectedType) {
43 assertTrue(api.getType() == expectedType);
50 throw new AssertionError("Able to call getGraph(String name) after shutdown()");
51 } catch (IllegalStateException e) {
57 public void testChampMemoryGraphInstantiation() throws Exception
59 testChampGraphInstantiation(new InMemoryChampGraphImpl.Builder().build());
62 public void testChampGraphInstantiation(ChampGraph graph) throws Exception {
67 graph.deleteObject(null, Optional.empty());
68 throw new AssertionError("Able to call API method after shutdown was initiated");
69 } catch (IllegalStateException e) {
74 graph.deleteObjectIndex(null);
75 throw new AssertionError("Able to call API method after shutdown was initiated");
76 } catch (IllegalStateException e) {
81 graph.deletePartition(null, Optional.empty());
82 throw new AssertionError("Able to call API method after shutdown was initiated");
83 } catch (IllegalStateException e) {
88 graph.deleteRelationship(null, Optional.empty());
89 throw new AssertionError("Able to call API method after shutdown was initiated");
90 } catch (IllegalStateException e) {
95 graph.deleteRelationshipIndex(null);
96 throw new AssertionError("Able to call API method after shutdown was initiated");
97 } catch (IllegalStateException e) {
102 graph.deleteSchema();
103 throw new AssertionError("Able to call API method after shutdown was initiated");
104 } catch (IllegalStateException e) {
109 graph.queryObjects(null, Optional.empty());
110 throw new AssertionError("Able to call API method after shutdown was initiated");
111 } catch (IllegalStateException e) {
116 graph.queryRelationships(null, Optional.empty());
117 throw new AssertionError("Able to call API method after shutdown was initiated");
118 } catch (IllegalStateException e) {
123 graph.retrieveObject(null, Optional.empty());
124 throw new AssertionError("Able to call API method after shutdown was initiated");
125 } catch (IllegalStateException e) {
130 graph.retrieveObjectIndex(null);
131 throw new AssertionError("Able to call API method after shutdown was initiated");
132 } catch (IllegalStateException e) {
137 graph.retrieveObjectIndices();
138 throw new AssertionError("Able to call API method after shutdown was initiated");
139 } catch (IllegalStateException e) {
144 graph.retrieveRelationship(null, Optional.empty());
145 throw new AssertionError("Able to call API method after shutdown was initiated");
146 } catch (IllegalStateException e) {
151 graph.retrieveRelationshipIndex(null);
152 throw new AssertionError("Able to call API method after shutdown was initiated");
153 } catch (IllegalStateException e) {
158 graph.retrieveRelationshipIndices();
159 throw new AssertionError("Able to call API method after shutdown was initiated");
160 } catch (IllegalStateException e) {
165 graph.retrieveRelationships(null, Optional.empty());
166 throw new AssertionError("Able to call API method after shutdown was initiated");
167 } catch (IllegalStateException e) {
172 graph.retrieveSchema();
173 throw new AssertionError("Able to call API method after shutdown was initiated");
174 } catch (IllegalStateException e) {
179 graph.storeObject(null, Optional.empty());
180 throw new AssertionError("Able to call API method after shutdown was initiated");
181 } catch (IllegalStateException e) {
186 graph.storeObjectIndex(null);
187 throw new AssertionError("Able to call API method after shutdown was initiated");
188 } catch (IllegalStateException e) {
193 graph.storePartition(null, Optional.empty());
194 throw new AssertionError("Able to call API method after shutdown was initiated");
195 } catch (IllegalStateException e) {
200 graph.storeRelationship(null, Optional.empty());
201 throw new AssertionError("Able to call API method after shutdown was initiated");
202 } catch (IllegalStateException e) {
207 graph.storeRelationshipIndex(null);
208 throw new AssertionError("Able to call API method after shutdown was initiated");
209 } catch (IllegalStateException e) {
214 graph.storeSchema(null);
215 throw new AssertionError("Able to call API method after shutdown was initiated");
216 } catch (IllegalStateException e) {
221 graph.updateSchema(new ChampObjectConstraint.Builder("").build());
222 throw new AssertionError("Able to call API method after shutdown was initiated");
223 } catch (IllegalStateException e) {
228 graph.updateSchema(new ChampRelationshipConstraint.Builder("").build());
229 throw new AssertionError("Able to call API method after shutdown was initiated");
230 } catch (IllegalStateException e) {
236 throw new AssertionError("Able to call API method after shutdown was initiated");
237 } catch (IllegalStateException e) {