package SewerAnalysis; import org.junit.jupiter.api.Test; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import static org.junit.jupiter.api.Assertions.*; /** * Class SewerTest testing suite short range */ class SewerTest { @Test /* * check that the correct Sewer is fetched via MississaugaSewers fetchSewer method */ void fetchSewerTest() throws IOException, ParseException { MississaugaSewers ms = new MississaugaSewers(100); Sewer sewer = ms.fetchSewer(28400); assertEquals(28400, sewer.assetId); assertEquals("Catchbasin Manhole", sewer.assetType); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); Date expectedDate = sdf.parse("1952/01/01"); assertEquals(0, sewer.installDate.compareTo(expectedDate)); assertEquals("CLARKSON", sewer.worksYard); assertEquals(1, sewer.ward); } @Test void fetchSewerTest2() throws IOException { MississaugaSewers ms = new MississaugaSewers(100); Sewer sewer = ms.fetchSewer(2030135); assertEquals(2030135, sewer.assetId); } @Test /* * check that the correct Sewer is distance is outputted via Sewer distanceTo method */ void distanceTest() throws IOException { MississaugaSewers ms = new MississaugaSewers(100); Sewer s1 = ms.fetchSewer(28400); Sewer s2 = ms.fetchSewer(2030138); assertEquals(9331.570354035523,s1.distanceTo(s2),1); } @Test void distanceTest2() throws IOException { MississaugaSewers ms = new MississaugaSewers(100); Sewer s1 = ms.fetchSewer(2030569); Sewer s2 = ms.fetchSewer(2030571); assertEquals(50.24379829810221,s1.distanceTo(s2),1); } @Test /* * check that the correct number of Sewer objects in given works yard * and ward is outputted via MississaugaSewers filterWardWorksYard method */ void filterWardWorksYard() throws IOException { MississaugaSewers ms = new MississaugaSewers(82036); String Malton = "MALTON"; short ward = 5; ArrayList worksYard_Ward = ms.filterWardWorksYard(Malton, ward); assertEquals(14112, worksYard_Ward.size()); } }