// Path: src/main/java/com/maxdemarzi/processing/centrality/Betweenness.java
// public class Betweenness implements Centrality {
//     private final GraphDatabaseService db;
//     private final int nodeCount;
//     private BetweennessCentrality<Double> betweennessCentrality;
// 
//     public Betweenness(GraphDatabaseService db){
//         this.db = db;
//         this.nodeCount = new NodeCounter().getNodeCount(db);
//     }
// 
//     @Override
//     public void compute(String label, String type, int iterations) {
//         SingleSourceShortestPath<Double> singleSourceShortestPath = getSingleSourceShortestPath(DynamicRelationshipType.withName(type));
//         Set<Node> nodes = new HashSet<>();
//         try ( Transaction tx = db.beginTx()) {
//             ResourceIterator<Node> iterator = db.findNodes(Label.label(label));
//             while (iterator.hasNext()) {
//                 nodes.add(iterator.next());
//             }
//             betweennessCentrality = new BetweennessCentrality<Double>(
//                     singleSourceShortestPath, nodes);
//             betweennessCentrality.calculate();
//         }
// 
//     }
// 
//     @Override
//     public double getResult(long node) {
//             if (betweennessCentrality.isCalculated()) {
//                 Double result = betweennessCentrality.getCentrality(db.getNodeById(node));
//                 if (result != null) {
//                     return result;
//                 }
//             }
//         return 0.0;
//     }
// 
//     @Override
//     public long numberOfNodes() {
//         return nodeCount;
//     }
// 
//     @Override
//     public String getPropertyName() {
//         return  "betweeness_centrality";
//     }
// }


import com.maxdemarzi.processing.centrality.Betweenness;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.test.TestGraphDatabaseFactory;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
package com.maxdemarzi.processing;




public class BetweenessCentralityTest {
    private GraphDatabaseService db;
    private static Service service;

    @Before
    public void setUp() {
        db = new TestGraphDatabaseFactory().newImpermanentDatabase();
        service = new Service();
        populateDb(db);
    }

    private void populateDb(GraphDatabaseService db) {
        try ( Transaction tx = db.beginTx()) {
            db.execute(TestObjects.MOVIES_QUERY);
            db.execute(TestObjects.KNOWS_QUERY);
            tx.success();
        }
    }

    @After
    public void tearDown() throws Exception {
        db.shutdown();
    }

    @Test
    public void shouldCalculateBetweennessCentrality() throws IOException {
        String response = service.betweenness("Movie", "ACTED_IN", db);
        assertEquals("Betweenness Centrality for Movie and ACTED_IN Completed!", response);
    }

    @Test
    public void shouldCalculateBetweennessCentralityTwo() throws IOException {
// Path: src/main/java/com/maxdemarzi/processing/centrality/Betweenness.java
// public class Betweenness implements Centrality {
//     private final GraphDatabaseService db;
//     private final int nodeCount;
//     private BetweennessCentrality<Double> betweennessCentrality;
// 
//     public Betweenness(GraphDatabaseService db){
//         this.db = db;
//         this.nodeCount = new NodeCounter().getNodeCount(db);
//     }
// 
//     @Override
//     public void compute(String label, String type, int iterations) {
//         SingleSourceShortestPath<Double> singleSourceShortestPath = getSingleSourceShortestPath(DynamicRelationshipType.withName(type));
//         Set<Node> nodes = new HashSet<>();
//         try ( Transaction tx = db.beginTx()) {
//             ResourceIterator<Node> iterator = db.findNodes(Label.label(label));
//             while (iterator.hasNext()) {
//                 nodes.add(iterator.next());
//             }
//             betweennessCentrality = new BetweennessCentrality<Double>(
//                     singleSourceShortestPath, nodes);
//             betweennessCentrality.calculate();
//         }
// 
//     }
// 
//     @Override
//     public double getResult(long node) {
//             if (betweennessCentrality.isCalculated()) {
//                 Double result = betweennessCentrality.getCentrality(db.getNodeById(node));
//                 if (result != null) {
//                     return result;
//                 }
//             }
//         return 0.0;
//     }
// 
//     @Override
//     public long numberOfNodes() {
//         return nodeCount;
//     }
// 
//     @Override
//     public String getPropertyName() {
//         return  "betweeness_centrality";
//     }
// }


// Path: src/test/java/com/maxdemarzi/processing/BetweenessCentralityTest.java
import com.maxdemarzi.processing.centrality.Betweenness;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.test.TestGraphDatabaseFactory;
import java.io.IOException;
import static org.junit.Assert.assertEquals;

package com.maxdemarzi.processing;




public class BetweenessCentralityTest {
    private GraphDatabaseService db;
    private static Service service;

    @Before
    public void setUp() {
        db = new TestGraphDatabaseFactory().newImpermanentDatabase();
        service = new Service();
        populateDb(db);
    }

    private void populateDb(GraphDatabaseService db) {
        try ( Transaction tx = db.beginTx()) {
            db.execute(TestObjects.MOVIES_QUERY);
            db.execute(TestObjects.KNOWS_QUERY);
            tx.success();
        }
    }

    @After
    public void tearDown() throws Exception {
        db.shutdown();
    }

    @Test
    public void shouldCalculateBetweennessCentrality() throws IOException {
        String response = service.betweenness("Movie", "ACTED_IN", db);
        assertEquals("Betweenness Centrality for Movie and ACTED_IN Completed!", response);
    }

    @Test
    public void shouldCalculateBetweennessCentralityTwo() throws IOException {
        Betweenness centrality = new Betweenness(db);