Remove var
This commit is contained in:
parent
928920a359
commit
cda04fa8a2
@ -6,10 +6,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@ -37,7 +34,7 @@ class AddEmployeeToProjectActionIntegrationTest {
|
||||
|
||||
@Test
|
||||
void addEmployeeToProjectTest() throws Exception {
|
||||
var project = new ProjectEntity();
|
||||
ProjectEntity project = new ProjectEntity();
|
||||
project.setComment("comment");
|
||||
project.setContractor(1);
|
||||
project.setContractorName("contractorName");
|
||||
@ -54,7 +51,7 @@ class AddEmployeeToProjectActionIntegrationTest {
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isNoContent());
|
||||
|
||||
var updatedProject = projectRepository.findById(1L).get();
|
||||
ProjectEntity updatedProject = projectRepository.findById(1L).get();
|
||||
|
||||
assert updatedProject.getEmployees().contains(312L);
|
||||
}
|
||||
@ -73,7 +70,7 @@ class AddEmployeeToProjectActionIntegrationTest {
|
||||
|
||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
|
||||
|
||||
var response = this.restTemplate.exchange(url, HttpMethod.POST, request, Map.class);
|
||||
ResponseEntity<Map> response = this.restTemplate.exchange(url, HttpMethod.POST, request, Map.class);
|
||||
|
||||
return Objects.requireNonNull(response.getBody()).get("access_token").toString();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.szut.lf8_starter.integration.project;
|
||||
|
||||
import de.szut.lf8_starter.project.ProjectEntity;
|
||||
import de.szut.lf8_starter.project.ProjectRepository;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -12,10 +13,9 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest
|
||||
@ -41,7 +41,7 @@ class CreateProjectActionTest {
|
||||
}
|
||||
""";
|
||||
|
||||
final var contentAsString = this.mockMvc.perform(
|
||||
final String contentAsString = this.mockMvc.perform(
|
||||
post("/projects").content(content).contentType(MediaType.APPLICATION_JSON)
|
||||
)
|
||||
.andExpect(status().isCreated())
|
||||
@ -57,9 +57,9 @@ class CreateProjectActionTest {
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
final var id = Long.parseLong(new JSONObject(contentAsString).get("id").toString());
|
||||
final long id = Long.parseLong(new JSONObject(contentAsString).get("id").toString());
|
||||
|
||||
final var project = this.projectRepository.findById(id);
|
||||
final ProjectEntity project = this.projectRepository.findById(id);
|
||||
assertThat(project.get().getName()).isEqualTo("name");
|
||||
assertThat(project.get().getLeadingEmployee()).isEqualTo(1);
|
||||
assertThat(project.get().getContractor()).isEqualTo(4);
|
||||
|
@ -26,7 +26,7 @@ class GetProjectActionTest {
|
||||
|
||||
@Test
|
||||
void getProjectTest() throws Exception {
|
||||
var project = new ProjectEntity();
|
||||
ProjectEntity project = new ProjectEntity();
|
||||
project.setId(1);
|
||||
project.setComment("comment");
|
||||
project.setContractor(1);
|
||||
|
@ -27,7 +27,7 @@ class ProjectFindAllSuccessTest {
|
||||
|
||||
@Test
|
||||
void findAllProjectsTest() throws Exception {
|
||||
var project = new ProjectEntity();
|
||||
ProjectEntity project = new ProjectEntity();
|
||||
project.setId(1);
|
||||
project.setComment("comment");
|
||||
project.setContractor(1);
|
||||
|
@ -25,7 +25,7 @@ class RemoveProjectActionTest {
|
||||
|
||||
@Test
|
||||
void deleteProjectTest() throws Exception {
|
||||
var project = new ProjectEntity();
|
||||
ProjectEntity project = new ProjectEntity();
|
||||
project.setComment("comment");
|
||||
project.setContractor(1);
|
||||
project.setContractorName("contractorName");
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
@ -55,7 +56,7 @@ class UpdateProjectActionTest {
|
||||
}
|
||||
""";
|
||||
|
||||
final var contentAsString = this.mockMvc.perform(
|
||||
final String contentAsString = this.mockMvc.perform(
|
||||
put("/projects/1").content(content).contentType(MediaType.APPLICATION_JSON)
|
||||
)
|
||||
.andExpect(status().isOk())
|
||||
@ -71,9 +72,9 @@ class UpdateProjectActionTest {
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
final var id = Long.parseLong(new JSONObject(contentAsString).get("id").toString());
|
||||
final long id = Long.parseLong(new JSONObject(contentAsString).get("id").toString());
|
||||
|
||||
final var existingProject = this.projectRepository.findById(id);
|
||||
final Optional<ProjectEntity> existingProject = this.projectRepository.findById(id);
|
||||
assertThat(existingProject.get().getName()).isEqualTo("updatedName");
|
||||
assertThat(existingProject.get().getLeadingEmployee()).isEqualTo(2);
|
||||
assertThat(existingProject.get().getContractor()).isEqualTo(6);
|
||||
@ -103,7 +104,7 @@ class UpdateProjectActionTest {
|
||||
{}
|
||||
""";
|
||||
|
||||
final var contentAsString = this.mockMvc.perform(
|
||||
final String contentAsString = this.mockMvc.perform(
|
||||
put("/projects/1").content(content).contentType(MediaType.APPLICATION_JSON)
|
||||
)
|
||||
.andExpect(status().isOk())
|
||||
@ -120,9 +121,9 @@ class UpdateProjectActionTest {
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
final var id = Long.parseLong(new JSONObject(contentAsString).get("id").toString());
|
||||
final long id = Long.parseLong(new JSONObject(contentAsString).get("id").toString());
|
||||
|
||||
final var existingProject = this.projectRepository.findById(id);
|
||||
final Optional<ProjectEntity> existingProject = this.projectRepository.findById(id);
|
||||
assertThat(existingProject.get().getName()).isEqualTo("name");
|
||||
assertThat(existingProject.get().getLeadingEmployee()).isEqualTo(1);
|
||||
assertThat(existingProject.get().getContractor()).isEqualTo(1);
|
||||
|
Loading…
Reference in New Issue
Block a user