diff --git a/src/main/java/de/hs_mannheim/domain/System.java b/src/main/java/de/hs_mannheim/domain/System.java index 79a72a0..ca4b468 100644 --- a/src/main/java/de/hs_mannheim/domain/System.java +++ b/src/main/java/de/hs_mannheim/domain/System.java @@ -451,7 +451,9 @@ public class System { } catch (Exception e) { } - try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { + InputStream inputStream2 = System.class.getResourceAsStream("/zip.csv"); + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream2))) { String line; while ((line = reader.readLine()) != null) { line = line.replace("\"", ""); diff --git a/src/main/resources/user_data.csv b/src/main/resources/user_data.csv index d73791d..912c767 100644 --- a/src/main/resources/user_data.csv +++ b/src/main/resources/user_data.csv @@ -1,2 +1,2 @@ Daniel;MTQwMURhbmllbA==;Mannheim;68305;BMW;1.5;50.4;40.2 -David;MTIzRXNlbA==;Mannheim;68161;AMG;10.0;300.0;20.0 \ No newline at end of file +David;MTIzRXNlbA==;Mannheim;68161;AMG;10.0;300.0;20.0 \ No newline at end of file diff --git a/src/test/java/de/hs_mannheim/domain/SystemTest.java b/src/test/java/de/hs_mannheim/domain/SystemTest.java index 53f4e8b..3059507 100644 --- a/src/test/java/de/hs_mannheim/domain/SystemTest.java +++ b/src/test/java/de/hs_mannheim/domain/SystemTest.java @@ -20,7 +20,7 @@ public class SystemTest { @Test public void current_weather(){ - current_system.set_current_user_zip("68161"); + current_system.sign_in_user("David","123Esel"); assertNotEquals("Es ist ein Fehler aufgetreten!",current_system.current_weather()); } @@ -37,8 +37,8 @@ public class SystemTest { @Test public void distance(){ - - current_system.set_current_user_zip("68161"); + + current_system.sign_in_user("David","123Esel"); assertEquals("88.46 km", current_system.distance("60306")); // Frankfurt assertEquals("581.109 km", current_system.distance("20095")); // Hamburg @@ -49,7 +49,8 @@ public class SystemTest { @Test public void travel_time(){ - current_system.set_current_user_zip("68161"); + current_system.sign_in_user("David","123Esel"); + current_system.set_current_user_car_avg_kmh(100); current_system.set_current_user_bike_avg_kmh(20); @@ -63,7 +64,8 @@ public class SystemTest { @Test public void calc_l_consumption(){ - current_system.set_current_user_zip("68161"); + current_system.sign_in_user("David","123Esel"); + current_system.set_current_user_car_avg_kmh(100); current_system.set_current_user_car_l_100km(10); @@ -75,15 +77,17 @@ public class SystemTest { @Test public void random_destinations(){ - current_system.set_current_user_zip("68161"); - - assertEquals(3, current_system.random_destinations_car().size()); // random_destinations_car gibt genau 3 destinations zurück - assertEquals(3, current_system.random_destinations_bike().size()); // random destinations_bike gibt genau 3 destinations zurück + current_system.sign_in_user("David","123Esel"); + ArrayList random_destination_car = current_system.random_destinations_car(); + ArrayList random_destination_bike = current_system.random_destinations_bike(); + + assertEquals(3, random_destination_car.size()); // random_destinations_car gibt genau 3 destinations zurück + assertEquals(3, random_destination_bike.size()); // random destinations_bike gibt genau 3 destinations zurück // random_destinations_car gibt nur destinations mit mindestens 150 km Entfernung zurück - assertEquals(true, Double.parseDouble(current_system.distance(current_system.random_destinations_car().get(0).split(";")[0]).replace(" km", "")) > 150); + assertEquals(true, Double.parseDouble(current_system.distance(random_destination_car.get(0).split(";")[0]).replace(" km", "")) > 150); // random_destinations_bike gibt nur destinations mit maximal 100 km Entfernung zurück - assertEquals(true, Double.parseDouble(current_system.distance(current_system.random_destinations_bike().get(0).split(";")[0]).replace(" km", "")) < 100); + assertEquals(true, Double.parseDouble(current_system.distance(random_destination_bike.get(0).split(";")[0]).replace(" km", "")) < 100); } @Test @@ -144,10 +148,11 @@ public class SystemTest { assertEquals("Enes", current_system.getDetails()[0]); } - /* - Tests auf Basis von user_data.csv: Daniel;MTQwMURhbmllbA==;Mannheim;68305;BMW;1.5;50.4;40.2 - David;MTIzRXNlbA==;Mannheim;68161;AMG;10.0;300.0;20.0 - */ +/* +Tests auf Basis von user_data.csv: +Daniel;MTQwMURhbmllbA==;Mannheim;68305;BMW;1.5;50.4;40.2 +David;MTIzRXNlbA==;Mannheim;68161;AMG;10.0;300.0;20.0 +*/ } \ No newline at end of file diff --git a/src/test/resources/user_data.csv b/src/test/resources/user_data.csv index d73791d..912c767 100644 --- a/src/test/resources/user_data.csv +++ b/src/test/resources/user_data.csv @@ -1,2 +1,2 @@ Daniel;MTQwMURhbmllbA==;Mannheim;68305;BMW;1.5;50.4;40.2 -David;MTIzRXNlbA==;Mannheim;68161;AMG;10.0;300.0;20.0 \ No newline at end of file +David;MTIzRXNlbA==;Mannheim;68161;AMG;10.0;300.0;20.0 \ No newline at end of file