aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java')
-rw-r--r--src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java209
1 files changed, 3 insertions, 206 deletions
diff --git a/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java b/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
index 7dacfe6..0ca8481 100644
--- a/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
+++ b/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
@@ -21,7 +21,6 @@ package org.onap.aai.dbgen;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.boot.test.rule.OutputCapture;
import org.janusgraph.core.JanusGraphTransaction;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -29,7 +28,6 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.onap.aai.AAISetup;
@@ -39,8 +37,6 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -51,9 +47,6 @@ public class ForceDeleteToolTest extends AAISetup {
private ForceDeleteTool deleteTool;
private Vertex cloudRegionVertex;
-
- @Rule
- public OutputCapture outputCapture = new OutputCapture();
@Before
public void setup(){
@@ -124,12 +117,10 @@ public class ForceDeleteToolTest extends AAISetup {
@Test
public void testDeleteNode(){
- InputStream systemInputStream = System.in;
- ByteArrayInputStream in = new ByteArrayInputStream("y".getBytes());
- System.setIn(in);
String id = cloudRegionVertex.id().toString();
String [] args = {
+
"-action",
"DELETE_NODE",
"-userId",
@@ -139,7 +130,6 @@ public class ForceDeleteToolTest extends AAISetup {
};
deleteTool.main(args);
- System.setIn(systemInputStream);
}
@Test
@@ -151,6 +141,7 @@ public class ForceDeleteToolTest extends AAISetup {
String cloudRegionToPserverId = edges.get(0).id().toString();
String [] args = {
+
"-action",
"COLLECT_DATA",
"-userId",
@@ -160,7 +151,6 @@ public class ForceDeleteToolTest extends AAISetup {
};
deleteTool.main(args);
-
}
@Test
@@ -175,6 +165,7 @@ public class ForceDeleteToolTest extends AAISetup {
String cloudRegionToPserverId = edges.get(0).id().toString();
String [] args = {
+
"-action",
"DELETE_EDGE",
"-userId",
@@ -186,200 +177,6 @@ public class ForceDeleteToolTest extends AAISetup {
deleteTool.main(args);
System.setIn(systemInputStream);
}
-
- //------------------------------ Adding some new tests --------------
-
-
- @Test
- public void testCollectDataForVertexId(){
- String id = cloudRegionVertex.id().toString();
-
- String [] args = {
- "-action",
- "COLLECT_DATA",
- "-userId",
- "someuser",
- "-vertexId",
- id
- };
-
- deleteTool.main(args);
- }
-
-
- @Test
- public void testInputParamsBadAction(){
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
- List<Edge> edges = g.E().toList();
- String cloudRegionToPserverId = edges.get(0).id().toString();
-
- String [] args = {
- "-action",
- "JUNK-ACTION",
- "-userId",
- "someuser",
- "-edgeId",
- cloudRegionToPserverId
- };
-
- deleteTool.main(args);
- // Capture the standard output and see if the following text is there
- assertThat(outputCapture.toString(), containsString("Bad action parameter"));
-
- }
-
-
- @Test
- public void testMissingInputs(){
-
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
-
- String [] args = {
- "-action"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
-
- args = new String []{
- "-vertexId"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
-
- args = new String []{
- "-edgeId"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
-
- args = new String []{
- "-params4Collect"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
- }
-
-
-
- @Test
- public void testInvalidUserIds(){
-
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
- List<Edge> edges = g.E().toList();
- String cloudRegionToPserverId = edges.get(0).id().toString();
-
- String [] args = {
- "-userId"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
- args = new String []{
- "-userId",
- "bad"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Bad userId parameter"));
-
- args = new String []{
- "-userId",
- "AAIADMIN"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Bad userId parameter"));
- }
-
-
- @Test
- public void testBadInputs2(){
-
- // pass in a bad/unknown argument (-junkParam)
- String [] args = {
- "-junkParam",
- "COLLECT_DATA",
- "-userId",
- "someuser",
- "-edgeId",
- "999"
- };
-
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Unrecognized argument"));
- }
-
- @Test
- public void testBadInputs3(){
-
- // pass in a nonExistant edgeId for DELETE EDGE
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
-
- String [] args = {
- "-action",
- "DELETE_EDGE",
- "-userId",
- "someuser",
- "-edgeId",
- "NotRealId"
- };
-
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Edge with edgeId = NotRealId not found"));
-
- }
-
- @Test
- public void testBadInputs4(){
-
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
-
- // pass in a bad vertex Id when collecting data
-
- String [] args = {
- "-action",
- "COLLECT_DATA",
- "-userId",
- "someuser",
- "-vertexId",
- "NotANumber"
- };
-
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Bad value passed"));
-
- }
-
-
- @Test
- public void testBadInputs5(){
-
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
-
- // pass in a bad vertex Id when collecting data
-
- String [] args = {
- "-action",
- "DELETE_NODE",
- "-userId",
- "someuser",
- "-vertexId",
- "555"
- };
-
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Vertex with vertexId = 555 not found"));
-
- }
-
@After
public void tearDown(){