added shouldNotCreateProjectWhenAdministratorDoesNotExist test
Some checks failed
Quality Check / Validate OAS (push) Successful in 51s
Quality Check / Validate OAS (pull_request) Successful in 1m4s
Quality Check / Linting (push) Failing after 1m26s
Quality Check / Static Analysis (push) Failing after 1m27s
Quality Check / Testing (push) Failing after 1m29s
Quality Check / Linting (pull_request) Failing after 1m29s
Quality Check / Testing (pull_request) Failing after 1m26s
Quality Check / Static Analysis (pull_request) Failing after 1m28s
Some checks failed
Quality Check / Validate OAS (push) Successful in 51s
Quality Check / Validate OAS (pull_request) Successful in 1m4s
Quality Check / Linting (push) Failing after 1m26s
Quality Check / Static Analysis (push) Failing after 1m27s
Quality Check / Testing (push) Failing after 1m29s
Quality Check / Linting (pull_request) Failing after 1m29s
Quality Check / Testing (pull_request) Failing after 1m26s
Quality Check / Static Analysis (pull_request) Failing after 1m28s
This commit is contained in:
parent
7c9b8e919d
commit
80a8a74373
1 changed files with 30 additions and 3 deletions
|
@ -5,12 +5,16 @@ import de.hmmh.pmt.dtos.CreateProjectDTO;
|
||||||
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
import org.springframework.http.HttpStatusCode;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.web.servlet.RequestBuilder;
|
import org.springframework.test.web.servlet.RequestBuilder;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
@ -18,8 +22,7 @@ public class CreateTest extends IntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void successfullyCreate() throws Exception {
|
void successfullyCreate() throws Exception {
|
||||||
Mockito
|
when(this.mockEmployeeApi.findById(Mockito.anyLong()))
|
||||||
.when(this.mockEmployeeApi.findById(Mockito.anyLong()))
|
|
||||||
.thenReturn(new EmployeeResponseDTO());
|
.thenReturn(new EmployeeResponseDTO());
|
||||||
|
|
||||||
CreateProjectDTO createDTO = new CreateProjectDTO();
|
CreateProjectDTO createDTO = new CreateProjectDTO();
|
||||||
|
@ -49,7 +52,7 @@ public class CreateTest extends IntegrationTest {
|
||||||
createDTO.setName("Test");
|
createDTO.setName("Test");
|
||||||
createDTO.setGoal("A Test Goal");
|
createDTO.setGoal("A Test Goal");
|
||||||
createDTO.setCustomerId(10L);
|
createDTO.setCustomerId(10L);
|
||||||
createDTO.setAdministratorId(10L);
|
createDTO.setAdministratorId(1L);
|
||||||
createDTO.setStart(LocalDateTime.of(2000, 1, 13, 12, 51));
|
createDTO.setStart(LocalDateTime.of(2000, 1, 13, 12, 51));
|
||||||
createDTO.setPlannedEnd(LocalDateTime.of(2002, 3, 21, 11, 42));
|
createDTO.setPlannedEnd(LocalDateTime.of(2002, 3, 21, 11, 42));
|
||||||
|
|
||||||
|
@ -67,6 +70,30 @@ public class CreateTest extends IntegrationTest {
|
||||||
.andExpect(status().isConflict());
|
.andExpect(status().isConflict());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldNotCreateProjectWhenAdministratorDoesNotExist() throws Exception {
|
||||||
|
HttpClientErrorException httpClientErrorException = mock(HttpClientErrorException.class);
|
||||||
|
|
||||||
|
when(httpClientErrorException.getStatusCode()).thenReturn(HttpStatusCode.valueOf(404));
|
||||||
|
|
||||||
|
when(this.mockEmployeeApi.findById(1L))
|
||||||
|
.thenThrow(httpClientErrorException);
|
||||||
|
|
||||||
|
CreateProjectDTO createDTO = new CreateProjectDTO();
|
||||||
|
createDTO.setName("Test");
|
||||||
|
createDTO.setGoal("A Test Goal");
|
||||||
|
createDTO.setCustomerId(10L);
|
||||||
|
createDTO.setAdministratorId(1L);
|
||||||
|
createDTO.setStart(LocalDateTime.of(2000, 1, 13, 12, 51));
|
||||||
|
createDTO.setPlannedEnd(LocalDateTime.of(2002, 3, 21, 11, 42));
|
||||||
|
|
||||||
|
RequestBuilder projectRequestBuilder = createProjectRequestBuilder(createDTO);
|
||||||
|
|
||||||
|
this.mvc
|
||||||
|
.perform(projectRequestBuilder)
|
||||||
|
.andExpect(status().isNotFound());
|
||||||
|
}
|
||||||
|
|
||||||
private RequestBuilder createProjectRequestBuilder(CreateProjectDTO createDTO) throws Exception {
|
private RequestBuilder createProjectRequestBuilder(CreateProjectDTO createDTO) throws Exception {
|
||||||
|
|
||||||
return MockMvcRequestBuilders
|
return MockMvcRequestBuilders
|
||||||
|
|
Loading…
Reference in a new issue