mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 08:58:48 +00:00
añadidos los ficheros nuevos2
This commit is contained in:
82
src/test/java/com/imprimelibros/erp/skApiClientTest.java
Normal file
82
src/test/java/com/imprimelibros/erp/skApiClientTest.java
Normal file
@ -0,0 +1,82 @@
|
||||
package com.imprimelibros.erp;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import com.imprimelibros.erp.externalApi.skApiClient;
|
||||
|
||||
@SpringBootTest
|
||||
class skApiClientTest {
|
||||
|
||||
@Autowired
|
||||
private skApiClient apiClient;
|
||||
|
||||
@Test
|
||||
void testPrecioCalculadoDevuelveJson() {
|
||||
String resultado = this.test();
|
||||
|
||||
System.out.println("📦 Resultado de la API:");
|
||||
System.out.println(resultado);
|
||||
|
||||
assertNotNull(resultado, "El resultado no debe ser null");
|
||||
assertTrue(resultado.trim().startsWith("{"), "El resultado debe comenzar con { (JSON)");
|
||||
assertTrue(resultado.trim().endsWith("}"), "El resultado debe terminar con } (JSON)");
|
||||
}
|
||||
|
||||
public String test() {
|
||||
|
||||
Map<String, Object> tamanio = Map.of("ancho", 148, "alto", 210);
|
||||
Map<String, Object> interior = Map.of("papelInterior", "3", "gramajeInterior", 90);
|
||||
Map<String, Object> cubierta = Map.of(
|
||||
"tipoCubierta", "tapaBlanda",
|
||||
"papelCubierta", "2",
|
||||
"gramajeCubierta", 300,
|
||||
"carasImpresion", 2,
|
||||
"solapas", 0,
|
||||
"acabado", "1",
|
||||
"cabezada", "WHI",
|
||||
"lomoRedondo", 0);
|
||||
|
||||
// ✅ Corregido: usamos HashMap porque Map.of no permite null
|
||||
Map<String, Object> sobrecubierta = new HashMap<>();
|
||||
sobrecubierta.put("papel", "2");
|
||||
sobrecubierta.put("gramaje", 170);
|
||||
sobrecubierta.put("solapas", 80);
|
||||
sobrecubierta.put("acabado", null);
|
||||
|
||||
Map<String, Object> servicios = Map.of(
|
||||
"retractilado", 0,
|
||||
"retractilado5", 0,
|
||||
"ferro", 0,
|
||||
"ferroDigital", 0,
|
||||
"marcapaginas", 0,
|
||||
"prototipo", 0);
|
||||
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("tirada", List.of(50, 100, 150, 500));
|
||||
body.put("tamanio", tamanio);
|
||||
body.put("tipo", "fresado");
|
||||
body.put("clienteId", 1284);
|
||||
body.put("isColor", 1);
|
||||
body.put("isHq", 0);
|
||||
body.put("paginas", 112);
|
||||
body.put("paginasColor", 80);
|
||||
body.put("paginasCuadernillo", 32);
|
||||
body.put("interior", interior);
|
||||
body.put("cubierta", cubierta);
|
||||
body.put("sobrecubierta", sobrecubierta);
|
||||
body.put("guardas", null);
|
||||
body.put("faja", false);
|
||||
body.put("servicios", servicios);
|
||||
|
||||
return apiClient.getPrice(body);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user