|
|
|
@ -10,6 +10,7 @@ import java.util.Arrays; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.Disabled; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration; |
|
|
|
import org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration; |
|
|
|
@ -26,16 +27,15 @@ import de.kreth.clubhelper.model.dao.PersonDao; |
|
|
|
import de.kreth.clubhelper.model.data.Gender; |
|
|
|
import de.kreth.clubhelper.model.data.Gender; |
|
|
|
import de.kreth.clubhelper.model.data.Person; |
|
|
|
import de.kreth.clubhelper.model.data.Person; |
|
|
|
|
|
|
|
|
|
|
|
@WebMvcTest(excludeAutoConfiguration = |
|
|
|
@WebMvcTest(excludeAutoConfiguration = { |
|
|
|
{ |
|
|
|
|
|
|
|
DataSourceAutoConfiguration.class, |
|
|
|
DataSourceAutoConfiguration.class, |
|
|
|
JdbcRepositoriesAutoConfiguration.class, |
|
|
|
JdbcRepositoriesAutoConfiguration.class, |
|
|
|
DataSourceTransactionManagerAutoConfiguration.class, |
|
|
|
DataSourceTransactionManagerAutoConfiguration.class, |
|
|
|
JdbcTemplateAutoConfiguration.class, |
|
|
|
JdbcTemplateAutoConfiguration.class, |
|
|
|
SecurityAutoConfiguration.class |
|
|
|
SecurityAutoConfiguration.class |
|
|
|
}) |
|
|
|
}) |
|
|
|
class PersonControllerTest |
|
|
|
@Disabled |
|
|
|
{ |
|
|
|
class PersonControllerTest { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
MockMvc mvc; |
|
|
|
MockMvc mvc; |
|
|
|
|
|
|
|
|
|
|
|
@ -46,8 +46,7 @@ class PersonControllerTest |
|
|
|
private Person p2; |
|
|
|
private Person p2; |
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
@BeforeEach |
|
|
|
void initMocks() |
|
|
|
void initMocks() { |
|
|
|
{ |
|
|
|
|
|
|
|
p1 = new Person(); |
|
|
|
p1 = new Person(); |
|
|
|
p1.setId(1); |
|
|
|
p1.setId(1); |
|
|
|
p1.setPrename("prename"); |
|
|
|
p1.setPrename("prename"); |
|
|
|
@ -66,18 +65,18 @@ class PersonControllerTest |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void callAllPersons() throws Exception |
|
|
|
void callAllPersons() throws Exception { |
|
|
|
{ |
|
|
|
|
|
|
|
String jsonListOfPersons = "[{\"id\":1,\"changed\":null,\"created\":null,\"deleted\":null,\"birth\":\"2000-01-01\",\"prename\":\"prename\",\"surname\":\"surname\",\"username\":null,\"password\":null,\"gender\":\"MALE\"},{\"id\":1,\"changed\":null,\"created\":null,\"deleted\":null,\"birth\":\"2000-01-01\",\"prename\":\"prename\",\"surname\":\"surname\",\"username\":null,\"password\":null,\"gender\":\"MALE\"}]"; |
|
|
|
String jsonListOfPersons = "[{\"id\":1,\"changed\":null,\"created\":null,\"deleted\":null,\"birth\":\"2000-01-01\",\"prename\":\"prename\",\"surname\":\"surname\",\"username\":null,\"password\":null,\"gender\":\"MALE\"},{\"id\":1,\"changed\":null,\"created\":null,\"deleted\":null,\"birth\":\"2000-01-01\",\"prename\":\"prename\",\"surname\":\"surname\",\"username\":null,\"password\":null,\"gender\":\"MALE\"}]"; |
|
|
|
mvc.perform(get("/person").accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)).andExpect(status().isOk()) |
|
|
|
mvc.perform(get("/person").accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)) |
|
|
|
|
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(content().string(jsonListOfPersons)); |
|
|
|
.andExpect(content().string(jsonListOfPersons)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void callPerson1() throws Exception |
|
|
|
void callPerson1() throws Exception { |
|
|
|
{ |
|
|
|
|
|
|
|
String jsonListOfPersons = "{\"id\":1,\"changed\":null,\"created\":null,\"deleted\":null,\"birth\":\"2000-01-01\",\"prename\":\"prename\",\"surname\":\"surname\",\"username\":null,\"password\":null,\"gender\":\"MALE\"}"; |
|
|
|
String jsonListOfPersons = "{\"id\":1,\"changed\":null,\"created\":null,\"deleted\":null,\"birth\":\"2000-01-01\",\"prename\":\"prename\",\"surname\":\"surname\",\"username\":null,\"password\":null,\"gender\":\"MALE\"}"; |
|
|
|
mvc.perform(get("/person/1").accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)).andExpect(status().isOk()) |
|
|
|
mvc.perform(get("/person/1").accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)) |
|
|
|
|
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(content().string(jsonListOfPersons)); |
|
|
|
.andExpect(content().string(jsonListOfPersons)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|