BAEL-19890: Upgrade to Spring Boot 2.2.2 and refactor test method
This commit is contained in:
parent
8469804de9
commit
017d8d2e8b
@ -128,7 +128,7 @@
|
|||||||
<geronimo-json_1.1_spec.version>1.0</geronimo-json_1.1_spec.version>
|
<geronimo-json_1.1_spec.version>1.0</geronimo-json_1.1_spec.version>
|
||||||
<commons-collections4.version>4.1</commons-collections4.version>
|
<commons-collections4.version>4.1</commons-collections4.version>
|
||||||
<project-reactor-test>3.1.6.RELEASE</project-reactor-test>
|
<project-reactor-test>3.1.6.RELEASE</project-reactor-test>
|
||||||
<spring-boot.version>2.2.1.RELEASE</spring-boot.version>
|
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package com.baeldung.reactive.functional;
|
package com.baeldung.reactive.functional;
|
||||||
|
|
||||||
import static org.mockito.BDDMockito.given;
|
import com.baeldung.webflux.Employee;
|
||||||
import static org.mockito.Mockito.verify;
|
import com.baeldung.webflux.EmployeeRepository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -15,13 +11,15 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||||
|
|
||||||
import com.baeldung.webflux.Employee;
|
|
||||||
import com.baeldung.webflux.EmployeeRepository;
|
|
||||||
|
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.mockito.BDDMockito.given;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = EmployeeSpringFunctionalApplication.class)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = EmployeeSpringFunctionalApplication.class)
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
@ -58,15 +56,11 @@ public class EmployeeSpringFunctionalIntegrationTest {
|
|||||||
.bindToRouterFunction(config.getAllEmployeesRoute())
|
.bindToRouterFunction(config.getAllEmployeesRoute())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<Employee> employeeList = new ArrayList<>();
|
List<Employee> employees = Arrays.asList(
|
||||||
|
new Employee("1", "Employee 1"),
|
||||||
|
new Employee("2", "Employee 2"));
|
||||||
|
|
||||||
Employee employee1 = new Employee("1", "Employee 1");
|
Flux<Employee> employeeFlux = Flux.fromIterable(employees);
|
||||||
Employee employee2 = new Employee("2", "Employee 2");
|
|
||||||
|
|
||||||
employeeList.add(employee1);
|
|
||||||
employeeList.add(employee2);
|
|
||||||
|
|
||||||
Flux<Employee> employeeFlux = Flux.fromIterable(employeeList);
|
|
||||||
given(employeeRepository.findAllEmployees()).willReturn(employeeFlux);
|
given(employeeRepository.findAllEmployees()).willReturn(employeeFlux);
|
||||||
|
|
||||||
client.get()
|
client.get()
|
||||||
@ -75,7 +69,7 @@ public class EmployeeSpringFunctionalIntegrationTest {
|
|||||||
.expectStatus()
|
.expectStatus()
|
||||||
.isOk()
|
.isOk()
|
||||||
.expectBodyList(Employee.class)
|
.expectBodyList(Employee.class)
|
||||||
.isEqualTo(employeeList);
|
.isEqualTo(employees);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user