diff --git a/src/main/java/py/com/volpe/cotizacion/domain/QueryResponseDetail.java b/src/main/java/py/com/volpe/cotizacion/domain/QueryResponseDetail.java index 339783f..f00b6d9 100644 --- a/src/main/java/py/com/volpe/cotizacion/domain/QueryResponseDetail.java +++ b/src/main/java/py/com/volpe/cotizacion/domain/QueryResponseDetail.java @@ -25,11 +25,11 @@ public class QueryResponseDetail { private long purchasePrice; private long salePrice; /** - * >1 if is increasing + * >1 if it is increasing */ private long purchaseTrend; /** - * >1 if is increasing + * >1 if it is increasing */ private long saleTrend; private String isoCode; diff --git a/src/main/java/py/com/volpe/cotizacion/gatherer/Alberdi.java b/src/main/java/py/com/volpe/cotizacion/gatherer/Alberdi.java index 9515223..ae3b988 100644 --- a/src/main/java/py/com/volpe/cotizacion/gatherer/Alberdi.java +++ b/src/main/java/py/com/volpe/cotizacion/gatherer/Alberdi.java @@ -29,7 +29,7 @@ public class Alberdi implements Gatherer { private static final String CODE = "ALBERDI_2"; - private static final String WS_URL = "http://www.cambiosalberdi.com/ws/getTablero.json.php"; + private static final String WS_URL = "https://www.cambiosalberdi.com/ws/getTablero.json.php"; private final HTTPHelper helper; @Override diff --git a/src/main/java/py/com/volpe/cotizacion/gatherer/Amambay.java b/src/main/java/py/com/volpe/cotizacion/gatherer/Amambay.java index 83570cb..ea8df98 100644 --- a/src/main/java/py/com/volpe/cotizacion/gatherer/Amambay.java +++ b/src/main/java/py/com/volpe/cotizacion/gatherer/Amambay.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Map; /** * @author Arturo Volpe @@ -41,7 +42,12 @@ public List doQuery(Place p, List branches) { QueryResponse qr = new QueryResponse(p); - BranchExchangeData data = buildMapper().readValue(httpHelper.doGet(URL_CHANGE), BranchExchangeData.class); + BranchExchangeData data = buildMapper().readValue(httpHelper.doGet( + URL_CHANGE, + 5000, + Map.of(), + true + ), BranchExchangeData.class); data.getCurrencyExchanges().forEach(exchange -> qr.addDetail(exchange.map())); diff --git a/src/main/java/py/com/volpe/cotizacion/gatherer/MaxiCambios.java b/src/main/java/py/com/volpe/cotizacion/gatherer/MaxiCambios.java index a2a6ebf..52b4551 100644 --- a/src/main/java/py/com/volpe/cotizacion/gatherer/MaxiCambios.java +++ b/src/main/java/py/com/volpe/cotizacion/gatherer/MaxiCambios.java @@ -15,6 +15,7 @@ import py.com.volpe.cotizacion.domain.QueryResponseDetail; import javax.transaction.Transactional; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -63,9 +64,9 @@ private String getURLForBranch(PlaceBranch branch) { private QueryResponseDetail mapToDetail(ExchangeData detail, String iso) { QueryResponseDetail qrd = new QueryResponseDetail(); qrd.setIsoCode(iso); - qrd.setSalePrice(detail.getVenta()); + qrd.setSalePrice(detail.getVenta().longValue()); qrd.setSaleTrend("up.png".equals(detail.getVentaTendencia()) ? 1 : -1); - qrd.setPurchasePrice(detail.getCompra()); + qrd.setPurchasePrice(detail.getCompra().longValue()); qrd.setPurchaseTrend("up.png".equals(detail.getCompraTendencia()) ? 1 : -1); return qrd; } @@ -177,14 +178,17 @@ private static class ExchangeData { private String pais; private String nombre; private String bandera; - private long compra; + private BigDecimal compra; private String compraTendencia; - private long venta; + private BigDecimal venta; private String ventaTendencia; } - private static Long parse(String value) { - return Long.parseLong(value.replaceAll("\\..*", "")); + private static BigDecimal parse(String value) { + return new BigDecimal(value + .replaceAll("\\..*", "") + .replaceAll(",", ".") + ); } } diff --git a/src/test/java/py/com/volpe/cotizacion/gatherer/MaxiCambiosTest.java b/src/test/java/py/com/volpe/cotizacion/gatherer/MaxiCambiosTest.java index 20653e5..958b537 100644 --- a/src/test/java/py/com/volpe/cotizacion/gatherer/MaxiCambiosTest.java +++ b/src/test/java/py/com/volpe/cotizacion/gatherer/MaxiCambiosTest.java @@ -27,7 +27,7 @@ * @since 1/5/20 */ @ExtendWith(MockitoExtension.class) -public class MaxiCambiosTest { +class MaxiCambiosTest { @Mock private HTTPHelper wsHelper; @@ -36,7 +36,7 @@ public class MaxiCambiosTest { private MaxiCambios maxi; @Test - public void testFetchAsu() throws Exception { + void testFetchAsu() throws Exception { String data = IOUtils.toString(getClass().getResourceAsStream("maxi_asu.xml"), StandardCharsets.UTF_8); @@ -51,20 +51,20 @@ public void testFetchAsu() throws Exception { QueryResponse coti = result.get(0); - assertEquals(17, coti.getDetails().size()); + assertEquals(15, coti.getDetails().size()); QueryResponseDetail usd = coti.getDetails() .stream() .filter(d -> d.getIsoCode().equals("USD")) .findFirst().orElseThrow(() -> new AppException(500, "Data not found")); - assertEquals(6300, usd.getPurchasePrice()); - assertEquals(6380, usd.getSalePrice()); + assertEquals(7130, usd.getPurchasePrice()); + assertEquals(7280, usd.getSalePrice()); } @Test - public void testFetchCDE() throws Exception { + void testFetchCDE() throws Exception { String data = IOUtils.toString(getClass().getResourceAsStream("maxi_cde.xml"), StandardCharsets.UTF_8); @@ -86,8 +86,8 @@ public void testFetchCDE() throws Exception { .filter(d -> d.getIsoCode().equals("USD")) .findFirst().orElseThrow(() -> new AppException(500, "Data not found")); - assertEquals(6310, usd.getPurchasePrice()); - assertEquals(6380, usd.getSalePrice()); + assertEquals(7210, usd.getPurchasePrice()); + assertEquals(7270, usd.getSalePrice()); } } diff --git a/src/test/resources/py/com/volpe/cotizacion/gatherer/maxi_asu.xml b/src/test/resources/py/com/volpe/cotizacion/gatherer/maxi_asu.xml index 02bb397..b5adc56 100644 --- a/src/test/resources/py/com/volpe/cotizacion/gatherer/maxi_asu.xml +++ b/src/test/resources/py/com/volpe/cotizacion/gatherer/maxi_asu.xml @@ -1,25 +1,24 @@ - EFECTIVOEEUUDólarus.png6300up.png6380up.png - EFECTIVOArgentinaPeso ar.png70down.png90up.png - EFECTIVOBrasilRealbr.png1515down.png1600up.png - EFECTIVOUruguayPeso ur.png150down.png240up.png - EFECTIVOEUEuroeu.png6850down.png7100up.png - EFECTIVOGran BretańaLibragbp.png8000down.png8900up.png - EFECTIVOJaponYenyen.png50down.png63up.png - EFECTIVOChilePeso ch.png5down.png11up.png - EFECTIVOSueciaCorona cs.png200down.png500up.png - EFECTIVODinamarcaCorona cd.png200down.png950up.png - EFECTIVOCanadáDólar dc.png4500down.png5500up.png - EFECTIVOAustraliaDólar da.png4000down.png5500up.png - EFECTIVOSuizaFranco fs.png5500down.png6600up.png - EFECTIVOMejicoPesopm.png350down.png450up.png - EFECTIVOPeruanoSol sp.png1950down.png2500up.png - EFECTIVOBoliviaPeso pb.png850down.png1000up.png - EFECTIVOColombiaPeso pc.png1.00down.png4.00up.png - CH Y TRFEEUUDólarus.png6290up.png6510up.png - CH Y TRFEUEuroeu.png6300up.png7400up.png - CH Y TRFGran BretańaLibragbp.png6500up.png8500up.png - CH Y TRF SuizaFrancofs.pngup.pngup.png - 04/01/2020 - 20:40 - \ No newline at end of file + EFECTIVOEEUUDŰlarus.png7130up.png7280up.png + EFECTIVOArgentinaPeso Argar.png7.20down.png8.20up.png + EFECTIVOBrasilRealbr.png1430down.png1480up.png + EFECTIVOUruguayPeso Uruur.png160down.png250up.png + EFECTIVOEUEuroeu.png7800down.png8100up.png + EFECTIVOGran BretaŇaLibragbp.png8600down.png9950up.png + EFECTIVOJaponYenyen.png35down.png55up.png + EFECTIVOChilePeso Chich.png5down.png10up.png + EFECTIVOSudafricaRand sud.svg250down.png450up.png + EFECTIVOCanadˇDŰlar Canadˇdc.png4000down.png5500up.png + EFECTIVOAustraliaDŰlar Austda.png4600down.png5200up.png + EFECTIVOSuizaFranco fs.png6000down.png8400up.png + EFECTIVOMejicoPeso Mexpm.png400down.png500up.png + EFECTIVOPeruanoSol sp.png1950down.png2200up.png + EFECTIVOBoliviaPeso Bolpb.png300down.png1000up.png + EFECTIVOColombiaPeso Colpc.png1.50down.png3.50up.png + CH Y TRFEEUUDŰlarus.png7130up.png7330up.png + CH Y TRFEUEuroeu.png7500up.png8450up.png + CH Y TRFGran BretaŇaLibragbp.png8600up.png9950up.png + CH Y TRF SuizaFranco fs.pngup.pngup.png + 08/03/2024 - 09:07 + diff --git a/src/test/resources/py/com/volpe/cotizacion/gatherer/maxi_cde.xml b/src/test/resources/py/com/volpe/cotizacion/gatherer/maxi_cde.xml index c58ba5e..b544287 100644 --- a/src/test/resources/py/com/volpe/cotizacion/gatherer/maxi_cde.xml +++ b/src/test/resources/py/com/volpe/cotizacion/gatherer/maxi_cde.xml @@ -1,8 +1,44 @@ - EFECTIVOEEUUDólarus.png63106380 - EFECTIVOArgentinaPeso ar.png7285 - EFECTIVOBrasilRealbr.png15001545 - EFECTIVOEuroEuro eu.png67507175 - 04/01/2020 - 20:40 - \ No newline at end of file + + EFECTIVO + EEUU + DŰlar + us.png + 7210 + up.png + 7270 + up.png + + + EFECTIVO + Argentina + Peso + ar.png + 6,70 + down.png + 7,70 + up.png + + + EFECTIVO + Brasil + Real + br.png + 1430 + down.png + 1465 + up.png + + + EFECTIVO + Euro + Euro + eu.png + 7785 + down.png + 8175 + up.png + + 08/03/2024 - 09:07 +