diff --git a/pom.xml b/pom.xml index 6bad6857..48cb5c45 100644 --- a/pom.xml +++ b/pom.xml @@ -6,13 +6,13 @@ 4.0.0 org.opencommercial api - 1.3.17 + 1.4.0 jar org.springframework.boot spring-boot-starter-parent - 3.3.7 + 4.0.1 @@ -23,16 +23,17 @@ 1.6.1 6.17.0 3.17 - 0.12.6 + 0.13.0 1.46 2.14.0 1.4.0 3.0.4 1.39.0 - 8.17.0 + 8.25.1 2.1.4 2.8.9 - 2.2.1 + 2.3.0 + 5.1.0 src/main/java/org/opencommercial/model/**, src/main/java/org/opencommercial/exception/** @@ -64,15 +65,11 @@ lombok provided - - org.mockito - mockito-core - com.querydsl querydsl-apt - ${querydsl.version} provided + ${querydsl.version} jakarta @@ -129,7 +126,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc org.springframework.boot @@ -139,6 +136,10 @@ org.springframework.boot spring-boot-starter-data-jpa + + org.springframework.boot + spring-boot-starter-cache + org.springframework.boot spring-boot-starter-mail @@ -167,6 +168,11 @@ spring-boot-starter-test test + + org.springframework.boot + spring-boot-test-autoconfigure + test + org.springframework.boot spring-boot-testcontainers @@ -174,12 +180,32 @@ org.testcontainers - junit-jupiter + testcontainers-junit-jupiter test org.testcontainers - mysql + testcontainers-mysql + test + + + org.springframework.boot + spring-boot-starter-data-jpa-test + test + + + org.springframework.boot + spring-boot-starter-webmvc-test + test + + + org.springframework.boot + spring-boot-starter-restclient-test + test + + + org.springframework.boot + spring-boot-starter-cache-test test diff --git a/src/main/java/org/opencommercial/App.java b/src/main/java/org/opencommercial/App.java index 2010ecd6..782ab118 100644 --- a/src/main/java/org/opencommercial/App.java +++ b/src/main/java/org/opencommercial/App.java @@ -2,14 +2,12 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cache.annotation.EnableCaching; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableScheduling @EnableAsync -@EnableCaching public class App { public static void main(String[] args) { diff --git a/src/main/java/org/opencommercial/config/AppConfig.java b/src/main/java/org/opencommercial/config/AppConfig.java index a4ae8452..29446381 100644 --- a/src/main/java/org/opencommercial/config/AppConfig.java +++ b/src/main/java/org/opencommercial/config/AppConfig.java @@ -1,12 +1,12 @@ package org.opencommercial.config; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.module.SimpleModule; import org.modelmapper.ModelMapper; import org.modelmapper.PropertyMap; +import org.opencommercial.model.Cliente; +import org.opencommercial.model.Ubicacion; +import org.opencommercial.model.dto.ClienteDTO; +import org.opencommercial.model.dto.UbicacionDTO; +import org.opencommercial.service.AfipWebServiceSOAPClient; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -17,41 +17,39 @@ import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; -import org.opencommercial.model.Cliente; -import org.opencommercial.model.Ubicacion; -import org.opencommercial.model.dto.ClienteDTO; -import org.opencommercial.model.dto.UbicacionDTO; -import org.opencommercial.service.AfipWebServiceSOAPClient; +import tools.jackson.core.JacksonException; +import tools.jackson.core.JsonGenerator; +import tools.jackson.databind.SerializationContext; +import tools.jackson.databind.ValueSerializer; +import tools.jackson.databind.module.SimpleModule; -import java.io.IOException; import java.time.Clock; @Configuration public class AppConfig { @Bean - public Module springDataPageModule() { + public SimpleModule springDataPageModule() { return new SimpleModule() - .addSerializer( - Page.class, - new JsonSerializer() { - @Override - public void serialize(Page value, JsonGenerator gen, SerializerProvider serializers) - throws IOException { - gen.writeStartObject(); - gen.writeNumberField("totalElements", value.getTotalElements()); - gen.writeNumberField("totalPages", value.getTotalPages()); - gen.writeNumberField("number", value.getNumber()); - gen.writeNumberField("numberOfElements", value.getNumberOfElements()); - gen.writeNumberField("size", value.getSize()); - gen.writeBooleanField("first", value.isFirst()); - gen.writeBooleanField("last", value.isLast()); - gen.writeFieldName("content"); - serializers.defaultSerializeValue(value.getContent(), gen); - gen.writeObjectField("sort", value.getSort()); - gen.writeEndObject(); - } - }); + .addSerializer( + Page.class, + new ValueSerializer() { + + @Override + public void serialize(Page value, JsonGenerator gen, SerializationContext sc) throws JacksonException { + gen.writeStartObject(); + gen.writeNumberProperty("totalElements", value.getTotalElements()); + gen.writeNumberProperty("totalPages", value.getTotalPages()); + gen.writeNumberProperty("number", value.getNumber()); + gen.writeNumberProperty("numberOfElements", value.getNumberOfElements()); + gen.writeNumberProperty("size", value.getSize()); + gen.writeBooleanProperty("first", value.isFirst()); + gen.writeBooleanProperty("last", value.isLast()); + sc.defaultSerializeProperty("content", value.getContent(), gen); + gen.writePOJOProperty("sort", value.getSort()); + gen.writeEndObject(); + } + }); } @Bean diff --git a/src/main/java/org/opencommercial/config/CacheConfig.java b/src/main/java/org/opencommercial/config/CacheConfig.java new file mode 100644 index 00000000..ca4682aa --- /dev/null +++ b/src/main/java/org/opencommercial/config/CacheConfig.java @@ -0,0 +1,17 @@ +package org.opencommercial.config; + +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.concurrent.ConcurrentMapCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableCaching +public class CacheConfig { + + @Bean + public CacheManager cacheManager() { + return new ConcurrentMapCacheManager(); + } +} diff --git a/src/main/java/org/opencommercial/config/SecurityJsonViewControllerAdvice.java b/src/main/java/org/opencommercial/config/SecurityJsonViewControllerAdvice.java index 7f1a60c2..934a49b1 100644 --- a/src/main/java/org/opencommercial/config/SecurityJsonViewControllerAdvice.java +++ b/src/main/java/org/opencommercial/config/SecurityJsonViewControllerAdvice.java @@ -1,20 +1,28 @@ package org.opencommercial.config; +import com.fasterxml.jackson.annotation.JsonView; +import jakarta.servlet.http.HttpServletRequest; +import org.jspecify.annotations.NonNull; +import org.opencommercial.model.Rol; +import org.opencommercial.service.AuthService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; -import org.springframework.http.converter.json.MappingJacksonValue; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.servlet.mvc.method.annotation.AbstractMappingJacksonResponseBodyAdvice; -import org.opencommercial.model.Rol; -import org.opencommercial.service.AuthService; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; import java.util.List; +import java.util.Map; +import java.util.Optional; @RestControllerAdvice -public class SecurityJsonViewControllerAdvice extends AbstractMappingJacksonResponseBodyAdvice { +public class SecurityJsonViewControllerAdvice implements ResponseBodyAdvice { private final AuthService authService; private static final String AUTHORIZATION_HEADER = "Authorization"; @@ -26,32 +34,79 @@ public SecurityJsonViewControllerAdvice(AuthService authService) { } @Override - protected void beforeBodyWriteInternal( - MappingJacksonValue mappingJacksonValue, - MediaType mediaType, - MethodParameter methodParameter, - ServerHttpRequest serverHttpRequest, - ServerHttpResponse serverHttpResponse) { - - var headers = serverHttpRequest.getHeaders().get(AUTHORIZATION_HEADER); + public boolean supports(@NonNull MethodParameter returnType, + @NonNull Class> converterType) { + return converterType == JacksonJsonHttpMessageConverter.class; + } + + @Override + public Map<@NonNull String, @NonNull Object> determineWriteHints( + Object body, + @NonNull MethodParameter returnType, + @NonNull MediaType selectedContentType, + @NonNull Class> selectedConverterType) { + + if (body == null) { + return null; + } + + var httpRequest = this.getCurrentHttpRequest(); + if (httpRequest == null) { + return null; + } + + var viewClass = this.determineViewClass(httpRequest); + if (viewClass != null) { + return Map.of(JsonView.class.getName(), viewClass); + } + + return null; + } + + @Override + public Object beforeBodyWrite( + Object body, + @NonNull MethodParameter returnType, + @NonNull MediaType selectedContentType, + @NonNull Class> selectedConverterType, + @NonNull ServerHttpRequest request, + @NonNull ServerHttpResponse response) { + return body; + } + + private Class determineViewClass(HttpServletRequest httpServletRequest) { + var headers = httpServletRequest.getHeader(AUTHORIZATION_HEADER); if (headers != null && !headers.isEmpty()) { - var claims = authService.getClaimsDelToken(headers.get(0)); - var rolesDelUsuario = claims.get(CLAIM_ROLES, List.class); - if (rolesDelUsuario != null && !rolesDelUsuario.isEmpty()) { - if (rolesDelUsuario.contains(Rol.ADMINISTRADOR.name())) { - mappingJacksonValue.setSerializationView(Views.Administrador.class); - } else if (rolesDelUsuario.contains(Rol.ENCARGADO.name())) { - mappingJacksonValue.setSerializationView(Views.Encargado.class); - } else if (rolesDelUsuario.contains(Rol.VENDEDOR.name())) { - mappingJacksonValue.setSerializationView(Views.Vendedor.class); - } else if (rolesDelUsuario.contains(Rol.VIAJANTE.name())) { - mappingJacksonValue.setSerializationView(Views.Viajante.class); - } else if (rolesDelUsuario.contains(Rol.COMPRADOR.name())) { - mappingJacksonValue.setSerializationView(Views.Comprador.class); + try { + var claims = authService.getClaimsDelToken(headers); + var rolesDelUsuario = claims.get(CLAIM_ROLES, List.class); + if (rolesDelUsuario != null && !rolesDelUsuario.isEmpty()) { + if (rolesDelUsuario.contains(Rol.ADMINISTRADOR.name())) { + return Views.Administrador.class; + } else if (rolesDelUsuario.contains(Rol.ENCARGADO.name())) { + return Views.Encargado.class; + } else if (rolesDelUsuario.contains(Rol.VENDEDOR.name())) { + return Views.Vendedor.class; + } else if (rolesDelUsuario.contains(Rol.VIAJANTE.name())) { + return Views.Viajante.class; + } else if (rolesDelUsuario.contains(Rol.COMPRADOR.name())) { + return Views.Comprador.class; + } } + } catch (Exception ex) { + return Views.Comprador.class; } - } else { - mappingJacksonValue.setSerializationView(Views.Comprador.class); } + + return Views.Comprador.class; + } + + private HttpServletRequest getCurrentHttpRequest() { + return Optional.ofNullable(RequestContextHolder.getRequestAttributes()) + .filter(ServletRequestAttributes.class::isInstance) + .map(ServletRequestAttributes.class::cast) + .map(ServletRequestAttributes::getRequest) + .orElse(null); } } + diff --git a/src/main/java/org/opencommercial/controller/FacturaController.java b/src/main/java/org/opencommercial/controller/FacturaController.java index a2efb8a7..ba4f60cc 100644 --- a/src/main/java/org/opencommercial/controller/FacturaController.java +++ b/src/main/java/org/opencommercial/controller/FacturaController.java @@ -109,17 +109,14 @@ public List guardarFacturaCompra(@RequestBody NuevaFacturaCompraD FacturaCompra fc = new FacturaCompra(); fc.setFecha(nuevaCompraCompraDTO.getFecha()); fc.setTipoComprobante(nuevaCompraCompraDTO.getTipoDeComprobante()); - fc.setNumSerie( - nuevaCompraCompraDTO.getNumSerie() != null ? nuevaCompraCompraDTO.getNumSerie() : 0L); - fc.setNumFactura( - nuevaCompraCompraDTO.getNumFactura() != null ? nuevaCompraCompraDTO.getNumFactura() : 0L); + fc.setNumSerie(nuevaCompraCompraDTO.getNumSerie() != null ? nuevaCompraCompraDTO.getNumSerie() : 0L); + fc.setNumFactura(nuevaCompraCompraDTO.getNumFactura() != null ? nuevaCompraCompraDTO.getNumFactura() : 0L); fc.setFechaVencimiento(nuevaCompraCompraDTO.getFechaVencimiento()); fc.setFechaAlta(LocalDateTime.now()); - fc.setRenglones( - facturaService.calcularRenglones( - nuevaCompraCompraDTO.getTipoDeComprobante(), - Movimiento.COMPRA, - nuevaCompraCompraDTO.getRenglones())); + fc.setRenglones(facturaService.calcularRenglones( + nuevaCompraCompraDTO.getTipoDeComprobante(), + Movimiento.COMPRA, + nuevaCompraCompraDTO.getRenglones())); fc.setRecargoPorcentaje( nuevaCompraCompraDTO.getRecargoPorcentaje() != null ? nuevaCompraCompraDTO.getRecargoPorcentaje() @@ -133,12 +130,9 @@ public List guardarFacturaCompra(@RequestBody NuevaFacturaCompraD ? nuevaCompraCompraDTO.getObservaciones() : ""); fc.setSucursal(sucursalService.getSucursalPorId(nuevaCompraCompraDTO.getIdSucursal())); - fc.setProveedor( - proveedorService.getProveedorNoEliminadoPorId(nuevaCompraCompraDTO.getIdProveedor())); + fc.setProveedor(proveedorService.getProveedorNoEliminadoPorId(nuevaCompraCompraDTO.getIdProveedor())); if (nuevaCompraCompraDTO.getIdTransportista() != null) { - fc.setTransportista( - transportistaService.getTransportistaNoEliminadoPorId( - nuevaCompraCompraDTO.getIdTransportista())); + fc.setTransportista(transportistaService.getTransportistaNoEliminadoPorId(nuevaCompraCompraDTO.getIdTransportista())); } Claims claims = authService.getClaimsDelToken(authorizationHeader); fc.setUsuario(usuarioService.getUsuarioNoEliminadoPorId(claims.get(CLAIM_ID_USUARIO, Long.class))); @@ -154,7 +148,7 @@ public Page buscarFacturaCompra(@RequestBody BusquedaFacturaCompr } @GetMapping("/api/v1/facturas/compras/tipos/sucursales/{idSucursal}/proveedores/{idProveedor}") - @AccesoRolesPermitidos({Rol.ADMINISTRADOR, Rol.ENCARGADO, Rol.VENDEDOR}) //remove VENDEDOR + @AccesoRolesPermitidos({Rol.ADMINISTRADOR, Rol.ENCARGADO, Rol.VENDEDOR}) public TipoDeComprobante[] getTipoFacturaCompra(@PathVariable long idSucursal, @PathVariable long idProveedor) { return facturaCompraService.getTiposDeComprobanteCompra( diff --git a/src/main/java/org/opencommercial/model/dto/NuevoRenglonFacturaDTO.java b/src/main/java/org/opencommercial/model/dto/NuevoRenglonFacturaDTO.java index 652a85dc..5b146080 100644 --- a/src/main/java/org/opencommercial/model/dto/NuevoRenglonFacturaDTO.java +++ b/src/main/java/org/opencommercial/model/dto/NuevoRenglonFacturaDTO.java @@ -1,14 +1,18 @@ package org.opencommercial.model.dto; +import jakarta.validation.constraints.Positive; +import jakarta.validation.constraints.PositiveOrZero; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; -import jakarta.validation.constraints.Positive; -import jakarta.validation.constraints.PositiveOrZero; import java.math.BigDecimal; @Data @Builder +@AllArgsConstructor +@NoArgsConstructor public class NuevoRenglonFacturaDTO { private long idProducto; diff --git a/src/main/java/org/opencommercial/service/NotaServiceImpl.java b/src/main/java/org/opencommercial/service/NotaServiceImpl.java index 469534dc..0b33355a 100644 --- a/src/main/java/org/opencommercial/service/NotaServiceImpl.java +++ b/src/main/java/org/opencommercial/service/NotaServiceImpl.java @@ -699,8 +699,7 @@ public NotaCredito guardarNotaCredito(NotaCredito notaCredito) { public NotaCredito calcularNotaCreditoConFactura(NuevaNotaCreditoDeFacturaDTO nuevaNotaCreditoDeFacturaDTO, Usuario usuario) { NotaCredito notaCreditoNueva = new NotaCredito(); - Factura factura = - facturaService.getFacturaNoEliminadaPorId(nuevaNotaCreditoDeFacturaDTO.getIdFactura()); + Factura factura = facturaService.getFacturaNoEliminadaPorId(nuevaNotaCreditoDeFacturaDTO.getIdFactura()); if (Arrays.asList(nuevaNotaCreditoDeFacturaDTO.getCantidades()).contains(null) || Arrays.asList(nuevaNotaCreditoDeFacturaDTO.getIdsRenglonesFactura()).contains(null)) { throw new BusinessServiceException( @@ -734,9 +733,8 @@ public NotaCredito calcularNotaCreditoConFactura(NuevaNotaCreditoDeFacturaDTO nu notaCreditoNueva.setRecargoPorcentaje(factura.getRecargoPorcentaje()); notaCreditoNueva.setRecargoNeto( notaService.calcularRecargoNetoCredito( - notaCreditoNueva.getSubTotal(), notaCreditoNueva.getRecargoPorcentaje())); - notaCreditoNueva.setTipoComprobante( - notaService.getTipoDeNotaCreditoSegunFactura(factura.getTipoComprobante())); + notaCreditoNueva.getSubTotal(), notaCreditoNueva.getRecargoPorcentaje())); + notaCreditoNueva.setTipoComprobante(notaService.getTipoDeNotaCreditoSegunFactura(factura.getTipoComprobante())); notaCreditoNueva.setIva105Neto( notaService.calcularIVANetoCredito( notaService.getTipoDeNotaCreditoSegunFactura(factura.getTipoComprobante()), diff --git a/src/main/java/org/opencommercial/service/ProductoServiceImpl.java b/src/main/java/org/opencommercial/service/ProductoServiceImpl.java index 20f00122..134e385e 100644 --- a/src/main/java/org/opencommercial/service/ProductoServiceImpl.java +++ b/src/main/java/org/opencommercial/service/ProductoServiceImpl.java @@ -873,7 +873,6 @@ public void eliminarCantidadesDeSucursal(Sucursal sucursal) { } @Override - @Transactional public String subirImagenProducto(long idProducto, byte[] imagen) { if (imagen.length > TAMANIO_MAXIMO_IMAGEN) throw new BusinessServiceException( diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index af89de2a..8e25ee76 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -32,9 +32,12 @@ spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.Ph #logging.file.name=log/api.log logging.level.root=INFO +logging.level.org.hibernate=WARN server.compression.enabled=true server.compression.mime-types=application/json,application/pdf,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet #server.compression.min-response-size=2048 spring.web.resources.add-mappings=false +spring.threads.virtual.enabled=true +spring.jackson.deserialization.fail-on-null-for-primitives=false diff --git a/src/test/java/org/opencommercial/controller/CarritoCompraControllerTest.java b/src/test/java/org/opencommercial/controller/CarritoCompraControllerTest.java index aa21052c..e81e542f 100644 --- a/src/test/java/org/opencommercial/controller/CarritoCompraControllerTest.java +++ b/src/test/java/org/opencommercial/controller/CarritoCompraControllerTest.java @@ -3,15 +3,15 @@ import io.jsonwebtoken.impl.DefaultClaims; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.MessageSource; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.opencommercial.model.dto.ProductoFaltanteDTO; import org.opencommercial.service.AuthServiceImpl; import org.opencommercial.service.CarritoCompraServiceImpl; import org.opencommercial.service.ProductoServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.ArrayList; import java.util.List; @@ -24,10 +24,10 @@ @ContextConfiguration(classes = {CarritoCompraController.class, MessageSource.class}) class CarritoCompraControllerTest { - @MockBean CarritoCompraServiceImpl carritoCompraService; - @MockBean ProductoServiceImpl productoService; - @MockBean AuthServiceImpl authService; - @MockBean MessageSource messageSource; + @MockitoBean CarritoCompraServiceImpl carritoCompraService; + @MockitoBean ProductoServiceImpl productoService; + @MockitoBean AuthServiceImpl authService; + @MockitoBean MessageSource messageSource; @Autowired CarritoCompraController carritoCompraController; diff --git a/src/test/java/org/opencommercial/controller/CuentaCorrienteControllerTest.java b/src/test/java/org/opencommercial/controller/CuentaCorrienteControllerTest.java index 78756b17..c7b686f2 100644 --- a/src/test/java/org/opencommercial/controller/CuentaCorrienteControllerTest.java +++ b/src/test/java/org/opencommercial/controller/CuentaCorrienteControllerTest.java @@ -10,9 +10,9 @@ import org.opencommercial.service.ProveedorService; import org.opencommercial.util.FormatoReporte; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.List; @@ -25,11 +25,11 @@ @ContextConfiguration(classes = {CuentaCorrienteController.class}) class CuentaCorrienteControllerTest { - @MockBean CuentaCorrienteService cuentaCorrienteService; - @MockBean ProveedorService proveedorService; - @MockBean ClienteService clienteService; - @MockBean AuthService authService; - @MockBean MessageSource messageSource; + @MockitoBean CuentaCorrienteService cuentaCorrienteService; + @MockitoBean ProveedorService proveedorService; + @MockitoBean ClienteService clienteService; + @MockitoBean AuthService authService; + @MockitoBean MessageSource messageSource; @Autowired CuentaCorrienteController cuentaCorrienteController; diff --git a/src/test/java/org/opencommercial/controller/FacturaControllerTest.java b/src/test/java/org/opencommercial/controller/FacturaControllerTest.java index 21a5a48d..ed680fcc 100644 --- a/src/test/java/org/opencommercial/controller/FacturaControllerTest.java +++ b/src/test/java/org/opencommercial/controller/FacturaControllerTest.java @@ -13,11 +13,11 @@ import org.opencommercial.model.dto.NuevosResultadosComprobanteDTO; import org.opencommercial.service.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -34,18 +34,18 @@ @ContextConfiguration(classes = {FacturaController.class, MessageSource.class}) class FacturaControllerTest { - @MockBean SucursalServiceImpl sucursalService; - @MockBean FacturaServiceImpl facturaService; - @MockBean FacturaCompraServiceImpl facturaCompraService; - @MockBean ProveedorServiceImpl proveedorService; - @MockBean UsuarioServiceImpl usuarioService; - @MockBean TransportistaServiceImpl transportistaService; - @MockBean FacturaVentaServiceImpl facturaVentaService; - @MockBean ReciboServiceImpl reciboService; - @MockBean AuthServiceImpl authService; - @MockBean ClienteServiceImpl clienteService; - @MockBean PedidoServiceImpl pedidoService; - @MockBean MessageSource messageSource; + @MockitoBean SucursalServiceImpl sucursalService; + @MockitoBean FacturaServiceImpl facturaService; + @MockitoBean FacturaCompraServiceImpl facturaCompraService; + @MockitoBean ProveedorServiceImpl proveedorService; + @MockitoBean UsuarioServiceImpl usuarioService; + @MockitoBean TransportistaServiceImpl transportistaService; + @MockitoBean FacturaVentaServiceImpl facturaVentaService; + @MockitoBean ReciboServiceImpl reciboService; + @MockitoBean AuthServiceImpl authService; + @MockitoBean ClienteServiceImpl clienteService; + @MockitoBean PedidoServiceImpl pedidoService; + @MockitoBean MessageSource messageSource; @Autowired FacturaController facturaController; diff --git a/src/test/java/org/opencommercial/controller/NotaControllerTest.java b/src/test/java/org/opencommercial/controller/NotaControllerTest.java index a4c147db..991fc8c7 100644 --- a/src/test/java/org/opencommercial/controller/NotaControllerTest.java +++ b/src/test/java/org/opencommercial/controller/NotaControllerTest.java @@ -10,9 +10,9 @@ import org.opencommercial.model.dto.NuevaNotaDebitoSinReciboDTO; import org.opencommercial.service.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.List; @@ -25,12 +25,12 @@ @ContextConfiguration(classes = {NotaController.class, MessageSource.class}) class NotaControllerTest { - @MockBean NotaService notaService; - @MockBean ReciboService reciboService; - @MockBean SucursalService sucursalService; - @MockBean UsuarioService usuarioService; - @MockBean AuthService authService; - @MockBean MessageSource messageSource; + @MockitoBean NotaService notaService; + @MockitoBean ReciboService reciboService; + @MockitoBean SucursalService sucursalService; + @MockitoBean UsuarioService usuarioService; + @MockitoBean AuthService authService; + @MockitoBean MessageSource messageSource; @Autowired NotaController notaController; diff --git a/src/test/java/org/opencommercial/controller/PedidoControllerTest.java b/src/test/java/org/opencommercial/controller/PedidoControllerTest.java index 81c2c1da..b371c50d 100644 --- a/src/test/java/org/opencommercial/controller/PedidoControllerTest.java +++ b/src/test/java/org/opencommercial/controller/PedidoControllerTest.java @@ -9,8 +9,8 @@ import org.opencommercial.model.dto.NuevosResultadosComprobanteDTO; import org.opencommercial.service.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -24,12 +24,12 @@ @ContextConfiguration(classes = {PedidoController.class}) class PedidoControllerTest { - @MockBean PedidoServiceImpl pedidoService; - @MockBean UsuarioServiceImpl usuarioService; - @MockBean SucursalServiceImpl sucursalService; - @MockBean ClienteServiceImpl clienteService; - @MockBean ReciboServiceImpl reciboService; - @MockBean AuthServiceImpl authService; + @MockitoBean PedidoServiceImpl pedidoService; + @MockitoBean UsuarioServiceImpl usuarioService; + @MockitoBean SucursalServiceImpl sucursalService; + @MockitoBean ClienteServiceImpl clienteService; + @MockitoBean ReciboServiceImpl reciboService; + @MockitoBean AuthServiceImpl authService; @Autowired PedidoController pedidoController; diff --git a/src/test/java/org/opencommercial/controller/ProductoControllerTest.java b/src/test/java/org/opencommercial/controller/ProductoControllerTest.java index 1894f180..735b7b64 100644 --- a/src/test/java/org/opencommercial/controller/ProductoControllerTest.java +++ b/src/test/java/org/opencommercial/controller/ProductoControllerTest.java @@ -11,8 +11,8 @@ import org.opencommercial.model.embeddable.PrecioProductoEmbeddable; import org.opencommercial.service.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -26,14 +26,14 @@ @ContextConfiguration(classes = {ProductoController.class}) class ProductoControllerTest { - @MockBean ProductoServiceImpl productoService; - @MockBean MedidaServiceImpl medidaService; - @MockBean RubroServiceImpl rubroService; - @MockBean ProveedorServiceImpl proveedorService; - @MockBean SucursalServiceImpl sucursalService; - @MockBean AuthServiceImpl authService; - @MockBean UsuarioServiceImpl usuarioService; - @MockBean ModelMapper modelMapper; + @MockitoBean ProductoServiceImpl productoService; + @MockitoBean MedidaServiceImpl medidaService; + @MockitoBean RubroServiceImpl rubroService; + @MockitoBean ProveedorServiceImpl proveedorService; + @MockitoBean SucursalServiceImpl sucursalService; + @MockitoBean AuthServiceImpl authService; + @MockitoBean UsuarioServiceImpl usuarioService; + @MockitoBean ModelMapper modelMapper; @Autowired ProductoController productoController; diff --git a/src/test/java/org/opencommercial/controller/TransportistaControllerTest.java b/src/test/java/org/opencommercial/controller/TransportistaControllerTest.java index 2203c6b6..6092e7f6 100644 --- a/src/test/java/org/opencommercial/controller/TransportistaControllerTest.java +++ b/src/test/java/org/opencommercial/controller/TransportistaControllerTest.java @@ -7,8 +7,8 @@ import org.opencommercial.service.TransportistaServiceImpl; import org.opencommercial.service.UbicacionServiceImpl; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.ArrayList; @@ -21,9 +21,9 @@ @ContextConfiguration(classes = {TransportistaController.class}) class TransportistaControllerTest { - @MockBean TransportistaServiceImpl transportistaService; - @MockBean UbicacionServiceImpl ubicacionService; - @MockBean ModelMapper modelMapper; + @MockitoBean TransportistaServiceImpl transportistaService; + @MockitoBean UbicacionServiceImpl ubicacionService; + @MockitoBean ModelMapper modelMapper; @Autowired TransportistaController transportistaController; diff --git a/src/test/java/org/opencommercial/controller/TraspasoControllerTest.java b/src/test/java/org/opencommercial/controller/TraspasoControllerTest.java index c87d6114..8647a030 100644 --- a/src/test/java/org/opencommercial/controller/TraspasoControllerTest.java +++ b/src/test/java/org/opencommercial/controller/TraspasoControllerTest.java @@ -3,15 +3,15 @@ import io.jsonwebtoken.impl.DefaultClaims; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.opencommercial.model.Traspaso; import org.opencommercial.model.criteria.BusquedaTraspasoCriteria; import org.opencommercial.model.dto.NuevoTraspasoDTO; import org.opencommercial.service.AuthServiceImpl; import org.opencommercial.service.TraspasoServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.List; import java.util.Map; @@ -23,8 +23,8 @@ @ContextConfiguration(classes = {TraspasoController.class}) class TraspasoControllerTest { - @MockBean TraspasoServiceImpl traspasoService; - @MockBean AuthServiceImpl authService; + @MockitoBean TraspasoServiceImpl traspasoService; + @MockitoBean AuthServiceImpl authService; @Autowired TraspasoController traspasoController; diff --git a/src/test/java/org/opencommercial/controller/UbicacionControllerTest.java b/src/test/java/org/opencommercial/controller/UbicacionControllerTest.java index 33e95e5c..e75f9736 100644 --- a/src/test/java/org/opencommercial/controller/UbicacionControllerTest.java +++ b/src/test/java/org/opencommercial/controller/UbicacionControllerTest.java @@ -3,12 +3,12 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.modelmapper.ModelMapper; +import org.opencommercial.model.dto.LocalidadesParaActualizarDTO; +import org.opencommercial.service.UbicacionServiceImpl; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.opencommercial.model.dto.LocalidadesParaActualizarDTO; -import org.opencommercial.service.UbicacionServiceImpl; import static org.mockito.Mockito.verify; @@ -16,8 +16,8 @@ @ContextConfiguration(classes = {UbicacionController.class}) class UbicacionControllerTest { - @MockBean UbicacionServiceImpl ubicacionService; - @MockBean ModelMapper modelMapper; + @MockitoBean UbicacionServiceImpl ubicacionService; + @MockitoBean ModelMapper modelMapper; @Autowired UbicacionController ubicacionController; diff --git a/src/test/java/org/opencommercial/integration/AppIntegrationTest.java b/src/test/java/org/opencommercial/integration/AppIntegrationTest.java index 2809362c..d2de804f 100644 --- a/src/test/java/org/opencommercial/integration/AppIntegrationTest.java +++ b/src/test/java/org/opencommercial/integration/AppIntegrationTest.java @@ -1,7 +1,7 @@ package org.opencommercial.integration; -import jakarta.validation.constraints.NotNull; import org.apache.commons.io.IOUtils; +import org.jspecify.annotations.NonNull; import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtendWith; import org.opencommercial.integration.model.*; @@ -9,8 +9,9 @@ import org.opencommercial.model.criteria.*; import org.opencommercial.model.dto.*; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.resttestclient.TestRestTemplate; +import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.context.MessageSource; import org.springframework.core.ParameterizedTypeReference; @@ -24,12 +25,13 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.RestClientResponseException; -import org.testcontainers.containers.MySQLContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.mysql.MySQLContainer; import java.io.IOException; import java.math.BigDecimal; +import java.net.URI; import java.nio.charset.Charset; import java.time.LocalDateTime; import java.util.*; @@ -39,6 +41,7 @@ @ExtendWith(SpringExtension.class) @Testcontainers @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureTestRestTemplate @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestPropertySource(locations = "/application.properties") class AppIntegrationTest { @@ -51,7 +54,7 @@ class AppIntegrationTest { @Container @ServiceConnection - static MySQLContainer mySQLContainer = new MySQLContainer<>("mysql:8.3.0"); + static MySQLContainer mySQLContainer = new MySQLContainer("mysql:8.3.0"); void iniciarSesionComoAdministrador() { this.token = restTemplate.postForEntity("/api/v1/login", @@ -74,13 +77,14 @@ void setup() { restTemplate.getRestTemplate() .setErrorHandler( new ResponseErrorHandler() { + @Override - public boolean hasError(@NotNull ClientHttpResponse response) throws IOException { + public boolean hasError(@NonNull ClientHttpResponse response) throws IOException { return (response.getStatusCode().is4xxClientError() || response.getStatusCode().is5xxServerError()); } @Override - public void handleError(@NotNull ClientHttpResponse response) throws IOException { + public void handleError(@NonNull URI url, @NonNull HttpMethod method, @NonNull ClientHttpResponse response) throws IOException { String mensaje = IOUtils.toString(response.getBody(), Charset.defaultCharset()); throw new RestClientResponseException( mensaje, @@ -133,8 +137,9 @@ void iniciarActividadComercial() { assertEquals(nuevaSucursal.getTelefono(), sucursalRecuperada.getTelefono()); assertEquals(nuevaSucursal.getUbicacion().getIdLocalidad(), sucursalRecuperada.getUbicacion().getIdLocalidad()); ConfiguracionSucursal configuracionSucursal = - restTemplate.getForObject("/api/v1/configuraciones-sucursal/" + sucursalRecuperada.getIdSucursal(), - ConfiguracionSucursal.class); + restTemplate.getForObject( + "/api/v1/configuraciones-sucursal/" + sucursalRecuperada.getIdSucursal(), + ConfiguracionSucursal.class); configuracionSucursal.setPuntoDeRetiro(true); configuracionSucursal.setPredeterminada(true); restTemplate.put("/api/v1/configuraciones-sucursal", configuracionSucursal); @@ -147,8 +152,9 @@ void iniciarActividadComercial() { configuracionSucursal.setNroPuntoDeVentaAfip(2); restTemplate.put("/api/v1/configuraciones-sucursal", configuracionSucursal); ConfiguracionSucursal configuracionSucursalActualizada = - restTemplate.getForObject("/api/v1/configuraciones-sucursal/" + sucursalRecuperada.getIdSucursal(), - ConfiguracionSucursal.class); + restTemplate.getForObject( + "/api/v1/configuraciones-sucursal/" + sucursalRecuperada.getIdSucursal(), + ConfiguracionSucursal.class); assertEquals(configuracionSucursal, configuracionSucursalActualizada); } @@ -1712,6 +1718,7 @@ void testEscenarioFacturarPedido() { "/api/v1/facturas/ventas/renglones/pedidos/" + pedidosRecuperados.getFirst().getIdPedido() + "?tipoDeComprobante=FACTURA_X", RenglonFactura[].class)); + assertNotNull(renglones); assertEquals("Corta Papas - Vegetales", renglones.getFirst().getDescripcionItem()); assertEquals(new BigDecimal("50.000000000000000"), renglones.getFirst().getCantidad()); assertEquals(new BigDecimal("1000.000000000000000"), renglones.getFirst().getPrecioUnitario()); diff --git a/src/test/java/org/opencommercial/integration/model/ConfiguracionSucursalTest.java b/src/test/java/org/opencommercial/integration/model/ConfiguracionSucursalTest.java index 5e60d8bd..57b93f80 100644 --- a/src/test/java/org/opencommercial/integration/model/ConfiguracionSucursalTest.java +++ b/src/test/java/org/opencommercial/integration/model/ConfiguracionSucursalTest.java @@ -6,7 +6,12 @@ @AllArgsConstructor @NoArgsConstructor @Builder -@EqualsAndHashCode(exclude = {"certificadoAfip", "existeCertificado", "passwordCertificadoAfip"}) +@EqualsAndHashCode( + exclude = { + "certificadoAfip", + "existeCertificado", + "passwordCertificadoAfip" + }) public class ConfiguracionSucursalTest { private long idConfiguracionSucursal; diff --git a/src/test/java/org/opencommercial/integration/model/CuentaCorrienteTest.java b/src/test/java/org/opencommercial/integration/model/CuentaCorrienteTest.java index c8762a55..e4c66d64 100644 --- a/src/test/java/org/opencommercial/integration/model/CuentaCorrienteTest.java +++ b/src/test/java/org/opencommercial/integration/model/CuentaCorrienteTest.java @@ -1,9 +1,7 @@ package org.opencommercial.integration.model; -import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.ObjectIdGenerators; import lombok.*; import java.math.BigDecimal; @@ -15,10 +13,6 @@ @NoArgsConstructor @EqualsAndHashCode(of = "fechaApertura") @ToString(exclude = {"renglones"}) -@JsonIdentityInfo( - generator = ObjectIdGenerators.PropertyGenerator.class, - property = "idCuentaCorriente", - scope = CuentaCorrienteTest.class) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = CuentaCorrienteClienteTest.class), diff --git a/src/test/java/org/opencommercial/integration/model/FacturaCompraTest.java b/src/test/java/org/opencommercial/integration/model/FacturaCompraTest.java index ad022924..835bd121 100644 --- a/src/test/java/org/opencommercial/integration/model/FacturaCompraTest.java +++ b/src/test/java/org/opencommercial/integration/model/FacturaCompraTest.java @@ -12,8 +12,11 @@ @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode( - callSuper = true, - exclude = {"razonSocialProveedor", "idProveedor"}) + callSuper = true, + exclude = { + "razonSocialProveedor", + "idProveedor" + }) @Builder public class FacturaCompraTest extends FacturaTest { @@ -23,70 +26,70 @@ public class FacturaCompraTest extends FacturaTest { @Builder(builderMethodName = "facturaCompraBuilder") public FacturaCompraTest( - long idFactura, - LocalDateTime fecha, - LocalDateTime fechaAlta, - TipoDeComprobante tipoDeComprobante, - long numSerie, - long numFactura, - LocalDate fechaVencimiento, - Long idPedido, - Long nroPedido, - Long idTransportista, - String nombreTransportista, - List renglones, - BigDecimal subTotal, - BigDecimal recargoPorcentaje, - BigDecimal recargoNeto, - BigDecimal descuentoPorcentaje, - BigDecimal descuentoNeto, - BigDecimal subTotalBruto, - BigDecimal iva105Neto, - BigDecimal iva21Neto, - BigDecimal impuestoInternoNeto, - BigDecimal total, - String observaciones, - BigDecimal cantidadArticulos, - long idSucursal, - String nombreSucursal, - Long idUsuario, - String nombreUsuario, - boolean eliminada, - long cae, - LocalDate vencimientoCae, - Long idProveedor, - String razonSocialProveedor) { + long idFactura, + LocalDateTime fecha, + LocalDateTime fechaAlta, + TipoDeComprobante tipoDeComprobante, + long numSerie, + long numFactura, + LocalDate fechaVencimiento, + Long idPedido, + Long nroPedido, + Long idTransportista, + String nombreTransportista, + List renglones, + BigDecimal subTotal, + BigDecimal recargoPorcentaje, + BigDecimal recargoNeto, + BigDecimal descuentoPorcentaje, + BigDecimal descuentoNeto, + BigDecimal subTotalBruto, + BigDecimal iva105Neto, + BigDecimal iva21Neto, + BigDecimal impuestoInternoNeto, + BigDecimal total, + String observaciones, + BigDecimal cantidadArticulos, + long idSucursal, + String nombreSucursal, + Long idUsuario, + String nombreUsuario, + boolean eliminada, + long cae, + LocalDate vencimientoCae, + Long idProveedor, + String razonSocialProveedor) { super( - idFactura, - fecha, - tipoDeComprobante, - numSerie, - numFactura, - fechaVencimiento, - idPedido, - nroPedido, - idTransportista, - nombreTransportista, - renglones, - subTotal, - recargoPorcentaje, - recargoNeto, - descuentoPorcentaje, - descuentoNeto, - subTotalBruto, - iva105Neto, - iva21Neto, - impuestoInternoNeto, - total, - observaciones, - cantidadArticulos, - idSucursal, - nombreSucursal, - idUsuario, - nombreUsuario, - eliminada, - cae, - vencimientoCae); + idFactura, + fecha, + tipoDeComprobante, + numSerie, + numFactura, + fechaVencimiento, + idPedido, + nroPedido, + idTransportista, + nombreTransportista, + renglones, + subTotal, + recargoPorcentaje, + recargoNeto, + descuentoPorcentaje, + descuentoNeto, + subTotalBruto, + iva105Neto, + iva21Neto, + impuestoInternoNeto, + total, + observaciones, + cantidadArticulos, + idSucursal, + nombreSucursal, + idUsuario, + nombreUsuario, + eliminada, + cae, + vencimientoCae); this.idProveedor = idProveedor; this.razonSocialProveedor = razonSocialProveedor; this.fechaAlta = fechaAlta; diff --git a/src/test/java/org/opencommercial/integration/model/FacturaTest.java b/src/test/java/org/opencommercial/integration/model/FacturaTest.java index b02474ea..5ccd0c5e 100644 --- a/src/test/java/org/opencommercial/integration/model/FacturaTest.java +++ b/src/test/java/org/opencommercial/integration/model/FacturaTest.java @@ -1,9 +1,7 @@ package org.opencommercial.integration.model; -import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.ObjectIdGenerators; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -31,10 +29,6 @@ "nombreUsuario", "cantidadArticulos" }) -@JsonIdentityInfo( - generator = ObjectIdGenerators.PropertyGenerator.class, - property = "idFactura", - scope = FacturaTest.class) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = FacturaCompraTest.class, name = "FacturaCompra"), diff --git a/src/test/java/org/opencommercial/integration/model/LocalidadTest.java b/src/test/java/org/opencommercial/integration/model/LocalidadTest.java index fe492aaf..0cf7ed51 100644 --- a/src/test/java/org/opencommercial/integration/model/LocalidadTest.java +++ b/src/test/java/org/opencommercial/integration/model/LocalidadTest.java @@ -10,7 +10,12 @@ @AllArgsConstructor @NoArgsConstructor @Builder -@EqualsAndHashCode(exclude = {"idLocalidad", "idProvincia", "nombreProvincia"}) +@EqualsAndHashCode( + exclude = { + "idLocalidad", + "idProvincia", + "nombreProvincia" + }) public class LocalidadTest { private long idLocalidad; diff --git a/src/test/java/org/opencommercial/integration/model/NotaTest.java b/src/test/java/org/opencommercial/integration/model/NotaTest.java index 10af3546..2c975d9d 100644 --- a/src/test/java/org/opencommercial/integration/model/NotaTest.java +++ b/src/test/java/org/opencommercial/integration/model/NotaTest.java @@ -1,9 +1,7 @@ package org.opencommercial.integration.model; -import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.ObjectIdGenerators; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -18,10 +16,6 @@ @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode(exclude = {"idNota", "serie", "nroNota"}) -@JsonIdentityInfo( - generator = ObjectIdGenerators.PropertyGenerator.class, - property = "idNota", - scope = NotaTest.class) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = NotaCreditoTest.class, name = "NotaCredito"), diff --git a/src/test/java/org/opencommercial/integration/model/SucursalTest.java b/src/test/java/org/opencommercial/integration/model/SucursalTest.java index 40a3f9e3..bc23900d 100644 --- a/src/test/java/org/opencommercial/integration/model/SucursalTest.java +++ b/src/test/java/org/opencommercial/integration/model/SucursalTest.java @@ -9,7 +9,13 @@ @AllArgsConstructor @NoArgsConstructor @Builder -@EqualsAndHashCode(exclude = {"idSucursal", "ubicacion", "detalleUbicacion", "configuracionSucursal"}) +@EqualsAndHashCode( + exclude = { + "idSucursal", + "ubicacion", + "detalleUbicacion", + "configuracionSucursal" + }) public class SucursalTest { private long idSucursal; diff --git a/src/test/java/org/opencommercial/repository/ProductoRepositoryTest.java b/src/test/java/org/opencommercial/repository/ProductoRepositoryTest.java index 6811cd0d..ffa7d127 100644 --- a/src/test/java/org/opencommercial/repository/ProductoRepositoryTest.java +++ b/src/test/java/org/opencommercial/repository/ProductoRepositoryTest.java @@ -12,16 +12,16 @@ import org.opencommercial.model.embeddable.PrecioProductoEmbeddable; import org.opencommercial.repository.custom.ProductoRepositoryImpl; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; +import org.springframework.boot.jpa.test.autoconfigure.TestEntityManager; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.testcontainers.containers.MySQLContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.mysql.MySQLContainer; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -37,7 +37,7 @@ @ContextConfiguration(classes = {ProductoRepositoryImpl.class, LocalidadRepository.class, App.class}) class ProductoRepositoryTest { - @MockBean JwtInterceptor jwtInterceptor; + @MockitoBean JwtInterceptor jwtInterceptor; @Autowired TestEntityManager testEntityManager; @Autowired ProductoRepositoryImpl productoRepositoryImpl; @@ -45,7 +45,7 @@ class ProductoRepositoryTest { @Container @ServiceConnection - static MySQLContainer mySQLContainer = new MySQLContainer<>("mysql:8.3.0"); + static MySQLContainer mySQLContainer = new MySQLContainer("mysql:8.3.0"); @Test void shouldThrowOptimisticLockExceptionWhenIntentaActualizarProductoDetached() { diff --git a/src/test/java/org/opencommercial/service/AuthServiceImplTest.java b/src/test/java/org/opencommercial/service/AuthServiceImplTest.java index edf9d321..8fd393a9 100644 --- a/src/test/java/org/opencommercial/service/AuthServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/AuthServiceImplTest.java @@ -2,16 +2,16 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.opencommercial.model.Rol; +import org.opencommercial.model.TokenAccesoExcluido; +import org.opencommercial.repository.TokenAccesoExcluidoRepository; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.web.client.RestTemplate; -import org.opencommercial.model.Rol; -import org.opencommercial.model.TokenAccesoExcluido; -import org.opencommercial.repository.TokenAccesoExcluidoRepository; import java.util.List; @@ -25,9 +25,9 @@ @TestPropertySource(locations = "classpath:application.properties") class AuthServiceImplTest { - @MockBean TokenAccesoExcluidoRepository tokenAccesoExcluidoRepository; - @MockBean MessageSource messageSource; - @MockBean RestTemplate restTemplate; + @MockitoBean TokenAccesoExcluidoRepository tokenAccesoExcluidoRepository; + @MockitoBean MessageSource messageSource; + @MockitoBean RestTemplate restTemplate; @Autowired AuthServiceImpl authService; static final String BEARER_TOKEN_PREFIX = "Bearer"; diff --git a/src/test/java/org/opencommercial/service/CarritoCompraServiceImplTest.java b/src/test/java/org/opencommercial/service/CarritoCompraServiceImplTest.java index 03ead862..33555d08 100644 --- a/src/test/java/org/opencommercial/service/CarritoCompraServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/CarritoCompraServiceImplTest.java @@ -13,12 +13,12 @@ import org.opencommercial.repository.CarritoCompraRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -33,12 +33,12 @@ @ContextConfiguration(classes = {CustomValidator.class, CarritoCompraServiceImpl.class}) class CarritoCompraServiceImplTest { - @MockBean CarritoCompraRepository carritoCompraRepository; - @MockBean UsuarioService usuarioService; - @MockBean ProductoService productoService; - @MockBean SucursalService sucursalService; - @MockBean ClienteService clienteService; - @MockBean PedidoService pedidoService; + @MockitoBean CarritoCompraRepository carritoCompraRepository; + @MockitoBean UsuarioService usuarioService; + @MockitoBean ProductoService productoService; + @MockitoBean SucursalService sucursalService; + @MockitoBean ClienteService clienteService; + @MockitoBean PedidoService pedidoService; @Autowired CarritoCompraServiceImpl carritoCompraServiceImpl; diff --git a/src/test/java/org/opencommercial/service/ClienteServiceImplTest.java b/src/test/java/org/opencommercial/service/ClienteServiceImplTest.java index dc7a488d..2675a0a3 100644 --- a/src/test/java/org/opencommercial/service/ClienteServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/ClienteServiceImplTest.java @@ -10,9 +10,9 @@ import org.opencommercial.repository.ClienteRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.ArrayList; @@ -31,11 +31,11 @@ classes = {ClienteServiceImpl.class, CustomValidator.class, MessageSource.class}) class ClienteServiceImplTest { - @MockBean MessageSource messageSource; - @MockBean ClienteRepository clienteRepository; - @MockBean CuentaCorrienteService cuentaCorrienteService; - @MockBean UsuarioService usuarioService; - @MockBean UbicacionService ubicacionService; + @MockitoBean MessageSource messageSource; + @MockitoBean ClienteRepository clienteRepository; + @MockitoBean CuentaCorrienteService cuentaCorrienteService; + @MockitoBean UsuarioService usuarioService; + @MockitoBean UbicacionService ubicacionService; @Autowired ClienteServiceImpl clienteService; diff --git a/src/test/java/org/opencommercial/service/ConfiguracionSucursalServiceImplTest.java b/src/test/java/org/opencommercial/service/ConfiguracionSucursalServiceImplTest.java index f2ae761d..dc798fa2 100644 --- a/src/test/java/org/opencommercial/service/ConfiguracionSucursalServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/ConfiguracionSucursalServiceImplTest.java @@ -7,9 +7,9 @@ import org.opencommercial.repository.ConfiguracionSucursalRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.time.LocalDateTime; @@ -26,8 +26,8 @@ classes = {ConfiguracionSucursalServiceImpl.class, CustomValidator.class, MessageSource.class}) class ConfiguracionSucursalServiceImplTest { - @MockBean ConfiguracionSucursalRepository configuracionSucursalRepository; - @MockBean MessageSource messageSource; + @MockitoBean ConfiguracionSucursalRepository configuracionSucursalRepository; + @MockitoBean MessageSource messageSource; @Autowired ConfiguracionSucursalServiceImpl configuracionSucursalService; diff --git a/src/test/java/org/opencommercial/service/CuentaCorrienteServiceImplTest.java b/src/test/java/org/opencommercial/service/CuentaCorrienteServiceImplTest.java index ce4491a0..f7c26803 100644 --- a/src/test/java/org/opencommercial/service/CuentaCorrienteServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/CuentaCorrienteServiceImplTest.java @@ -12,10 +12,10 @@ import org.opencommercial.util.FormatoReporte; import org.opencommercial.util.JasperReportsHandler; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.data.domain.PageImpl; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.ArrayList; @@ -32,13 +32,13 @@ classes = {CuentaCorrienteServiceImpl.class, CustomValidator.class, MessageSource.class, JasperReportsHandler.class}) class CuentaCorrienteServiceImplTest { - @MockBean CuentaCorrienteRepository cuentaCorrienteRepository; - @MockBean CuentaCorrienteClienteRepository cuentaCorrienteClienteRepository; - @MockBean RenglonCuentaCorrienteRepository renglonCuentaCorrienteRepository; - @MockBean UsuarioService usuarioService; - @MockBean ClienteService clienteService; - @MockBean SucursalService sucursalService; - @MockBean MessageSource messageSource; + @MockitoBean CuentaCorrienteRepository cuentaCorrienteRepository; + @MockitoBean CuentaCorrienteClienteRepository cuentaCorrienteClienteRepository; + @MockitoBean RenglonCuentaCorrienteRepository renglonCuentaCorrienteRepository; + @MockitoBean UsuarioService usuarioService; + @MockitoBean ClienteService clienteService; + @MockitoBean SucursalService sucursalService; + @MockitoBean MessageSource messageSource; @Autowired CuentaCorrienteServiceImpl cuentaCorrienteService; diff --git a/src/test/java/org/opencommercial/service/FacturaCompraServiceImplTest.java b/src/test/java/org/opencommercial/service/FacturaCompraServiceImplTest.java index 49ba7818..e038c514 100644 --- a/src/test/java/org/opencommercial/service/FacturaCompraServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/FacturaCompraServiceImplTest.java @@ -10,9 +10,9 @@ import org.opencommercial.model.embeddable.PrecioProductoEmbeddable; import org.opencommercial.repository.FacturaCompraRepository; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -29,8 +29,8 @@ classes = {FacturaServiceImpl.class, FacturaCompraServiceImpl.class, MessageSource.class}) class FacturaCompraServiceImplTest { - @MockBean FacturaCompraRepository facturaCompraRepository; - @MockBean MessageSource messageSource; + @MockitoBean FacturaCompraRepository facturaCompraRepository; + @MockitoBean MessageSource messageSource; @Autowired FacturaServiceImpl facturaServiceImpl; @Autowired FacturaCompraServiceImpl facturaCompraServiceImpl; diff --git a/src/test/java/org/opencommercial/service/FacturaServiceImplTest.java b/src/test/java/org/opencommercial/service/FacturaServiceImplTest.java index c536875d..f261e7e1 100644 --- a/src/test/java/org/opencommercial/service/FacturaServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/FacturaServiceImplTest.java @@ -10,9 +10,9 @@ import org.opencommercial.util.CalculosComprobante; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -27,13 +27,13 @@ classes = {CustomValidator.class, FacturaServiceImpl.class, MessageSource.class}) class FacturaServiceImplTest { - @MockBean SucursalServiceImpl sucursalService; - @MockBean ProductoServiceImpl productoService; - @MockBean PedidoServiceImpl pedidoService; - @MockBean FacturaRepository facturaRepository; - @MockBean NotaServiceImpl notaService; - @MockBean CuentaCorrienteServiceImpl cuentaCorrienteService; - @MockBean MessageSource messageSource; + @MockitoBean SucursalServiceImpl sucursalService; + @MockitoBean ProductoServiceImpl productoService; + @MockitoBean PedidoServiceImpl pedidoService; + @MockitoBean FacturaRepository facturaRepository; + @MockitoBean NotaServiceImpl notaService; + @MockitoBean CuentaCorrienteServiceImpl cuentaCorrienteService; + @MockitoBean MessageSource messageSource; @Autowired FacturaServiceImpl facturaServiceImpl; diff --git a/src/test/java/org/opencommercial/service/FacturaVentaServiceImplTest.java b/src/test/java/org/opencommercial/service/FacturaVentaServiceImplTest.java index 3f2041fe..147e11e7 100644 --- a/src/test/java/org/opencommercial/service/FacturaVentaServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/FacturaVentaServiceImplTest.java @@ -16,9 +16,9 @@ import org.opencommercial.util.CustomValidator; import org.opencommercial.util.JasperReportsHandler; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -41,18 +41,18 @@ }) class FacturaVentaServiceImplTest { - @MockBean FacturaRepository facturaRepository; - @MockBean FacturaVentaRepository facturaVentaRepository; - @MockBean ProductoServiceImpl productoService; - @MockBean UsuarioServiceImpl usuarioService; - @MockBean ClienteServiceImpl clienteService; - @MockBean PedidoServiceImpl pedidoService; - @MockBean ConfiguracionSucursalServiceImpl configuracionSucursalService; - @MockBean EmailServiceFactory emailServiceFactory; - @MockBean ResendEmailServiceImpl resendEmailService; - @MockBean SucursalServiceImpl sucursalService; - @MockBean TransportistaServiceImpl transportistaService; - @MockBean MessageSource messageSource; + @MockitoBean FacturaRepository facturaRepository; + @MockitoBean FacturaVentaRepository facturaVentaRepository; + @MockitoBean ProductoServiceImpl productoService; + @MockitoBean UsuarioServiceImpl usuarioService; + @MockitoBean ClienteServiceImpl clienteService; + @MockitoBean PedidoServiceImpl pedidoService; + @MockitoBean ConfiguracionSucursalServiceImpl configuracionSucursalService; + @MockitoBean EmailServiceFactory emailServiceFactory; + @MockitoBean ResendEmailServiceImpl resendEmailService; + @MockitoBean SucursalServiceImpl sucursalService; + @MockitoBean TransportistaServiceImpl transportistaService; + @MockitoBean MessageSource messageSource; @Autowired FacturaServiceImpl facturaServiceImpl; @Autowired FacturaVentaServiceImpl facturaVentaServiceImpl; diff --git a/src/test/java/org/opencommercial/service/GastoServiceImplTest.java b/src/test/java/org/opencommercial/service/GastoServiceImplTest.java index 54c42887..505b3ae9 100644 --- a/src/test/java/org/opencommercial/service/GastoServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/GastoServiceImplTest.java @@ -5,9 +5,9 @@ import org.opencommercial.model.criteria.BusquedaGastoCriteria; import org.opencommercial.repository.GastoRepository; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.time.LocalDateTime; @@ -18,10 +18,10 @@ @ContextConfiguration(classes = {GastoServiceImpl.class, MessageSource.class}) class GastoServiceImplTest { - @MockBean GastoRepository gastoRepository; - @MockBean SucursalService sucursalService; - @MockBean CajaService cajaService; - @MockBean MessageSource messageSource; + @MockitoBean GastoRepository gastoRepository; + @MockitoBean SucursalService sucursalService; + @MockitoBean CajaService cajaService; + @MockitoBean MessageSource messageSource; @Autowired GastoServiceImpl gastoService; diff --git a/src/test/java/org/opencommercial/service/MedidaServiceImplTest.java b/src/test/java/org/opencommercial/service/MedidaServiceImplTest.java index ffa405be..b027b7f5 100644 --- a/src/test/java/org/opencommercial/service/MedidaServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/MedidaServiceImplTest.java @@ -8,9 +8,9 @@ import org.opencommercial.repository.MedidaRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -24,8 +24,8 @@ classes = {MedidaServiceImpl.class, CustomValidator.class, MessageSource.class}) class MedidaServiceImplTest { - @MockBean MessageSource messageSource; - @MockBean MedidaRepository medidaRepository; + @MockitoBean MessageSource messageSource; + @MockitoBean MedidaRepository medidaRepository; @Autowired MedidaServiceImpl medidaService; diff --git a/src/test/java/org/opencommercial/service/NotaServiceImplTest.java b/src/test/java/org/opencommercial/service/NotaServiceImplTest.java index 9b3cec8d..3b5539c3 100644 --- a/src/test/java/org/opencommercial/service/NotaServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/NotaServiceImplTest.java @@ -8,9 +8,9 @@ import org.opencommercial.repository.NotaDebitoRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -29,11 +29,11 @@ classes = {NotaServiceImpl.class, CustomValidator.class, MessageSource.class}) class NotaServiceImplTest { - @MockBean SucursalServiceImpl sucursalServiceImpl; - @MockBean ClienteServiceImpl clienteService; - @MockBean ProveedorServiceImpl proveedorService; - @MockBean NotaDebitoRepository notaDebitoRepository; - @MockBean MessageSource messageSource; + @MockitoBean SucursalServiceImpl sucursalServiceImpl; + @MockitoBean ClienteServiceImpl clienteService; + @MockitoBean ProveedorServiceImpl proveedorService; + @MockitoBean NotaDebitoRepository notaDebitoRepository; + @MockitoBean MessageSource messageSource; @Autowired NotaServiceImpl notaServiceImpl; diff --git a/src/test/java/org/opencommercial/service/PedidoServiceImplTest.java b/src/test/java/org/opencommercial/service/PedidoServiceImplTest.java index a1670862..d3d2a8eb 100644 --- a/src/test/java/org/opencommercial/service/PedidoServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/PedidoServiceImplTest.java @@ -16,9 +16,9 @@ import org.opencommercial.util.CustomValidator; import org.opencommercial.util.JasperReportsHandler; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -39,19 +39,19 @@ }) class PedidoServiceImplTest { - @MockBean PedidoRepository pedidoRepository; - @MockBean RenglonPedidoRepository renglonPedidoRepository; - @MockBean FacturaVentaServiceImpl facturaVentaService; - @MockBean UsuarioServiceImpl usuarioService; - @MockBean ClienteServiceImpl clienteService; - @MockBean ProductoServiceImpl productoService; - @MockBean EmailServiceFactory emailServiceFactory; - @MockBean ResendEmailServiceImpl resendEmailService; - @MockBean ConfiguracionSucursalServiceImpl configuracionSucursalService; - @MockBean CuentaCorrienteServiceImpl cuentaCorrienteService; - @MockBean ReciboServiceImpl reciboService; - @MockBean MessageSource messageSource; - @MockBean ModelMapper modelMapper; + @MockitoBean PedidoRepository pedidoRepository; + @MockitoBean RenglonPedidoRepository renglonPedidoRepository; + @MockitoBean FacturaVentaServiceImpl facturaVentaService; + @MockitoBean UsuarioServiceImpl usuarioService; + @MockitoBean ClienteServiceImpl clienteService; + @MockitoBean ProductoServiceImpl productoService; + @MockitoBean EmailServiceFactory emailServiceFactory; + @MockitoBean ResendEmailServiceImpl resendEmailService; + @MockitoBean ConfiguracionSucursalServiceImpl configuracionSucursalService; + @MockitoBean CuentaCorrienteServiceImpl cuentaCorrienteService; + @MockitoBean ReciboServiceImpl reciboService; + @MockitoBean MessageSource messageSource; + @MockitoBean ModelMapper modelMapper; @Autowired PedidoServiceImpl pedidoService; diff --git a/src/test/java/org/opencommercial/service/ProductoServiceImplTest.java b/src/test/java/org/opencommercial/service/ProductoServiceImplTest.java index 5e49942e..6936a18b 100644 --- a/src/test/java/org/opencommercial/service/ProductoServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/ProductoServiceImplTest.java @@ -22,10 +22,10 @@ import org.opencommercial.util.FormatoReporte; import org.opencommercial.util.JasperReportsHandler; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.data.domain.*; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -47,19 +47,19 @@ }) class ProductoServiceImplTest { - @MockBean MedidaServiceImpl medidaService; - @MockBean RubroServiceImpl rubroService; - @MockBean ProveedorServiceImpl proveedorService; - @MockBean SucursalServiceImpl sucursalService; - @MockBean TraspasoServiceImpl traspasoService; - @MockBean PedidoServiceImpl pedidoService; - @MockBean ClienteServiceImpl clienteService; - @MockBean UsuarioServiceImpl usuarioService; - @MockBean EmailServiceFactory emailServiceFactory; - @MockBean ResendEmailServiceImpl resendEmailService; - @MockBean ProductoRepository productoRepository; - @MockBean ProductoFavoritoRepository productoFavoritoRepository; - @MockBean MessageSource messageSource; + @MockitoBean MedidaServiceImpl medidaService; + @MockitoBean RubroServiceImpl rubroService; + @MockitoBean ProveedorServiceImpl proveedorService; + @MockitoBean SucursalServiceImpl sucursalService; + @MockitoBean TraspasoServiceImpl traspasoService; + @MockitoBean PedidoServiceImpl pedidoService; + @MockitoBean ClienteServiceImpl clienteService; + @MockitoBean UsuarioServiceImpl usuarioService; + @MockitoBean EmailServiceFactory emailServiceFactory; + @MockitoBean ResendEmailServiceImpl resendEmailService; + @MockitoBean ProductoRepository productoRepository; + @MockitoBean ProductoFavoritoRepository productoFavoritoRepository; + @MockitoBean MessageSource messageSource; @Autowired ProductoServiceImpl productoService; diff --git a/src/test/java/org/opencommercial/service/ProveedorServiceImplTest.java b/src/test/java/org/opencommercial/service/ProveedorServiceImplTest.java index b698d964..70f7799e 100644 --- a/src/test/java/org/opencommercial/service/ProveedorServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/ProveedorServiceImplTest.java @@ -7,9 +7,9 @@ import org.opencommercial.repository.ProveedorRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.mockito.Mockito.verify; @@ -19,10 +19,10 @@ classes = {CustomValidator.class, ProveedorServiceImpl.class, MessageSource.class}) public class ProveedorServiceImplTest { - @MockBean ProveedorRepository proveedorRepository; - @MockBean CuentaCorrienteServiceImpl cuentaCorrienteService; - @MockBean UbicacionServiceImpl ubicacionService; - @MockBean MessageSource messageSource; + @MockitoBean ProveedorRepository proveedorRepository; + @MockitoBean CuentaCorrienteServiceImpl cuentaCorrienteService; + @MockitoBean UbicacionServiceImpl ubicacionService; + @MockitoBean MessageSource messageSource; @Autowired ProveedorServiceImpl proveedorService; diff --git a/src/test/java/org/opencommercial/service/ReciboServiceImplTest.java b/src/test/java/org/opencommercial/service/ReciboServiceImplTest.java index 80089560..6e497079 100644 --- a/src/test/java/org/opencommercial/service/ReciboServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/ReciboServiceImplTest.java @@ -7,9 +7,9 @@ import org.opencommercial.model.criteria.BusquedaReciboCriteria; import org.opencommercial.repository.ReciboRepository; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -28,11 +28,11 @@ @ContextConfiguration(classes = {ReciboServiceImpl.class, MessageSource.class}) class ReciboServiceImplTest { - @MockBean ConfiguracionSucursalService configuracionSucursalServiceInterface; - @MockBean FormaDePagoService formaDePagoService; - @MockBean SucursalService sucursalService; - @MockBean ReciboRepository reciboRepository; - @MockBean MessageSource messageSource; + @MockitoBean ConfiguracionSucursalService configuracionSucursalServiceInterface; + @MockitoBean FormaDePagoService formaDePagoService; + @MockitoBean SucursalService sucursalService; + @MockitoBean ReciboRepository reciboRepository; + @MockitoBean MessageSource messageSource; @Autowired ReciboServiceImpl reciboServiceImpl; diff --git a/src/test/java/org/opencommercial/service/RegistracionServiceImplTest.java b/src/test/java/org/opencommercial/service/RegistracionServiceImplTest.java index 218b202d..c6d2101d 100644 --- a/src/test/java/org/opencommercial/service/RegistracionServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/RegistracionServiceImplTest.java @@ -7,8 +7,8 @@ import org.opencommercial.model.dto.RegistracionClienteAndUsuarioDTO; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -18,9 +18,9 @@ @ContextConfiguration(classes = {RegistracionServiceImpl.class, CustomValidator.class}) class RegistracionServiceImplTest { - @MockBean UsuarioService usuarioService; - @MockBean ClienteService clienteService; - @MockBean EmailServiceFactory emailServiceFactory; + @MockitoBean UsuarioService usuarioService; + @MockitoBean ClienteService clienteService; + @MockitoBean EmailServiceFactory emailServiceFactory; @Autowired RegistracionServiceImpl registracionService; diff --git a/src/test/java/org/opencommercial/service/RemitoServiceImplTest.java b/src/test/java/org/opencommercial/service/RemitoServiceImplTest.java index e53e5442..5ea66f82 100644 --- a/src/test/java/org/opencommercial/service/RemitoServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/RemitoServiceImplTest.java @@ -13,10 +13,10 @@ import org.opencommercial.util.CustomValidator; import org.opencommercial.util.JasperReportsHandler; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.data.domain.Pageable; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -37,17 +37,17 @@ classes = {CustomValidator.class, RemitoServiceImpl.class, MessageSource.class, JasperReportsHandler.class}) class RemitoServiceImplTest { - @MockBean FacturaService facturaService; - @MockBean FacturaVentaService facturaVentaService; - @MockBean RemitoRepository remitoRepository; - @MockBean RenglonRemitoRepository renglonRemitoRepository; - @MockBean ClienteService clienteService; - @MockBean UsuarioService usuarioService; - @MockBean TransportistaService transportistaService; - @MockBean ConfiguracionSucursalService configuracionSucursalService; - @MockBean CuentaCorrienteService cuentaCorrienteService; - @MockBean SucursalService sucursalService; - @MockBean MessageSource messageSource; + @MockitoBean FacturaService facturaService; + @MockitoBean FacturaVentaService facturaVentaService; + @MockitoBean RemitoRepository remitoRepository; + @MockitoBean RenglonRemitoRepository renglonRemitoRepository; + @MockitoBean ClienteService clienteService; + @MockitoBean UsuarioService usuarioService; + @MockitoBean TransportistaService transportistaService; + @MockitoBean ConfiguracionSucursalService configuracionSucursalService; + @MockitoBean CuentaCorrienteService cuentaCorrienteService; + @MockitoBean SucursalService sucursalService; + @MockitoBean MessageSource messageSource; @Autowired RemitoServiceImpl remitoService; diff --git a/src/test/java/org/opencommercial/service/RubroServiceImplTest.java b/src/test/java/org/opencommercial/service/RubroServiceImplTest.java index fa7d0146..657ae162 100644 --- a/src/test/java/org/opencommercial/service/RubroServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/RubroServiceImplTest.java @@ -7,9 +7,9 @@ import org.opencommercial.repository.RubroRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -20,8 +20,8 @@ classes = {CustomValidator.class, RubroServiceImpl.class, MessageSource.class}) class RubroServiceImplTest { - @MockBean MessageSource messageSource; - @MockBean RubroRepository rubroRepository; + @MockitoBean MessageSource messageSource; + @MockitoBean RubroRepository rubroRepository; @Autowired RubroServiceImpl rubroService; diff --git a/src/test/java/org/opencommercial/service/SucursalServiceImplTest.java b/src/test/java/org/opencommercial/service/SucursalServiceImplTest.java index 3f6c97ef..bd7e23e2 100644 --- a/src/test/java/org/opencommercial/service/SucursalServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/SucursalServiceImplTest.java @@ -9,9 +9,9 @@ import org.opencommercial.repository.SucursalRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.ArrayList; @@ -30,12 +30,12 @@ classes = {SucursalServiceImpl.class, CustomValidator.class, MessageSource.class}) class SucursalServiceImplTest { - @MockBean SucursalRepository sucursalRepository; - @MockBean ConfiguracionSucursalServiceImpl configuracionSucursalService; - @MockBean UbicacionServiceImpl ubicacionService; - @MockBean ImageUploaderService imageUploaderService; - @MockBean ProductoServiceImpl productoService; - @MockBean MessageSource messageSource; + @MockitoBean SucursalRepository sucursalRepository; + @MockitoBean ConfiguracionSucursalServiceImpl configuracionSucursalService; + @MockitoBean UbicacionServiceImpl ubicacionService; + @MockitoBean ImageUploaderService imageUploaderService; + @MockitoBean ProductoServiceImpl productoService; + @MockitoBean MessageSource messageSource; @Autowired SucursalServiceImpl sucursalService; diff --git a/src/test/java/org/opencommercial/service/TransportistaServiceImplTest.java b/src/test/java/org/opencommercial/service/TransportistaServiceImplTest.java index 9c248d27..3ef4ec70 100644 --- a/src/test/java/org/opencommercial/service/TransportistaServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/TransportistaServiceImplTest.java @@ -9,9 +9,9 @@ import org.opencommercial.repository.TransportistaRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -22,9 +22,9 @@ classes = {TransportistaServiceImpl.class, CustomValidator.class, MessageSource.class}) class TransportistaServiceImplTest { - @MockBean UbicacionServiceImpl ubicacionService; - @MockBean TransportistaRepository transportistaRepository; - @MockBean MessageSource messageSource; + @MockitoBean UbicacionServiceImpl ubicacionService; + @MockitoBean TransportistaRepository transportistaRepository; + @MockitoBean MessageSource messageSource; @Autowired TransportistaServiceImpl transportistaService; diff --git a/src/test/java/org/opencommercial/service/TraspasoServiceImplTest.java b/src/test/java/org/opencommercial/service/TraspasoServiceImplTest.java index 6195df78..1b9c411f 100644 --- a/src/test/java/org/opencommercial/service/TraspasoServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/TraspasoServiceImplTest.java @@ -16,11 +16,11 @@ import org.opencommercial.util.CustomValidator; import org.opencommercial.util.JasperReportsHandler; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -36,13 +36,13 @@ classes = {CustomValidator.class, TraspasoServiceImpl.class, MessageSource.class, JasperReportsHandler.class}) class TraspasoServiceImplTest { - @MockBean ProductoServiceImpl productoService; - @MockBean SucursalServiceImpl sucursalService; - @MockBean UsuarioServiceImpl usuarioService; - @MockBean PedidoServiceImpl pedidoService; - @MockBean TraspasoRepository traspasoRepository; - @MockBean RenglonTraspasoRepository renglonTraspasoRepository; - @MockBean MessageSource messageSource; + @MockitoBean ProductoServiceImpl productoService; + @MockitoBean SucursalServiceImpl sucursalService; + @MockitoBean UsuarioServiceImpl usuarioService; + @MockitoBean PedidoServiceImpl pedidoService; + @MockitoBean TraspasoRepository traspasoRepository; + @MockitoBean RenglonTraspasoRepository renglonTraspasoRepository; + @MockitoBean MessageSource messageSource; @Autowired TraspasoServiceImpl traspasoService; diff --git a/src/test/java/org/opencommercial/service/UbicacionServiceImplTest.java b/src/test/java/org/opencommercial/service/UbicacionServiceImplTest.java index f3d3bfd1..886f7840 100644 --- a/src/test/java/org/opencommercial/service/UbicacionServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/UbicacionServiceImplTest.java @@ -13,9 +13,9 @@ import org.opencommercial.repository.UbicacionRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.math.BigDecimal; @@ -28,10 +28,10 @@ classes = {UbicacionServiceImpl.class, CustomValidator.class, MessageSource.class}) class UbicacionServiceImplTest { - @MockBean MessageSource messageSource; - @MockBean UbicacionRepository UbicacionRepository; - @MockBean LocalidadRepository localidadRepository; - @MockBean ProvinciaRepository provinciaRepository; + @MockitoBean MessageSource messageSource; + @MockitoBean UbicacionRepository UbicacionRepository; + @MockitoBean LocalidadRepository localidadRepository; + @MockitoBean ProvinciaRepository provinciaRepository; @Autowired UbicacionServiceImpl ubicacionService; diff --git a/src/test/java/org/opencommercial/service/UsuarioServiceImplTest.java b/src/test/java/org/opencommercial/service/UsuarioServiceImplTest.java index 15f89db5..bd7f8817 100644 --- a/src/test/java/org/opencommercial/service/UsuarioServiceImplTest.java +++ b/src/test/java/org/opencommercial/service/UsuarioServiceImplTest.java @@ -6,9 +6,9 @@ import org.opencommercial.repository.UsuarioRepository; import org.opencommercial.util.CustomValidator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.MessageSource; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.time.LocalDateTime; @@ -24,8 +24,8 @@ classes = {UsuarioServiceImpl.class, CustomValidator.class, MessageSource.class}) class UsuarioServiceImplTest { - @MockBean UsuarioRepository usuarioRepository; - @MockBean MessageSource messageSource; + @MockitoBean UsuarioRepository usuarioRepository; + @MockitoBean MessageSource messageSource; @Autowired UsuarioServiceImpl usuarioService; diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 38d7d811..dac1427e 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -18,3 +18,4 @@ spring.jpa.defer-datasource-initialization=true spring.jpa.properties.hibernate.show_sql=false logging.level.root=INFO spring.main.banner-mode=OFF +spring.jackson.deserialization.fail-on-null-for-primitives=false