BAEL-3682 isolate test by cleaning the foo records to fix bulk test run

This commit is contained in:
Yavuz Tas 2021-05-09 23:51:40 +02:00
parent 525abe9831
commit 099b9d514f
1 changed files with 15 additions and 5 deletions

View File

@ -1,5 +1,11 @@
package com.baeldung.web; package com.baeldung.web;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import com.baeldung.persistence.dao.IFooDao;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -8,10 +14,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
/** /**
* *
* We'll start the whole context, but not the server. We'll mock the REST calls instead. * We'll start the whole context, but not the server. We'll mock the REST calls instead.
@ -25,6 +27,14 @@ public class FooControllerAppIntegrationTest {
@Autowired @Autowired
private MockMvc mockMvc; private MockMvc mockMvc;
@Autowired
private IFooDao fooDao;
@Before
public void setup(){
this.fooDao.deleteAll();
}
@Test @Test
public void whenFindPaginatedRequest_thenEmptyResponse() throws Exception { public void whenFindPaginatedRequest_thenEmptyResponse() throws Exception {
this.mockMvc.perform(get("/foos").param("page", "0") this.mockMvc.perform(get("/foos").param("page", "0")