summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test/java
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-02-21 13:41:30 +0100
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-02-21 15:06:36 +0100
commite190b0b67803241ad3a94a6c6396fc47a94e7fac (patch)
tree48bb6696a881cfda1941f602ae3bc68ba9a46fd2 /aai-core/src/test/java
parente5cf8b0a5bbad65dacdb1055f8b4894dce8cdb26 (diff)
Enhance SchemaGenerator to also generate indices for relationships
- generate edge indexes when they not already exist - reindex existing indexes when they are not in status ENABLED - try to recover indexes that are in INSTALLED state - bump version to 1.13.5 Issue-ID: AAI-3782 Change-Id: I127e0f83b17485d7a6721206ade92cd50c89a51b Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-core/src/test/java')
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java43
1 files changed, 22 insertions, 21 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java
index ac08ae2c..a1206b59 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java
@@ -47,7 +47,10 @@ import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.onap.aai.setup.SchemaVersion;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+@DirtiesContext(classMode=ClassMode.BEFORE_CLASS)
public class ResourceWithSoTTest extends AAISetup {
@Mock
private UrlBuilder urlBuilder;
@@ -78,7 +81,7 @@ public class ResourceWithSoTTest extends AAISetup {
graph = TinkerGraph.open();
long currentTimeMs = System.currentTimeMillis();
- String timeNowInMs = Long.toString(currentTimeMs);
+ final String timeNowInMs = Long.toString(currentTimeMs);
// PUT / CREATE
jsonPutObj.addProperty("aai-created-ts", timeNowInMs);
@@ -114,6 +117,24 @@ public class ResourceWithSoTTest extends AAISetup {
createLoaderEngineSetup();
}
+ public void createLoaderEngineSetup() throws AAIException {
+
+ loader = loaderFactory.createLoaderForVersion(factoryType, version);
+
+ dbEngine = spy(new JanusGraphDBEngine(QueryStyle.TRAVERSAL, loader));
+ serializer = new DBSerializer(version, dbEngine, factoryType, "Junit");
+ resourceWithSoT = new ResourceWithSoT.Builder(loader, serializer, urlBuilder).build();
+
+ TransactionalGraphEngine.Admin spyAdmin = spy(dbEngine.asAdmin());
+
+ when(dbEngine.tx()).thenReturn(graph);
+ when(dbEngine.asAdmin()).thenReturn(spyAdmin);
+
+ when(spyAdmin.getReadOnlyTraversalSource())
+ .thenReturn(graph.traversal().withStrategies(ReadOnlyStrategy.instance()));
+ when(spyAdmin.getTraversalSource()).thenReturn(graph.traversal());
+ }
+
// This test is to simulate a PUT request
@Test
public void testGetJsonFromVertexWithCreateVertex() throws AAIFormatVertexException, AAIException {
@@ -148,24 +169,4 @@ public class ResourceWithSoTTest extends AAISetup {
Optional<JsonObject> result = resourceWithSoT.getJsonFromVertex(null);
assertFalse(result.isPresent());
}
-
- public void createLoaderEngineSetup() throws AAIException {
-
- if (loader == null) {
- loader = loaderFactory.createLoaderForVersion(factoryType, version);
- // loader = LoaderFactory.createLoaderForVersion(factoryType, version);
- dbEngine = spy(new JanusGraphDBEngine(QueryStyle.TRAVERSAL, loader));
- serializer = new DBSerializer(version, dbEngine, factoryType, "Junit");
- resourceWithSoT = new ResourceWithSoT.Builder(loader, serializer, urlBuilder).build();
-
- TransactionalGraphEngine.Admin spyAdmin = spy(dbEngine.asAdmin());
-
- when(dbEngine.tx()).thenReturn(graph);
- when(dbEngine.asAdmin()).thenReturn(spyAdmin);
-
- when(spyAdmin.getReadOnlyTraversalSource())
- .thenReturn(graph.traversal().withStrategies(ReadOnlyStrategy.instance()));
- when(spyAdmin.getTraversalSource()).thenReturn(graph.traversal());
- }
- }
}