2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.aai.dbmap;
22 import org.janusgraph.core.JanusGraphFactory;
23 import org.janusgraph.core.JanusGraph;
24 import org.janusgraph.core.schema.JanusGraphManagement;
26 import org.onap.aai.AAISetup;
27 import org.onap.aai.util.AAIConstants;
30 import static org.hamcrest.CoreMatchers.containsString;
31 import static org.hamcrest.Matchers.matchesPattern;
32 import static org.junit.Assert.*;
34 public class AAIGraphTest extends AAISetup{
37 AAIGraph.getInstance();
41 public void getRealtimeInstanceConnectionName() throws Exception {
43 JanusGraphManagement graphMgt = AAIGraph.getInstance().getGraph().openManagement();
44 String connectionInstanceName = graphMgt.getOpenInstances().stream().filter(c -> c.contains("current")).findFirst().get();
45 assertThat(connectionInstanceName, containsString(SERVICE_NAME));
46 assertThat(connectionInstanceName, containsString("realtime"));
47 assertThat(connectionInstanceName, matchesPattern("^\\d+_[\\w\\-\\d]+_" + SERVICE_NAME + "_realtime_\\d+\\(current\\)$"));
52 public void getCachedInstanceConnectionName() throws Exception {
54 JanusGraphManagement graphMgt = AAIGraph.getInstance().getGraph(DBConnectionType.CACHED).openManagement();
55 String connectionInstanceName = graphMgt.getOpenInstances().stream().filter(c -> c.contains("current")).findFirst().get();
56 assertThat(connectionInstanceName, containsString(SERVICE_NAME));
57 assertThat(connectionInstanceName, containsString("cached"));
58 assertThat(connectionInstanceName, matchesPattern("^\\d+_[\\w\\-\\d]+_" + SERVICE_NAME + "_cached_\\d+\\(current\\)$"));
63 public void JanusGraphOpenNameTest() throws Exception{
64 JanusGraph graph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(SERVICE_NAME).withGraphType("graphType").buildConfiguration());
65 JanusGraphManagement graphMgt = graph.openManagement();
66 String connectionInstanceName = graphMgt.getOpenInstances().stream().filter(c -> c.contains("current")).findFirst().get();
67 assertThat(connectionInstanceName,matchesPattern("^\\d+_[\\w\\-\\d]+_" + SERVICE_NAME + "_graphType_\\d+\\(current\\)$"));