Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Renovate Dependency Scan #62

Merged
merged 2 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion JavaCon/JsonIO/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.5</version>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down
2 changes: 1 addition & 1 deletion JavaCon/SpecialKeywords/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.0.1</version>
<version>17.0.1</version>
</dependency>

</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion JavaCon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<lombok.version>1.18.22</lombok.version>
<commons-io.version>2.11.0</commons-io.version>
<rxjava.version>3.1.1</rxjava.version>
<rxjava.version>3.1.2</rxjava.version>
</properties>

<dependencies>
Expand Down
8 changes: 4 additions & 4 deletions Playground/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.12.4</version>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.4</version>
<version>2.13.0</version>
</dependency>

<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.8.2</version>
<version>2.8.9-ea-1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -46,7 +46,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.2</version>
<version>5.8.1</version>
<scope>compile</scope>
</dependency>

Expand Down
158 changes: 79 additions & 79 deletions Testing/Mockito/src/test/java/ListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -39,81 +39,81 @@
*/

public class ListTest {
@Rule
public MockitoRule mockitoRule = MockitoJUnit.rule(); //Use this instead of RunWith(jUnitRunner)

@Mock
private List<String> 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<String> 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)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> stringArgumentCaptor;
//ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
@Captor
private ArgumentCaptor<String> stringArgumentCaptor;
//ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);

private List<String> allTodoTasks = Arrays.asList("Learn Spring MVC", "Learn Spring", "Learn to Dance");
private List<String> 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<String> todos = todoBusinessImpl.retrieveTodoTasksRelatedToSpring("Saurabh");
//WHEN
when(todoService.retrieveTodoTasks("Saurabh")).thenReturn(allTodoTasks);
List<String> 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<String> todoTask = todoBusinessImpl.retrieveTodoTasksRelatedToSpring("Saurabh");
//when
List<String> 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());
}
}
2 changes: 1 addition & 1 deletion Testing/MutationPITesting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.7.0</version>
<version>1.7.2</version>
<!-- <configuration>-->
<!-- <targetClasses>-->
<!-- <param>com.saurabh.*</param>-->
Expand Down
4 changes: 2 additions & 2 deletions Testing/PluralSight/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.10</version>
<version>5.3.12</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.10</version>
<version>5.3.12</version>
</dependency>
</dependencies>

Expand Down
Loading