Skip to content

Commit

Permalink
Merge pull request #125 from TLI-Group-1/prelogin-returns-kms
Browse files Browse the repository at this point in the history
Prelogin returns kms not mileage (fix)
  • Loading branch information
sammdu authored Dec 12, 2021
2 parents 112afd3 + f8882e1 commit 0aeb75b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/tech/autodirect/api/services/SvcSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import tech.autodirect.api.interfaces.TableUsersInterface;
import tech.autodirect.api.utils.MergeCarAndOffer;
import tech.autodirect.api.utils.ParseChecker;
import tech.autodirect.api.utils.UnitConv;

import java.io.IOException;
import java.math.BigDecimal;
Expand Down Expand Up @@ -141,6 +142,16 @@ private List<Map<String, Object>> searchAllCars(
}

List<Map<String, Object>> carsMapsAll = this.tableCars.getAllCars();

// Loop over maps replacing mileage with kms
for (Map<String, Object> carMap : carsMapsAll) {
double mileage = ((Float) carMap.get("mileage")).doubleValue();
double kms = UnitConv.mileToKm(mileage);
carMap.remove("mileage");
carMap.put("kms", kms);
}


return sortCars(carsMapsAll, sortBy, sortAsc);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/tech/autodirect/api/upstream/BankApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class BankApi implements BankApiInterface {
/**
* Get the credit score for userId (uses last 3 digits of userId as credit score).
*/
@Override
public int getCreditScore(String userId) throws ResponseStatusException {
try {
return Integer.parseInt(userId.substring(userId.length() - 3));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/tech/autodirect/api/upstream/SensoApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class SensoApi implements SensoApiInterface {
// Gson object for JSON/Map conversions
private static final Gson GSON = new Gson();

@Override
public Map<String, Object> getLoanOffer(
String loanAmount,
String creditScore,
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/tech/autodirect/api/services/SvcSearchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ void testSorting(
} else {
assert prev >= valueDouble;
}

assert !carAndOfferInfo.containsKey("mileage") && carAndOfferInfo.containsKey("kms");
}
}
}
Expand Down

0 comments on commit 0aeb75b

Please sign in to comment.