PMT-4: Write Happy Path Test
All checks were successful
Quality Check / Validate OAS (push) Successful in 51s
Quality Check / Validate OAS (pull_request) Successful in 1m4s
Quality Check / Linting (push) Successful in 2m6s
Quality Check / Linting (pull_request) Successful in 2m10s
Quality Check / Testing (push) Successful in 2m20s
Quality Check / Static Analysis (push) Successful in 2m24s
Quality Check / Testing (pull_request) Successful in 2m16s
Quality Check / Static Analysis (pull_request) Successful in 2m20s
All checks were successful
Quality Check / Validate OAS (push) Successful in 51s
Quality Check / Validate OAS (pull_request) Successful in 1m4s
Quality Check / Linting (push) Successful in 2m6s
Quality Check / Linting (pull_request) Successful in 2m10s
Quality Check / Testing (push) Successful in 2m20s
Quality Check / Static Analysis (push) Successful in 2m24s
Quality Check / Testing (pull_request) Successful in 2m16s
Quality Check / Static Analysis (pull_request) Successful in 2m20s
This commit is contained in:
parent
96cb218e5c
commit
b907501d8b
1 changed files with 52 additions and 0 deletions
52
src/test/java/de/hmmh/pmt/project/AddEmployeeTest.java
Normal file
52
src/test/java/de/hmmh/pmt/project/AddEmployeeTest.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package de.hmmh.pmt.project;
|
||||
|
||||
import de.hmmh.pmt.IntegrationTest;
|
||||
import de.hmmh.pmt.db.Project;
|
||||
import de.hmmh.pmt.dtos.AddEmployeeDTO;
|
||||
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
||||
import de.hmmh.pmt.employee.dtos.QualificationGetDTO;
|
||||
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 static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AddEmployeeTest extends IntegrationTest {
|
||||
|
||||
@Test
|
||||
void addValidEmployee() throws Exception {
|
||||
EmployeeResponseDTO employee= new EmployeeResponseDTO();
|
||||
employee.setId(2L);
|
||||
employee.setSkillSet(List.of(newQualification(1L)));
|
||||
when(mockEmployeeApi.findById(anyLong()))
|
||||
.thenReturn(employee);
|
||||
|
||||
Map<String, Project> allProjects = createTestProjectData();
|
||||
AddEmployeeDTO addEmployeeDTO = new AddEmployeeDTO();
|
||||
addEmployeeDTO.setEmployeeId(1L);
|
||||
addEmployeeDTO.setQualificationId(1L);
|
||||
RequestBuilder request = MockMvcRequestBuilders
|
||||
.post(baseUri + "/project/" + allProjects.get("research-lab").getId())
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(this.objectMapper.writeValueAsString(addEmployeeDTO));
|
||||
|
||||
this.mvc
|
||||
.perform(request)
|
||||
.andExpect(status().isNoContent());
|
||||
}
|
||||
|
||||
|
||||
private static QualificationGetDTO newQualification(Long id){
|
||||
QualificationGetDTO qualificationGetDTO = new QualificationGetDTO();
|
||||
qualificationGetDTO.setId(id);
|
||||
return qualificationGetDTO;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue