CategoryPartitionRemoveNodeSingleGraph.java

package org.graphstream.graph.implementations;

import static org.junit.Assert.*;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;

import java.net.URL;
import java.util.NoSuchElementException;
import java.util.Random;

import org.databene.benerator.anno.Source;
import org.databene.feed4junit.Feeder;
import org.graphstream.graph.Edge;
import org.graphstream.graph.ElementNotFoundException;
import org.graphstream.graph.IdAlreadyInUseException;
import org.graphstream.graph.Node;
import org.junit.Test;
import org.junit.runner.RunWith;

public class CategoryPartitionRemoveNodeSingleGraph {

	// idExistance,idValue,graphNrNodes,graphStrictChecking,nodeDegree
	@Rule
	public ExpectedException exception = ExpectedException.none();
	
	

	// not completed yet
	@Test
	public void test1() {
		SingleGraph graph1 = new SingleGraph("single", false, false); // strict checking will
														// be set auto to true
														// by the constructor.

		for (int i = 0; i < 10; i++) {
			graph1.addNode("node_" + i);
		}
		for (int i = 0; i < 4; i++) {
			graph1.addEdge("Edge_" + i, "node_1", "node_" + (i + 1));
		}
		
		SingleGraph graph2 = new SingleGraph("MyGraph2",false, false);
		
		for (int i = 0; i < 10; i++) {
			graph2.addNode("node_" + i);
		}
		for (int i = 0; i < 4; i++) {
			graph2.addEdge("Edge_" + i, "node_1", "node_" + (i + 1));
		}
		
		Node nodeToRemove = graph2.addNode("node2");
		exception.expect(ElementNotFoundException.class);
		graph1.removeNode(nodeToRemove);
	
	}

	@Test
	public void test2() {
		
		SingleGraph graph1 = new SingleGraph("single"); // strict checking will
		// be set auto to true
		// by the constructor.

		for (int i = 0; i < 10; i++) {
		graph1.addNode("node_" + i);
		}
		for (int i = 0; i < 4; i++) {
		graph1.addEdge("Edge_" + i, "node_1", "node_" + (i + 1));
		}

		exception.expect(ElementNotFoundException.class);
		graph1.removeNode("notExistedNode");
		fail();
//		assertTrue(graph1.getNodeCount() == 10);
	}
	@Test
	public void test3() {
		
		SingleGraph graph1 = new SingleGraph("single", false, false); // strict checking will
		// be set auto to true
		// by the constructor.

		for (int i = 0; i < 10; i++) {
		graph1.addNode("node_" + i);
		}
		for (int i = 0; i < 4; i++) {
		graph1.addEdge("Edge_" + i, "node_1", "node_" + (i + 1));
		}

		graph1.removeNode("node_1");
		assertTrue(graph1.getNodeCount() == 9);


		

	}
	@Test
	public void test4() {
		SingleGraph graph1 = new SingleGraph("single"); // strict checking will
		// be set auto to true
		// by the constructor.

		for (int i = 0; i < 10; i++) {
		graph1.addNode("node_" + i);
		}
		for (int i = 0; i < 4; i++) {
		graph1.addEdge("Edge_" + i, "node_1", "node_" + (i + 1));
		}
		
		SingleGraph graph2 = new SingleGraph("MyGraph2");
		
		for (int i = 0; i < 10; i++) {
		graph2.addNode("node_" + i);
		}
		for (int i = 0; i < 4; i++) {
		graph2.addEdge("Edge_" + i, "node_1", "node_" + (i + 1));
		}
		
		
		graph1.removeNode("node_2");
		assertTrue(graph1.getNodeCount() == 9);

	}
	@Test
	public void test5() {

		SingleGraph graph1 = new SingleGraph("single"); // strict checking will
		// be set auto to true
		// by the constructor.

		for (int i = 0; i < 10; i++) {
		graph1.addNode("node_" + i);
		}
		
		SingleGraph graph2 = new SingleGraph("MyGraph2");
		
		for (int i = 0; i < 10; i++) {
		graph2.addNode("node_" + i);
		}
		
		
		graph1.removeNode("node_1");
		assertTrue(graph1.getNodeCount() == 9);

	}
	

}