//////////////// FILE HEADER (INCLUDE IN EVERY FILE) //////////////////////////
//
// Title: CampusPaths Backend Tests
// Course: CS 400 Fall 2025
//
// Author: Peter Zeng
// Email: qzeng48@wisc.edu
//
//
///////////////////////////////////////////////////////////////////////////////////

/**
 * Three JUnit tests required by the role code:
 * - roleTest1: load graph + list locations
 * - roleTest2: nodes on shortest path (after loading)
 * - roleTest3: times on shortest path + furthest destination (after loading)
 */
import static org.junit.Assert.*;
import org.junit.Test;
import java.util.List;

public class BackendTests {

  // roleTest1: loadGraphData + getListOfAllLocations
  @Test
  public void roleTest1() throws Exception {
    Backend be = new Backend(new Graph_Placeholder());
    be.loadGraphData("campus.dot");
    List<String> all = be.getListOfAllLocations();

    assertTrue(all.contains("Union South"));
    assertTrue(all.contains("Computer Sciences and Statistics"));
    assertTrue(all.contains("Weeks Hall for Geological Sciences"));
  }

  // roleTest2: load first, then findLocationsOnShortestPath
  @Test
  public void roleTest2() throws Exception {
    Backend be = new Backend(new Graph_Placeholder());
    be.loadGraphData("campus.dot"); // <— populate locations set
    List<String> path =
        be.findLocationsOnShortestPath("Union South", "Weeks Hall for Geological Sciences");

    assertEquals(3, path.size());
    assertEquals("Union South", path.get(0));
    assertEquals("Computer Sciences and Statistics", path.get(1));
    assertEquals("Weeks Hall for Geological Sciences", path.get(2));
  }
  // roleTest3: load first, then times + furthest
  @Test
  public void roleTest3() throws Exception {
    Backend be = new Backend(new Graph_Placeholder());
    be.loadGraphData("campus.dot");
    List<Double> times =
        be.findTimesOnShortestPath("Union South", "Weeks Hall for Geological Sciences");

    assertEquals(2, times.size());
    assertTrue(times.get(0) > 0.0);
    assertTrue(times.get(1) >= times.get(0));

    String far = be.getFurthestDestinationFrom("Union South");
    assertEquals("Memorial Union", far);
}

}
