From 5aafa8f191a2d51bae119238e404b402f500d48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Puig=20Moreno?= <48332388+rpuigm@users.noreply.github.com> Date: Fri, 16 Feb 2024 18:12:31 +0000 Subject: [PATCH 1/2] feat: cestaControllerTest finished --- .../controllers/CestaControllerTest.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ectemplate-servicio-productos/src/test/java/net/ostemplate/app/productos/controllers/CestaControllerTest.java b/ectemplate-servicio-productos/src/test/java/net/ostemplate/app/productos/controllers/CestaControllerTest.java index 0d61dc1..277b8a1 100644 --- a/ectemplate-servicio-productos/src/test/java/net/ostemplate/app/productos/controllers/CestaControllerTest.java +++ b/ectemplate-servicio-productos/src/test/java/net/ostemplate/app/productos/controllers/CestaControllerTest.java @@ -24,7 +24,7 @@ public class CestaControllerTest { @Mock - private CestaServiceI CestaServiceI; + private CestaServiceI cestaServiceI; @InjectMocks private CestaController cestaController; @@ -39,7 +39,7 @@ private void recuperaCestaPorIdUsuarioTest() { public void testRecuperaCestaPorIdUsuario() { Long idUsuario = 1L; Cesta cesta = new Cesta(); // crea una cesta ficticia para el test - when(CestaServiceI.buscarCestaPorUsuarioId(idUsuario)).thenReturn(cesta); + when(cestaServiceI.buscarCestaPorUsuarioId(idUsuario)).thenReturn(cesta); Cesta resultado = cestaController.recuperaCestaPorIdUsuario(idUsuario); assertEquals(cesta, resultado); @@ -49,7 +49,7 @@ public void testRecuperaCestaPorIdUsuario() { public void testActualizaCesta() { Cesta cesta = newCestabyRandom(); // crea una cesta ficticia para el test CestaEntity cestaEntity= CestaMapper.mapToCestaEntityFromCesta(cesta); - when(CestaServiceI.actualizaCesta(Mockito.any(CestaEntity.class))) + when(cestaServiceI.actualizaCesta(Mockito.any(CestaEntity.class))) .thenReturn(cestaEntity); Cesta response = cestaController.actualizaCesta(cesta); assertEquals(cestaEntity, response); @@ -60,12 +60,20 @@ public void testActualizaCesta() { public void testListaCestas() { List listCestasEntity= new ArrayList<>(); listCestasEntity = createListCestaEntitiesByRandom(); - when(CestaServiceI.listaCestas()).thenReturn(listCestasEntity); + when(cestaServiceI.listaCestas()).thenReturn(listCestasEntity); List resultado = cestaController.listaCestas(); assertEquals(listCestasEntity, resultado); } + @Test + public void recuperaCestaPorIdUsuarioEliminandoTest(){ + doNothing().when(cestaServiceI).eliminaCesta(Mockito.any(CestaEntity.class)); + cestaController.recuperaCestaPorIdUsuario(newCestabyRandom()); + } + + + private Cesta newCestabyRandom (){ Cesta cesta = new Cesta(); cesta.setId(1L); From c052fc9f4863fcb66b532ff25911a52623fbfac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Puig=20Moreno?= <48332388+rpuigm@users.noreply.github.com> Date: Fri, 16 Feb 2024 18:13:05 +0000 Subject: [PATCH 2/2] chore: coverage plugin added to devcontainer --- .devcontainer/devcontainer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2472bc8..825f567 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,6 +11,13 @@ "ghcr.io/devcontainers-contrib/features/angular-cli:2": {} }, + "customizations": { + "vscode": { + "extensions": [ + "ryanluker.vscode-coverage-gutters" + ] + } + }, //"customizations": { //"vscode": { //"extensions": [