// Testing the getDriveString method by mocking a location instance and stubbing the // getName, getCon1, getCon2, getSt1, and getSt2 methods to be able to test with // seed arguments 0 and 1 and make sure they return the correct string. @Test public void testGetDriveString() { City myCity = new City(); int d = 3; Location mockLoc = Mockito.mock(Location.class); Mockito.when(mockLoc.getName()).thenReturn("University"); Mockito.when(mockLoc.getCon1Name()).thenReturn("Con1"); Mockito.when(mockLoc.getCon2Name()).thenReturn("Con2"); Mockito.when(mockLoc.getSt1()).thenReturn("St1"); Mockito.when(mockLoc.getSt2()).thenReturn("St2"); int seed = 0; assertEquals( "Driver 3 heading from University to Con1 via St1", myCity.getDriveString(d, mockLoc, seed)); seed = 1; assertEquals( "Driver 3 heading from University to Con2 via St2", myCity.getDriveString(d, mockLoc, seed)); }