From de16319e884c2f627a4cb0b78e131c259680b5b2 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 30 Oct 2021 10:21:34 +0000 Subject: [PATCH 1/2] Update Renovate Dependency Scan --- JavaCon/JsonIO/pom.xml | 2 +- JavaCon/SpecialKeywords/pom.xml | 2 +- JavaCon/pom.xml | 2 +- Playground/pom.xml | 8 ++++---- Testing/MutationPITesting/pom.xml | 2 +- Testing/PluralSight/pom.xml | 4 ++-- Testing/TestContainers/pom.xml | 10 +++++----- Testing/pom.xml | 2 +- Tools/aop-logging/pom.xml | 2 +- Tools/moustache-demo/pom.xml | 6 +++--- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/JavaCon/JsonIO/pom.xml b/JavaCon/JsonIO/pom.xml index 03e78c9d..8f980ee2 100644 --- a/JavaCon/JsonIO/pom.xml +++ b/JavaCon/JsonIO/pom.xml @@ -19,7 +19,7 @@ com.fasterxml.jackson.core jackson-databind - 2.12.5 + 2.13.0 commons-io diff --git a/JavaCon/SpecialKeywords/pom.xml b/JavaCon/SpecialKeywords/pom.xml index 4bc722d8..c091d72e 100644 --- a/JavaCon/SpecialKeywords/pom.xml +++ b/JavaCon/SpecialKeywords/pom.xml @@ -19,7 +19,7 @@ org.openjfx javafx-controls - 17.0.0.1 + 17.0.1 diff --git a/JavaCon/pom.xml b/JavaCon/pom.xml index 9a7482c1..47492927 100644 --- a/JavaCon/pom.xml +++ b/JavaCon/pom.xml @@ -31,7 +31,7 @@ 1.18.22 2.11.0 - 3.1.1 + 3.1.2 diff --git a/Playground/pom.xml b/Playground/pom.xml index f7fa06fb..39e6480d 100644 --- a/Playground/pom.xml +++ b/Playground/pom.xml @@ -19,18 +19,18 @@ com.fasterxml.jackson.dataformat jackson-dataformat-yaml - 2.12.4 + 2.13.0 com.fasterxml.jackson.core jackson-databind - 2.12.4 + 2.13.0 org.immutables value - 2.8.2 + 2.8.9-ea-1 provided @@ -46,7 +46,7 @@ org.junit.jupiter junit-jupiter-engine - 5.7.2 + 5.8.1 compile diff --git a/Testing/MutationPITesting/pom.xml b/Testing/MutationPITesting/pom.xml index 40f76f4a..c828a426 100644 --- a/Testing/MutationPITesting/pom.xml +++ b/Testing/MutationPITesting/pom.xml @@ -34,7 +34,7 @@ org.pitest pitest-maven - 1.7.0 + 1.7.2 diff --git a/Testing/PluralSight/pom.xml b/Testing/PluralSight/pom.xml index f806e387..1d08765c 100644 --- a/Testing/PluralSight/pom.xml +++ b/Testing/PluralSight/pom.xml @@ -27,12 +27,12 @@ org.springframework spring-beans - 5.3.10 + 5.3.12 org.springframework spring-context - 5.3.10 + 5.3.12 diff --git a/Testing/TestContainers/pom.xml b/Testing/TestContainers/pom.xml index ee02941b..38e1d407 100644 --- a/Testing/TestContainers/pom.xml +++ b/Testing/TestContainers/pom.xml @@ -8,7 +8,7 @@ org.springframework.boot spring-boot-starter-parent - 2.5.5 + 2.5.6 @@ -50,28 +50,28 @@ org.testcontainers testcontainers - 1.16.0 + 1.16.2 test org.testcontainers junit-jupiter - 1.16.0 + 1.16.2 test org.testcontainers mysql - 1.16.0 + 1.16.2 test org.testcontainers rabbitmq - 1.16.0 + 1.16.2 test diff --git a/Testing/pom.xml b/Testing/pom.xml index 06dc2c7a..ae0b0209 100644 --- a/Testing/pom.xml +++ b/Testing/pom.xml @@ -26,7 +26,7 @@ org.mockito mockito-core - 3.12.4 + 4.0.0 diff --git a/Tools/aop-logging/pom.xml b/Tools/aop-logging/pom.xml index 6c146256..c5b46756 100644 --- a/Tools/aop-logging/pom.xml +++ b/Tools/aop-logging/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.5.5 + 2.5.6 com.saurabh diff --git a/Tools/moustache-demo/pom.xml b/Tools/moustache-demo/pom.xml index 3dd6e85e..764c23a4 100644 --- a/Tools/moustache-demo/pom.xml +++ b/Tools/moustache-demo/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.5.5 + 2.5.6 @@ -19,7 +19,7 @@ 16 0.9.10 0.8 - 5.1.1 + 5.1.3 @@ -41,7 +41,7 @@ org.projectlombok lombok - 1.18.20 + 1.18.22 com.github.spullara.mustache.java From 02c53103e3b4ea15530d9c2af79ce3f759bdd5c5 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Sat, 30 Oct 2021 16:00:18 +0530 Subject: [PATCH 2/2] mockito 4 upgrade https://github.com/mockito/mockito/releases/tag/v4.0.0 --- Testing/Mockito/src/test/java/ListTest.java | 158 +++++++++--------- .../buisness/TodoBusinessImplMockitoTest.java | 112 ++++++------- 2 files changed, 135 insertions(+), 135 deletions(-) diff --git a/Testing/Mockito/src/test/java/ListTest.java b/Testing/Mockito/src/test/java/ListTest.java index 28e04919..66f8a5c8 100644 --- a/Testing/Mockito/src/test/java/ListTest.java +++ b/Testing/Mockito/src/test/java/ListTest.java @@ -12,8 +12,8 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.*; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; /** @@ -39,81 +39,81 @@ */ public class ListTest { - @Rule - public MockitoRule mockitoRule = MockitoJUnit.rule(); //Use this instead of RunWith(jUnitRunner) - - @Mock - private List list; - - @Test - public void letsMockListSize() { - when(list.size()).thenReturn(10); - - //THEN - assertEquals(10, list.size()); - } - - @Test - public void letsMockListSizeWithMultipleReturnValues() { - when(list.size()).thenReturn(10).thenReturn(20); - - //THEN - assertEquals(10, list.size()); // First Call - assertEquals(20, list.size()); // Second Call - } - - @Test - public void letsMockListGet() { - when(list.get(0)).thenReturn("in28Minutes"); - - //THEN - assertEquals("in28Minutes", list.get(0)); - - assertNull(list.get(1)); //if un-stubbed value is called - } - - @Test(expected = RuntimeException.class) - public void letsMockListGetToThrowException() { - when(list.get(Mockito.anyInt())).thenThrow(new RuntimeException("Something went wrong")); - list.get(0); - } - - @Test - public void letsMockListGetWithAny() { - //Argument Matcher - when(list.get(Mockito.anyInt())).thenReturn("in28Minutes"); - - //THEN - assertEquals("in28Minutes", list.get(0)); - assertEquals("in28Minutes", list.get(1)); - } - - @Test(expected = InvalidUseOfMatchersException.class) - public void letsMockListGetWithMixedStubValues() { - when(list.subList(anyInt(), 5)).thenThrow(new RuntimeException("Something went wrong")); - // If you are using argument matchers, all arguments have to be provided by matchers. - - //THEN - assertEquals("in28Minutes", list.get(0)); - assertEquals("in28Minutes", list.get(1)); - } - - @Test - public void letsMockListGetWithMixedStubValuesButHamcrestWorkaround() { - when(list.subList(anyInt(), eq(5))).thenReturn(Collections.singletonList("Something")); - - //THEN - assertEquals("Something", list.subList(0, 5).get(0)); - //assertEquals(null, list.subList(0,5).get(1)); Index out of bounds - } - - @Test - public void bddAliases_UsingGivenWillReturn() { - //given - BDDMockito.given(list.get(Mockito.anyInt())).willReturn("in28Minutes"); - - //THEN - assertThat("in28Minutes", is(list.get(0))); - assertThat("in28Minutes", is(list.get(1))); - } + @Rule + public MockitoRule mockitoRule = MockitoJUnit.rule(); //Use this instead of RunWith(jUnitRunner) + + @Mock + private List list; + + @Test + public void letsMockListSize() { + when(list.size()).thenReturn(10); + + //THEN + assertEquals(10, list.size()); + } + + @Test + public void letsMockListSizeWithMultipleReturnValues() { + when(list.size()).thenReturn(10).thenReturn(20); + + //THEN + assertEquals(10, list.size()); // First Call + assertEquals(20, list.size()); // Second Call + } + + @Test + public void letsMockListGet() { + when(list.get(0)).thenReturn("in28Minutes"); + + //THEN + assertEquals("in28Minutes", list.get(0)); + + assertNull(list.get(1)); //if un-stubbed value is called + } + + @Test(expected = RuntimeException.class) + public void letsMockListGetToThrowException() { + when(list.get(Mockito.anyInt())).thenThrow(new RuntimeException("Something went wrong")); + list.get(0); + } + + @Test + public void letsMockListGetWithAny() { + //Argument Matcher + when(list.get(Mockito.anyInt())).thenReturn("in28Minutes"); + + //THEN + assertEquals("in28Minutes", list.get(0)); + assertEquals("in28Minutes", list.get(1)); + } + + @Test(expected = InvalidUseOfMatchersException.class) + public void letsMockListGetWithMixedStubValues() { + when(list.subList(anyInt(), 5)).thenThrow(new RuntimeException("Something went wrong")); + // If you are using argument matchers, all arguments have to be provided by matchers. + + //THEN + assertEquals("in28Minutes", list.get(0)); + assertEquals("in28Minutes", list.get(1)); + } + + @Test + public void letsMockListGetWithMixedStubValuesButHamcrestWorkaround() { + when(list.subList(anyInt(), eq(5))).thenReturn(Collections.singletonList("Something")); + + //THEN + assertEquals("Something", list.subList(0, 5).get(0)); + //assertEquals(null, list.subList(0,5).get(1)); Index out of bounds + } + + @Test + public void bddAliases_UsingGivenWillReturn() { + //given + BDDMockito.given(list.get(Mockito.anyInt())).willReturn("in28Minutes"); + + //THEN + assertThat("in28Minutes", is(list.get(0))); + assertThat("in28Minutes", is(list.get(1))); + } } \ No newline at end of file diff --git a/Testing/Mockito/src/test/java/udemy/mociktoin28minutes/buisness/TodoBusinessImplMockitoTest.java b/Testing/Mockito/src/test/java/udemy/mociktoin28minutes/buisness/TodoBusinessImplMockitoTest.java index 28321f4e..9dfdaa67 100644 --- a/Testing/Mockito/src/test/java/udemy/mociktoin28minutes/buisness/TodoBusinessImplMockitoTest.java +++ b/Testing/Mockito/src/test/java/udemy/mociktoin28minutes/buisness/TodoBusinessImplMockitoTest.java @@ -3,7 +3,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.*; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import udemy.mociktoin28minutes.data.api.TodoService; import java.util.Arrays; @@ -18,76 +18,76 @@ @RunWith(MockitoJUnitRunner.class) //Instead of this we can use @Rule public class TodoBusinessImplMockitoTest { - @Mock - private TodoService todoService; - //TodoService todoService = = mock(TodoService.class); //GIVEN STEP + @Mock + private TodoService todoService; + //TodoService todoService = = mock(TodoService.class); //GIVEN STEP - @InjectMocks - private TodoBusinessImpl todoBusinessImpl; - //TodoBusinessImpl todoBusinessImpl = new TodoBusinessImpl(todoService); //WHEN STEP + @InjectMocks + private TodoBusinessImpl todoBusinessImpl; + //TodoBusinessImpl todoBusinessImpl = new TodoBusinessImpl(todoService); //WHEN STEP - @Captor - private ArgumentCaptor stringArgumentCaptor; - //ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(String.class); + @Captor + private ArgumentCaptor stringArgumentCaptor; + //ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(String.class); - private List allTodoTasks = Arrays.asList("Learn Spring MVC", "Learn Spring", "Learn to Dance"); + private List allTodoTasks = Arrays.asList("Learn Spring MVC", "Learn Spring", "Learn to Dance"); - @Test - public void usingMockito() { - //GIVEN - //1. Mock - //2. todos arglist + @Test + public void usingMockito() { + //GIVEN + //1. Mock + //2. todos arglist - //WHEN - when(todoService.retrieveTodoTasks("Saurabh")).thenReturn(allTodoTasks); - List todos = todoBusinessImpl.retrieveTodoTasksRelatedToSpring("Saurabh"); + //WHEN + when(todoService.retrieveTodoTasks("Saurabh")).thenReturn(allTodoTasks); + List todos = todoBusinessImpl.retrieveTodoTasksRelatedToSpring("Saurabh"); - //THEN - assertEquals(2, todos.size()); - } + //THEN + assertEquals(2, todos.size()); + } - @Test - public void usingMockito_UsingBDD() { - //GIVEN - //1. Mock - //2. todos arglist - BDDMockito.given(todoService.retrieveTodoTasks("Saurabh")).willReturn(allTodoTasks); + @Test + public void usingMockito_UsingBDD() { + //GIVEN + //1. Mock + //2. todos arglist + BDDMockito.given(todoService.retrieveTodoTasks("Saurabh")).willReturn(allTodoTasks); - //when - List todoTask = todoBusinessImpl.retrieveTodoTasksRelatedToSpring("Saurabh"); + //when + List todoTask = todoBusinessImpl.retrieveTodoTasksRelatedToSpring("Saurabh"); - //then - assertThat(todoTask.size(), is(2)); - } + //then + assertThat(todoTask.size(), is(2)); + } - @Test - public void letsTestDeleteNow() { - //GIVEN - //1. Mock - //2. todos arglist + @Test + public void letsTestDeleteNow() { + //GIVEN + //1. Mock + //2. todos arglist - //WHEN - when(todoService.retrieveTodoTasks("Saurabh")).thenReturn(allTodoTasks); - todoBusinessImpl.deleteTodoTasksNotRelatedToSpring("Saurabh"); + //WHEN + when(todoService.retrieveTodoTasks("Saurabh")).thenReturn(allTodoTasks); + todoBusinessImpl.deleteTodoTasksNotRelatedToSpring("Saurabh"); - //THEN - verify(todoService).deleteTodo("Learn to Dance"); + //THEN + verify(todoService).deleteTodo("Learn to Dance"); - verify(todoService, Mockito.never()).deleteTodo("Learn Spring MVC"); + verify(todoService, Mockito.never()).deleteTodo("Learn Spring MVC"); - verify(todoService, Mockito.never()).deleteTodo("Learn Spring"); + verify(todoService, Mockito.never()).deleteTodo("Learn Spring"); - verify(todoService, Mockito.times(1)).deleteTodo("Learn to Dance"); // atLeastOnce, atLeast - } + verify(todoService, Mockito.times(1)).deleteTodo("Learn to Dance"); // atLeastOnce, atLeast + } - @Test - public void captureArgument() { - //WHEN - when(todoService.retrieveTodoTasks("Saurabh")).thenReturn(allTodoTasks); - todoBusinessImpl.deleteTodoTasksNotRelatedToSpring("Saurabh"); + @Test + public void captureArgument() { + //WHEN + when(todoService.retrieveTodoTasks("Saurabh")).thenReturn(allTodoTasks); + todoBusinessImpl.deleteTodoTasksNotRelatedToSpring("Saurabh"); - //THEN - verify(todoService).deleteTodo(stringArgumentCaptor.capture()); - assertEquals("Learn to Dance", stringArgumentCaptor.getValue()); - } + //THEN + verify(todoService).deleteTodo(stringArgumentCaptor.capture()); + assertEquals("Learn to Dance", stringArgumentCaptor.getValue()); + } }