cleanup
This commit is contained in:
parent
cb84efe63d
commit
5d63544a15
@ -3,14 +3,12 @@ package net.hostsharing.hsadminng.hs.hspackage;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||
import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.UUID;
|
||||
@ -24,8 +22,6 @@ import static org.hamcrest.Matchers.is;
|
||||
webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
classes = HsadminNgApplication.class
|
||||
)
|
||||
// classes = { PackageController.class, JsonObjectMapperConfiguration.class },
|
||||
@Import(JsonObjectMapperConfiguration.class)
|
||||
@Transactional
|
||||
class PackageControllerAcceptanceTest {
|
||||
|
||||
@ -36,7 +32,7 @@ class PackageControllerAcceptanceTest {
|
||||
class ListPackages {
|
||||
|
||||
@Test
|
||||
void withoutNameParameter() throws Exception {
|
||||
void withoutNameParameter() {
|
||||
// @formatter:off
|
||||
RestAssured
|
||||
.given()
|
||||
@ -57,7 +53,7 @@ class PackageControllerAcceptanceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void withNameParameter() throws Exception {
|
||||
void withNameParameter() {
|
||||
// @formatter:off
|
||||
RestAssured
|
||||
.given()
|
||||
@ -78,7 +74,7 @@ class PackageControllerAcceptanceTest {
|
||||
class UpdatePackage {
|
||||
|
||||
@Test
|
||||
void withDescriptionUpdatesDescription() throws Exception {
|
||||
void withDescriptionUpdatesDescription() {
|
||||
|
||||
assumeThat(getDescriptionOfPackage("aaa00"))
|
||||
.isEqualTo("Here can add your own description of package aaa00.");
|
||||
@ -109,7 +105,7 @@ class PackageControllerAcceptanceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void withNullDescriptionUpdatesDescriptionToNull() throws Exception {
|
||||
void withNullDescriptionUpdatesDescriptionToNull() {
|
||||
|
||||
assumeThat(getDescriptionOfPackage("aaa01"))
|
||||
.isEqualTo("Here can add your own description of package aaa01.");
|
||||
@ -137,7 +133,7 @@ class PackageControllerAcceptanceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void withoutDescriptionDoesNothing() throws Exception {
|
||||
void withoutDescriptionDoesNothing() {
|
||||
|
||||
assumeThat(getDescriptionOfPackage("aaa02"))
|
||||
.isEqualTo("Here can add your own description of package aaa02.");
|
||||
|
@ -34,22 +34,6 @@ class PackageControllerRestTest {
|
||||
@MockBean
|
||||
PackageRepository packageRepositoryMock;
|
||||
|
||||
// @Autowired
|
||||
// ObjectMapper objectMapper;
|
||||
//
|
||||
// @Autowired
|
||||
// private Jackson2ObjectMapperBuilder jacksonObjectMapper;
|
||||
//
|
||||
// @Autowired
|
||||
// private PackageController restController;
|
||||
|
||||
// @Before
|
||||
// public void init(){
|
||||
//
|
||||
// objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
|
||||
// objectMapper.registerModule(new JsonNullableModule());
|
||||
// }
|
||||
|
||||
@Nested
|
||||
class ListPackages {
|
||||
|
||||
@ -61,7 +45,7 @@ class PackageControllerRestTest {
|
||||
when(packageRepositoryMock.findAllByOptionalNameLike(null)).thenReturn(givenPacs);
|
||||
|
||||
// when
|
||||
final var pacs = mockMvc.perform(MockMvcRequestBuilders
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.get("/api/packages")
|
||||
.header("current-user", "mike@hostsharing.net")
|
||||
.header("assumed-roles", "customer#xxx.admin")
|
||||
@ -86,7 +70,7 @@ class PackageControllerRestTest {
|
||||
when(packageRepositoryMock.findAllByOptionalNameLike("xxx01")).thenReturn(givenPacs);
|
||||
|
||||
// when
|
||||
final var pacs = mockMvc.perform(MockMvcRequestBuilders
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.get("/api/packages?name=xxx01")
|
||||
.header("current-user", "mike@hostsharing.net")
|
||||
.header("assumed-roles", "customer#xxx.admin")
|
||||
@ -114,7 +98,7 @@ class PackageControllerRestTest {
|
||||
when(packageRepositoryMock.save(any())).thenAnswer(invocation -> invocation.getArgument(0));
|
||||
|
||||
// when
|
||||
final var pacs = mockMvc.perform(MockMvcRequestBuilders
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.patch("/api/packages/" + givenPac.getUuid().toString())
|
||||
.header("current-user", "mike@hostsharing.net")
|
||||
.header("assumed-roles", "customer#xxx.admin")
|
||||
@ -146,7 +130,7 @@ class PackageControllerRestTest {
|
||||
when(packageRepositoryMock.save(any())).thenAnswer(invocation -> invocation.getArgument(0));
|
||||
|
||||
// when
|
||||
final var pacs = mockMvc.perform(MockMvcRequestBuilders
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.patch("/api/packages/" + givenPac.getUuid().toString())
|
||||
.header("current-user", "mike@hostsharing.net")
|
||||
.header("assumed-roles", "customer#xxx.admin")
|
||||
@ -161,8 +145,8 @@ class PackageControllerRestTest {
|
||||
verify(contextMock).setCurrentUser("mike@hostsharing.net");
|
||||
verify(contextMock).assumeRoles("customer#xxx.admin");
|
||||
verify(packageRepositoryMock).save(argThat(entity ->
|
||||
entity.getDescription() == givenPac.getDescription() &&
|
||||
entity.getUuid().equals(givenPac.getUuid())));
|
||||
givenPac.getDescription().equals(entity.getDescription()) &&
|
||||
givenPac.getUuid().equals(entity.getUuid())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user