CategoryPartitionAddNodeSingleGraph.java
package org.graphstream.graph.implementations;
import static org.junit.Assert.*;
import org.databene.benerator.anno.InvocationCount;
import org.databene.benerator.anno.Source;
import org.databene.feed4junit.Feeder;
import org.graphstream.graph.IdAlreadyInUseException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
@RunWith(Feeder.class)
public class CategoryPartitionAddNodeSingleGraph {
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
@Source("csvFiles/CategoryPartitionAddNodeSingleGraph.csv")
public void singleGraphAddNodeTest(String id, String value, String nodes, String strict) {
if (id.equals("false") && value.equals("correct") && nodes.equals("many") && strict.equals("true")) {
test1();
}
else if (id.equals("false") && value.equals("correct") && nodes.equals("0") && strict.equals("false")) {
test2();
}
else if (id.equals("false") && value.equals("correct") && nodes.equals("0") && strict.equals("true")) {
test3();
}
else if (id.equals("true") && value.equals("correct") && nodes.equals("many") && strict.equals("false")) {
test4();
}
else if (id.equals("true") && value.equals("correct") && nodes.equals("many") && strict.equals("true")) {
test5();
}
else if (id.equals("true") && value.equals("malformed") && nodes.equals("many") && strict.equals("true")) {
test6();
}
else if (id.equals("false") && value.equals("") && nodes.equals("0") && strict.equals("true")) {
test7();
}
else if (id.equals("false") && value.equals("null") && nodes.equals("0") && strict.equals("true")) {
test8();
}
}
public void test1() {
System.out.println("First");
SingleGraph single = new SingleGraph("single"); // strict checking will be set auto to true by the constructor.
String idValue = "nodeNew";
for (int i=0; i<10; i++) {
single.addNode("node"+i);
}
assertNull(single.getNode(idValue));
single.addNode(idValue);
assertNotNull(single.getNode(idValue));
}
public void test2() {
System.out.println("Second");
SingleGraph single = new SingleGraph("single");
single.setStrict(false);
String idValue = "nodeNew";
assertNull(single.getNode(idValue));
single.addNode(idValue);
assertNotNull(single.getNode(idValue));
}
public void test3() {
System.out.println("Third");
SingleGraph single = new SingleGraph("single");
String idValue = "nodeNew";
assertNull(single.getNode(idValue));
single.addNode(idValue);
assertNotNull(single.getNode(idValue));
}
public void test4() {
System.out.println("Fourth");
SingleGraph single = new SingleGraph("single");
single.setStrict(false);
String idValue = "nodeNew";
for (int i=0; i<10; i++) {
single.addNode("node"+i);
}
single.addNode(idValue);
assertNotNull(single.getNode(idValue));
single.addNode(idValue);
}
public void test5() {
System.out.println("Fifth");
exception.expect(IdAlreadyInUseException.class);
SingleGraph single = new SingleGraph("single");
String idValue = "nodeNew";
for (int i=0; i<10; i++) {
single.addNode("node"+i);
}
single.addNode(idValue);
assertNotNull(single.getNode(idValue));
single.addNode(idValue);
}
public void test6() {
System.out.println("Sixth");
exception.expect(IdAlreadyInUseException.class);
SingleGraph single = new SingleGraph("single");
String idValue = "\n"; // \n should be a malformed string.
for (int i=0; i<10; i++) {
single.addNode("node"+i);
}
single.addNode(idValue);
assertNotNull(single.getNode(idValue));
single.addNode(idValue);
}
public void test7() {
System.out.println("Seventh");
SingleGraph single = new SingleGraph("single");
String idValue = "";
assertNull(single.getNode(idValue));
single.addNode(idValue);
assertNotNull(single.getNode(idValue));
}
public void test8() {
System.out.println("Eighth");
exception.expect(AssertionError.class);
SingleGraph single = new SingleGraph("single");
String idValue = null;
assertNull(single.getNode(idValue));
single.addNode(idValue);
}
}