diff --git a/pom.xml b/pom.xml
index 070a7e0..840abfd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,7 +66,7 @@
org.jsoup
jsoup
- 1.14.3
+ 1.17.2
diff --git a/src/main/java/py/com/volpe/cotizacion/gatherer/GNB.java b/src/main/java/py/com/volpe/cotizacion/gatherer/GNB.java
index 6a978e8..9e44639 100644
--- a/src/main/java/py/com/volpe/cotizacion/gatherer/GNB.java
+++ b/src/main/java/py/com/volpe/cotizacion/gatherer/GNB.java
@@ -1,7 +1,6 @@
package py.com.volpe.cotizacion.gatherer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -14,6 +13,7 @@
import py.com.volpe.cotizacion.domain.QueryResponseDetail;
import java.io.IOException;
+import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@@ -34,25 +34,24 @@ public List doQuery(Place place, List branches) {
QueryResponse toRet = new QueryResponse(place);
- List parsed = getParsedData();
+ Root parsed = getParsedData();
- for (Root info : parsed) {
+ for (Exchange info : parsed.getExchangeRates()) {
toRet.addDetail(new QueryResponseDetail(
- info.getCashBuyPrice(),
- info.getCashSellPrice(),
- info.getCurrency().getCode()
+ info.getCashBuyPrice().longValue(),
+ info.getCashSellPrice().longValue(),
+ info.getCurrencyCode()
));
}
return Collections.singletonList(toRet);
}
- protected List getParsedData() {
+ protected Root getParsedData() {
try {
String queryResult = helper.doGet(WS_URL);
return buildMapper()
- .readValue(queryResult, new TypeReference>() {
- });
+ .readValue(queryResult, Root.class);
} catch (IOException e) {
throw new AppException(500, "cant parse the result of GNB ws", e);
}
@@ -76,21 +75,22 @@ protected Long parseAmount(String amount) {
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
- public static class Currency {
- public String code;
- public String description;
+ public static class Root {
+ private List exchangeRates;
}
+
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
- public static class Root {
- public Currency currency;
- public int electronicBuyPrice;
- public int electronicSellPrice;
- public int cashBuyPrice;
- public int cashSellPrice;
- public int checkBuyPrice;
- public int checkSellPrice;
+ public static class Exchange {
+ public String currencyCode;
+ public String currencyDesc;
+ public BigDecimal electronicBuyPrice;
+ public BigDecimal electronicSellPrice;
+ public BigDecimal cashBuyPrice;
+ public BigDecimal cashSellPrice;
+ public BigDecimal checkBuyPrice;
+ public BigDecimal checkSellPrice;
}
}
diff --git a/src/test/java/py/com/volpe/cotizacion/gatherer/GNBTest.java b/src/test/java/py/com/volpe/cotizacion/gatherer/GNBTest.java
index c9cbd91..0bf292e 100644
--- a/src/test/java/py/com/volpe/cotizacion/gatherer/GNBTest.java
+++ b/src/test/java/py/com/volpe/cotizacion/gatherer/GNBTest.java
@@ -66,11 +66,11 @@ void doQuery() throws Exception {
QueryResponseDetail usd = qr.getDetails().stream().filter(q -> q.getIsoCode().equals("USD")).findFirst().orElse(null);
QueryResponseDetail eur = qr.getDetails().stream().filter(q -> q.getIsoCode().equals("EUR")).findFirst().orElse(null);
- assertEquals(6730, usd.getPurchasePrice());
- assertEquals(6950, usd.getSalePrice());
+ assertEquals(7220, usd.getPurchasePrice());
+ assertEquals(7380, usd.getSalePrice());
- assertEquals(7400, eur.getPurchasePrice());
- assertEquals(8100, eur.getSalePrice());
+ assertEquals(7570, eur.getPurchasePrice());
+ assertEquals(8310, eur.getSalePrice());
}
diff --git a/src/test/resources/py/com/volpe/cotizacion/gatherer/gnb_data.json b/src/test/resources/py/com/volpe/cotizacion/gatherer/gnb_data.json
index 3267c93..30de313 100644
--- a/src/test/resources/py/com/volpe/cotizacion/gatherer/gnb_data.json
+++ b/src/test/resources/py/com/volpe/cotizacion/gatherer/gnb_data.json
@@ -1,27 +1,28 @@
-[
+{
+ "exchangeRates": [
{
- "currency": {
- "code": "USD",
- "description": "DOLAR ESTADOUNIDENSE"
- },
- "electronicBuyPrice": 6785,
- "electronicSellPrice": 6940,
- "cashBuyPrice": 6730,
- "cashSellPrice": 6950,
- "checkBuyPrice": 6770,
- "checkSellPrice": 6950
+ "currencyCode": "USD",
+ "electronicSellPrice": "7350.00",
+ "electronicBuyPrice": "7250.00",
+ "currencyDesc": "DOLAR AMERICANO",
+ "currencyAbbreviation": "DOLAR",
+ "cashBuyPrice": "7220.00",
+ "checkSellPrice": "",
+ "checkBuyPrice": "",
+ "cashSellPrice": "7380.00",
+ "order": 1
},
{
- "currency": {
- "code": "EUR",
- "description": "EURO"
- },
- "electronicBuyPrice": 7510,
- "electronicSellPrice": 7960,
- "cashBuyPrice": 7400,
- "cashSellPrice": 8100,
- "checkBuyPrice": 7480,
- "checkSellPrice": 8000
+ "currencyCode": "EUR",
+ "electronicSellPrice": "8160.00",
+ "electronicBuyPrice": "7720.00",
+ "currencyDesc": "EUR",
+ "currencyAbbreviation": "EUROS",
+ "cashBuyPrice": "7570.00",
+ "checkSellPrice": "",
+ "checkBuyPrice": "",
+ "cashSellPrice": "8310.00",
+ "order": 2
}
]
-
\ No newline at end of file
+}