PMT-26 created Test
Some checks failed
Quality Check / Validate OAS (push) Successful in 50s
Quality Check / Validate OAS (pull_request) Successful in 1m7s
Quality Check / Linting (push) Successful in 2m6s
Quality Check / Linting (pull_request) Successful in 2m13s
Quality Check / Testing (push) Successful in 2m21s
Quality Check / Static Analysis (push) Failing after 2m25s
Quality Check / Testing (pull_request) Successful in 2m18s
Quality Check / Static Analysis (pull_request) Failing after 2m21s
Some checks failed
Quality Check / Validate OAS (push) Successful in 50s
Quality Check / Validate OAS (pull_request) Successful in 1m7s
Quality Check / Linting (push) Successful in 2m6s
Quality Check / Linting (pull_request) Successful in 2m13s
Quality Check / Testing (push) Successful in 2m21s
Quality Check / Static Analysis (push) Failing after 2m25s
Quality Check / Testing (pull_request) Successful in 2m18s
Quality Check / Static Analysis (pull_request) Failing after 2m21s
This commit is contained in:
parent
8fa066b374
commit
be0b7b8f7d
2 changed files with 73 additions and 0 deletions
|
@ -165,6 +165,12 @@ public abstract class IntegrationTest {
|
|||
allocation1ToOverlapA.setRole(TEST_QUALIFICATION_A_ID);
|
||||
allocations.put("1>overlap-a", allocation1ToOverlapA);
|
||||
|
||||
Allocation allocation1ToAiResearch = new Allocation();
|
||||
allocation1ToAiResearch.setProject(allProjects.get("ai-research"));
|
||||
allocation1ToAiResearch.setEmployeeId(TEST_EMPLOYEE_A_ID);
|
||||
allocation1ToAiResearch.setRole(TEST_QUALIFICATION_A_ID);
|
||||
allocations.put("1>ai-research", allocation1ToAiResearch);
|
||||
|
||||
allocationRepository.saveAllAndFlush(allocations.values());
|
||||
return allocations;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package de.hmmh.pmt.project;
|
||||
|
||||
import de.hmmh.pmt.IntegrationTest;
|
||||
import de.hmmh.pmt.db.Allocation;
|
||||
import de.hmmh.pmt.db.Project;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.RequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
public class GetAllEmployeesByProjectTest extends IntegrationTest {
|
||||
|
||||
@Test
|
||||
void shouldReturnNotFoundWhenProjectDoesNotExist() throws Exception {
|
||||
createTestProjectData();
|
||||
|
||||
this.mvc
|
||||
.perform(getRequest(50L))
|
||||
.andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnOkWhenProjectHasNoEmployees() throws Exception {
|
||||
Map<String, Project> allProjects = createTestProjectData();
|
||||
|
||||
this.mvc
|
||||
.perform(getRequest(allProjects.get("research-lab").getId()))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnListOfEmployeesWhenAllParametersAreValid() throws Exception {
|
||||
Map<String, Project> allProjects = createTestProjectData();
|
||||
Map<String, Allocation> allocations = createTestAllocationData(allProjects);
|
||||
|
||||
this.mvc
|
||||
.perform(getRequest(allProjects.get("ai-research").getId()))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnInternalServer() throws Exception {
|
||||
when(this.mockEmployeeApi.findAll1())
|
||||
.thenThrow(new RestClientException("Internal Server Error"));
|
||||
|
||||
Map<String, Project> allProjects = createTestProjectData();
|
||||
Map<String, Allocation> allocations = createTestAllocationData(allProjects);
|
||||
|
||||
this.mvc
|
||||
.perform(getRequest(allProjects.get("ai-research").getId()))
|
||||
.andExpect(status().isInternalServerError());
|
||||
}
|
||||
|
||||
private RequestBuilder getRequest(Long projectId) {
|
||||
return MockMvcRequestBuilders
|
||||
.get(baseUri + "/project/" + projectId + "/employees")
|
||||
.contentType(MediaType.APPLICATION_JSON);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue