Fix tests
Some checks failed
Build PR / Build and analyze (pull_request) Failing after 1m6s
Quality Check / Tests (pull_request) Failing after 1m7s
Quality Check / Checkstyle Main (pull_request) Successful in 23s

This commit is contained in:
Phan Huy Tran 2024-10-23 14:46:44 +02:00
parent 010d91131e
commit ffefb5a72e
4 changed files with 8 additions and 15 deletions

@ -3,7 +3,7 @@ Authorization: Bearer {{auth_token}}
Content-Type: application/json Content-Type: application/json
{ {
"firstName": "Jan1", "firstName": "Jan12",
"lastName": "Klattenhoff1", "lastName": "Klattenhoff1",
"street": "Pirolweg 171", "street": "Pirolweg 171",
"postcode": "27777", "postcode": "27777",

@ -2,7 +2,6 @@ package de.szut.lf8_starter.integration.project;
import de.szut.lf8_starter.project.ProjectEntity; import de.szut.lf8_starter.project.ProjectEntity;
import de.szut.lf8_starter.project.ProjectRepository; import de.szut.lf8_starter.project.ProjectRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@ -32,13 +31,10 @@ class AddEmployeeToProjectTest {
@Autowired @Autowired
private ProjectRepository projectRepository; private ProjectRepository projectRepository;
@BeforeEach
public void clear() {
this.projectRepository.deleteAll();
}
@Test @Test
void addEmployeeToProjectTest() throws Exception { void addEmployeeToProjectTest() throws Exception {
this.projectRepository.deleteAll();
ProjectEntity project = new ProjectEntity(); ProjectEntity project = new ProjectEntity();
project.setComment("comment"); project.setComment("comment");
project.setContractor(1); project.setContractor(1);
@ -60,6 +56,7 @@ class AddEmployeeToProjectTest {
assert updatedProject.getEmployees().contains(312L); assert updatedProject.getEmployees().contains(312L);
} }
private String getBearerToken() { private String getBearerToken() {
String url = "https://keycloak.szut.dev/auth/realms/szut/protocol/openid-connect/token"; String url = "https://keycloak.szut.dev/auth/realms/szut/protocol/openid-connect/token";

@ -3,7 +3,6 @@ package de.szut.lf8_starter.integration.project;
import de.szut.lf8_starter.project.ProjectEntity; import de.szut.lf8_starter.project.ProjectEntity;
import de.szut.lf8_starter.project.ProjectRepository; import de.szut.lf8_starter.project.ProjectRepository;
import org.json.JSONObject; import org.json.JSONObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@ -36,13 +35,10 @@ class CreateProjectActionTest {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@BeforeEach
public void clear() {
this.projectRepository.deleteAll();
}
@Test @Test
void createProjectTest() throws Exception { void createProjectTest() throws Exception {
this.projectRepository.deleteAll();
String content = """ String content = """
{ {
"name": "name", "name": "name",

@ -42,7 +42,7 @@ class GetEmployeesFromProjectTest {
project.setLeadingEmployee(1); project.setLeadingEmployee(1);
project.setName("name"); project.setName("name");
project.setStartDate(LocalDate.of(2021, 1, 1)); project.setStartDate(LocalDate.of(2021, 1, 1));
project.setEmployees(List.of(315L)); project.setEmployees(List.of(316L));
this.projectRepository.save(project); this.projectRepository.save(project);
this.mockMvc.perform(get("/projects/1/employees") this.mockMvc.perform(get("/projects/1/employees")
@ -50,7 +50,7 @@ class GetEmployeesFromProjectTest {
).andExpect(status().isOk()) ).andExpect(status().isOk())
.andExpect(jsonPath("project_id").value(1)) .andExpect(jsonPath("project_id").value(1))
.andExpect(jsonPath("project_description").value("comment")) .andExpect(jsonPath("project_description").value("comment"))
.andExpect(jsonPath("employees[0].id").value(315)) .andExpect(jsonPath("employees[0].id").value(316))
.andExpect(jsonPath("employees[0].skillSet[0].skill").value("Product Owner")); .andExpect(jsonPath("employees[0].skillSet[0].skill").value("Product Owner"));
} }