* Java 3590 (#11367)

* JAVA-3590: updating junit-jupiter dependency in the main pom.xml

* resolving unnecessary mockito stubbings exception

* adding junit-bom in dependency management

* fixing tests which were not getting discovered

* Revert "fixing tests which were not getting discovered"

This reverts commit 2e9ed8df42eb96f7e0929167aabbc2ddd374a263.

* fixing tests in ninja, open-liberty and spring-ejb

* removing junit4 dependency and replacing it with junit-vintage-engine

* removing junit4 dependency and replacing it with junit-vintage-engine in testing-modules, maven-modules and aws-lambda

* removing junit dependency and replacing it with junit-vintage-engine

* removing junit and replacing it with junit-vintage-engine

* fixing tests that were not getting discovered due to old version of junit:junit

* updated failsafe plugin configuration to skip integration tests in blade

* fixing tests that were not getting discovered due to old version of junit:junit

* fixing tests in libraries and libraries-2 modules

Co-authored-by: chaos2418 <>

* Java 3590 - fixing integration tests in restx and spring-5-webflux (#11382)

* JAVA-3590: updating junit-jupiter dependency in the main pom.xml

* resolving unnecessary mockito stubbings exception

* adding junit-bom in dependency management

* fixing tests which were not getting discovered

* Revert "fixing tests which were not getting discovered"

This reverts commit 2e9ed8df42eb96f7e0929167aabbc2ddd374a263.

* fixing tests in ninja, open-liberty and spring-ejb

* removing junit4 dependency and replacing it with junit-vintage-engine

* removing junit4 dependency and replacing it with junit-vintage-engine in testing-modules, maven-modules and aws-lambda

* removing junit dependency and replacing it with junit-vintage-engine

* removing junit and replacing it with junit-vintage-engine

* fixing tests that were not getting discovered due to old version of junit:junit

* updated failsafe plugin configuration to skip integration tests in blade

* fixing tests that were not getting discovered due to old version of junit:junit

* fixing tests in libraries and libraries-2 modules

* fixing integration tests in restx and spring-5-webflux

Co-authored-by: chaos2418 <>

Co-authored-by: chaos2418 <92030908+chaos2418@users.noreply.github.com>
This commit is contained in:
Dhawal Kapil
2021-10-29 09:37:04 +05:30
committed by GitHub
parent 1caf806454
commit 1ab0a19d25
111 changed files with 536 additions and 376 deletions
@@ -1,21 +1,18 @@
package com.baeldung.spring.redis.configuration.controller;
import com.baeldung.spring.redis.configuration.entity.Book;
import com.baeldung.spring.redis.configuration.repository.BooksRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.when;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.baeldung.spring.redis.configuration.entity.Book;
import com.baeldung.spring.redis.configuration.repository.BooksRepository;
@RunWith(MockitoJUnitRunner.class)
public class BooksControllerUnitTest {
@@ -44,8 +41,6 @@ public class BooksControllerUnitTest {
@Test
public void whenFindOneNotFound_thenReturnsNull() {
Book book = new Book(BOOK_ID, BOOK_NAME);
when(booksRepository.findById(BOOK_ID)).thenReturn(book);
assertNull(booksController.findOne(OTHER_BOOK_ID));
}
@@ -1,23 +1,20 @@
package com.baeldung.spring.redis.configuration.repository;
import com.baeldung.spring.redis.configuration.entity.Book;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.baeldung.spring.redis.configuration.entity.Book;
@RunWith(MockitoJUnitRunner.class)
public class BooksRepositoryUnitTest {
@@ -55,9 +52,7 @@ public class BooksRepositoryUnitTest {
@Test
public void whenFindByIdNotFound_thenReturnsNull() {
Book book = new Book(BOOK_ID, BOOK_NAME);
when(redisTemplate.opsForValue()).thenReturn(valueOperations);
when(valueOperations.get(BOOK_ID)).thenReturn(book);
assertNull(booksRepository.findById(OTHER_BOOK_ID));
verify(redisTemplate, times(1)).opsForValue();
verify(valueOperations, times(1)).get(OTHER_BOOK_ID);