mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Test inventory error handling
This commit is contained in:
parent
cbe7d14a64
commit
4c83c661fe
|
@ -19,6 +19,7 @@ package catering.inventory;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.tuple;
|
import static org.assertj.core.api.Assertions.tuple;
|
||||||
import static org.hamcrest.CoreMatchers.containsString;
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.hamcrest.CoreMatchers.endsWith;
|
import static org.hamcrest.CoreMatchers.endsWith;
|
||||||
import static org.salespointframework.core.Currencies.EURO;
|
import static org.salespointframework.core.Currencies.EURO;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
@ -159,6 +160,42 @@ class InventoryControllerIntegrationTests {
|
||||||
Money.of(0.01, EURO), hasPromotionPrice ? null : Money.of(0.01, EURO));
|
Money.of(0.01, EURO), hasPromotionPrice ? null : Money.of(0.01, EURO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@WithMockUser(username = "admin", roles = "ADMIN")
|
||||||
|
void invalidAddReturnsNiceError() throws Exception {
|
||||||
|
mvc.perform(post("/inventory/add")
|
||||||
|
.param("type", "CONSUMABLE")
|
||||||
|
.param("name", "")
|
||||||
|
.param("quantity", "10")
|
||||||
|
.param("wholesalePrice", "1.00")
|
||||||
|
.param("retailPrice", "2.00"))
|
||||||
|
.andExpect(content().string(containsString("Ungültiger Name")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@WithMockUser(username = "admin", roles = "ADMIN")
|
||||||
|
void missingRetailPriceIsNoError() throws Exception {
|
||||||
|
mvc.perform(post("/inventory/add")
|
||||||
|
.param("type", "CONSUMABLE")
|
||||||
|
.param("name", "MOCK")
|
||||||
|
.param("quantity", "10")
|
||||||
|
.param("wholesalePrice", "1.00")
|
||||||
|
.param("retailPrice", "2.00"))
|
||||||
|
.andExpect(content().string(not(containsString("Ungültiger Angebotspreis"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@WithMockUser(username = "admin", roles = "ADMIN")
|
||||||
|
void invalidEditReturnsNiceError() throws Exception {
|
||||||
|
mvc.perform(post("/inventory/edit/" + anyPid)
|
||||||
|
.param("type", "CONSUMABLE")
|
||||||
|
.param("name", "")
|
||||||
|
.param("quantity", "10")
|
||||||
|
.param("wholesalePrice", "1.00")
|
||||||
|
.param("retailPrice", "2.00"))
|
||||||
|
.andExpect(content().string(containsString("Ungültiger Name")));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function for asserting that protected endpoints are not accessible by
|
* Helper function for asserting that protected endpoints are not accessible by
|
||||||
* unauthentificated users.
|
* unauthentificated users.
|
||||||
|
|
Loading…
Reference in a new issue