I want to create some tests for my Controller in Spring Boot. To be concrete I want to create a test for the processing of the form to add a new item. The item belongs to the class Drug and has a collection as a
paramater:
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "drug_pet_types", joinColumns = @JoinColumn(name = "drug_id"), inverseJoinColumns =
@JoinColumn(name = "pet_type_id"))
private Set<PetType> petTypes;`
I also have a Validator for this form, which does not allow any empty/null fields. My question is how to assign a collection as a parameter for mockMvc.perform() method. What do i put instead of the ???????. Here is the Test:
@Test
void testProcessCreationFormSuccess() throws Exception {
mockMvc.perform(post("/drugs/new")
.param("name", "Test_Drug")
.param("batchNumber", "255888")
.param("expirationDate", "2023-05-10")
.param("petTypes", "_____?????????____")
)
.andExpect(status().is3xxRedirection());
}```