PMT-4: Mitarbeiter zu einem projekt hinzufügen #14
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