Fixed search, random_destination method return ArrayList sizes, implemented random_destination tests and build ran successful

distance_related_methods
Selim Eser 2024-06-09 19:59:22 +02:00
parent db04ad8201
commit 0ac411e9d3
2 changed files with 20 additions and 4 deletions

View File

@ -72,8 +72,8 @@ public class System {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
while ((line = reader.readLine()) != null) {
if(line.contains(hometown_or_zip)&&zip_set.size()<200){
while ((line = reader.readLine()) != null && zip_set.size()<200) {
if(line.contains(hometown_or_zip)){
line = line.replace("\"", "");
zip_set.add(line);
}
@ -91,7 +91,7 @@ public class System {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
while ((line = reader.readLine()) != null) {
while ((line = reader.readLine()) != null && result.size()<3) {
line = line.replace("\"", "");
@ -111,7 +111,7 @@ public class System {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
while ((line = reader.readLine()) != null) {
while ((line = reader.readLine()) != null && result.size()<3) {
line = line.replace("\"", "");

View File

@ -82,4 +82,20 @@ public class SystemTest {
assertEquals("60.361 l", current_system.calc_l_consumption("10115")); // Kraftstoffverbrauch nach Berlin
}
@Test
public void random_destinations(){
System current_system = new System("35a75437476f12302f72e55d368485db");
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
// 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);
// 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);
}
}