mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
parent
44c9eb8f3a
commit
699db13864
|
@ -22,6 +22,7 @@ import org.salespointframework.useraccount.UserAccountManagement;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
@ -200,4 +201,20 @@ public class OrderControllerIntegrationTests {
|
|||
.andExpect(redirectedUrl("/event"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(username = "andi", roles = "CUSTOMER")
|
||||
void addWrongProduct() throws Exception {
|
||||
myCart.setOrderType(OrderType.RENT_A_COOK);
|
||||
Product wrongProduct = inventory.findAll(Pageable.unpaged()).stream()
|
||||
.filter(item -> item.getProduct().getCategories().stream()
|
||||
.noneMatch(c -> c.equals(myCart.getOrderType().toString())))
|
||||
.findFirst().get().getProduct();
|
||||
|
||||
mvc.perform(post("/event/addProduct")
|
||||
.param("pid", wrongProduct.getId().toString())
|
||||
.param("number", "1"))
|
||||
.andExpect(redirectedUrl("/event"))
|
||||
.andExpect(content().string(not(containsString(wrongProduct.getName()))));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue