testing....... (Comit needs to be edited later)
Co-authored-by: Rajbir Singh <rajbir.singh@hmmh.de> Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
parent
154c38c29f
commit
57de299b99
1 changed files with 44 additions and 0 deletions
44
src/test/java/de/hmmh/pmt/project/CreateTest.java
Normal file
44
src/test/java/de/hmmh/pmt/project/CreateTest.java
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
package de.hmmh.pmt.project;
|
||||||
|
|
||||||
|
import de.hmmh.pmt.IntegrationTest;
|
||||||
|
import de.hmmh.pmt.dtos.CreateProjectDTO;
|
||||||
|
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.test.web.servlet.RequestBuilder;
|
||||||
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
public class CreateTest extends IntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void successfullyCreate() throws Exception {
|
||||||
|
Mockito
|
||||||
|
.when(this.mockEmployeeApi.findById(Mockito.anyLong()))
|
||||||
|
.thenReturn(new EmployeeResponseDTO());
|
||||||
|
|
||||||
|
CreateProjectDTO createDTO = new CreateProjectDTO();
|
||||||
|
createDTO.setName("Test");
|
||||||
|
createDTO.setGoal("A Test Goal");
|
||||||
|
createDTO.setCustomerId(10L);
|
||||||
|
createDTO.setAdministratorId(10L);
|
||||||
|
createDTO.setStart(LocalDateTime.of(2000, 1, 13, 12, 51));
|
||||||
|
createDTO.setPlannedEnd(LocalDateTime.of(2002, 3, 21, 11, 42));
|
||||||
|
|
||||||
|
RequestBuilder requestBuilder = MockMvcRequestBuilders
|
||||||
|
.post(baseUri + "/project")
|
||||||
|
.accept(MediaType.APPLICATION_JSON)
|
||||||
|
.content(this.objectMapper.writeValueAsString(createDTO))
|
||||||
|
.contentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
this.mvc
|
||||||
|
.perform(requestBuilder)
|
||||||
|
.andExpect(status().isCreated())
|
||||||
|
.andExpect(jsonPath("$.id").exists());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue