Compare commits
1 commit
a61791f3ef
...
da7905a3a8
Author | SHA1 | Date | |
---|---|---|---|
da7905a3a8 |
3 changed files with 41 additions and 83 deletions
|
@ -28,8 +28,6 @@ components:
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/ProjectInfo"
|
$ref: "#/components/schemas/ProjectInfo"
|
||||||
responses:
|
responses:
|
||||||
UnAuthorized:
|
|
||||||
description: "Un Authorized"
|
|
||||||
InternalError:
|
InternalError:
|
||||||
description: "Internal Server Error"
|
description: "Internal Server Error"
|
||||||
content:
|
content:
|
||||||
|
@ -48,7 +46,5 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/GetAllProjectsDTO"
|
$ref: "#/components/schemas/GetAllProjectsDTO"
|
||||||
401:
|
|
||||||
$ref: "#/components/responses/UnAuthorized"
|
|
||||||
500:
|
500:
|
||||||
$ref: "#/components/responses/InternalError"
|
$ref: "#/components/responses/InternalError"
|
|
@ -1,7 +1,7 @@
|
||||||
package de.hmmh.pmt;
|
package de.hmmh.pmt;
|
||||||
|
|
||||||
import de.hmmh.pmt.db.Project;
|
//import de.hmmh.pmt.db.Project;
|
||||||
import de.hmmh.pmt.db.ProjectRepository;
|
//import de.hmmh.pmt.db.ProjectRepository;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -11,7 +11,6 @@ import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc(addFilters = false)
|
@AutoConfigureMockMvc(addFilters = false)
|
||||||
|
@ -22,83 +21,53 @@ public abstract class IntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected MockMvc mvc;
|
protected MockMvc mvc;
|
||||||
@Autowired
|
//@Autowired
|
||||||
protected ProjectRepository projectRepository;
|
//protected ProjectRepository projectRepository;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
projectRepository.deleteAll();
|
//projectRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void cleanUp() {
|
void cleanUp() {
|
||||||
projectRepository.deleteAll();
|
//projectRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Project> createTestProjectData() {
|
protected void createTestData() {
|
||||||
Project project1 = new Project(
|
/*Project testProject1 = new Project(
|
||||||
1L,
|
0L,
|
||||||
"Build a Dream Space Station",
|
"testName1",
|
||||||
"Launch a self-sustaining space habitat!",
|
"testGoaaaaaaaal!",
|
||||||
42L,
|
0L,
|
||||||
101L,
|
0L,
|
||||||
LocalDateTime.of(2024, 3, 1, 10, 0),
|
LocalDateTime.of(2001, 9, 11, 13, 34),
|
||||||
LocalDateTime.of(2028, 6, 30, 18, 0),
|
LocalDateTime.of(2002, 8, 13, 14, 34),
|
||||||
LocalDateTime.of(2029, 12, 15, 16, 30)
|
LocalDateTime.of(2003, 7, 12, 23, 34)
|
||||||
);
|
);
|
||||||
Project project2 = new Project(
|
Project testProject2 = new Project(
|
||||||
2L,
|
0L,
|
||||||
"Underwater Research Lab",
|
"testName2",
|
||||||
"Discover new marine species!",
|
"testGoaaaaaaaal!",
|
||||||
73L,
|
0L,
|
||||||
202L,
|
0L,
|
||||||
LocalDateTime.of(2025, 5, 22, 8, 45),
|
LocalDateTime.of(2009, 9, 11, 13, 34),
|
||||||
LocalDateTime.of(2027, 11, 5, 17, 0),
|
LocalDateTime.of(2009, 12, 13, 14, 34),
|
||||||
LocalDateTime.of(2027, 10, 20, 14, 0)
|
LocalDateTime.of(2010, 7, 12, 23, 34)
|
||||||
);
|
);
|
||||||
Project project3 = new Project(
|
Project testProject3 = new Project(
|
||||||
3L,
|
0L,
|
||||||
"AI-Powered Smart City",
|
"testName3",
|
||||||
"Create the world's most advanced smart city!",
|
"testGoaaaaaaaal!",
|
||||||
89L,
|
0L,
|
||||||
303L,
|
0L,
|
||||||
LocalDateTime.of(2026, 9, 14, 12, 0),
|
LocalDateTime.of(2010, 9, 11, 13, 34),
|
||||||
LocalDateTime.of(2030, 4, 1, 9, 30),
|
LocalDateTime.of(2012, 8, 13, 14, 34),
|
||||||
LocalDateTime.of(2030, 5, 2, 15, 0)
|
LocalDateTime.of(2013, 7, 12, 23, 34)
|
||||||
);
|
|
||||||
Project project4 = new Project(
|
|
||||||
4L,
|
|
||||||
"Renewable Energy Revolution",
|
|
||||||
"Replace all fossil fuels with renewables!",
|
|
||||||
56L,
|
|
||||||
404L,
|
|
||||||
LocalDateTime.of(2023, 7, 19, 11, 30),
|
|
||||||
LocalDateTime.of(2029, 12, 31, 20, 0),
|
|
||||||
LocalDateTime.of(2029, 10, 5, 18, 45)
|
|
||||||
);
|
|
||||||
Project project5 = new Project(
|
|
||||||
5L,
|
|
||||||
"Virtual Reality Theme Park",
|
|
||||||
"Build a fully immersive VR theme park!",
|
|
||||||
99L,
|
|
||||||
505L,
|
|
||||||
LocalDateTime.of(2024, 2, 28, 9, 15),
|
|
||||||
LocalDateTime.of(2026, 9, 30, 17, 0),
|
|
||||||
LocalDateTime.of(2026, 8, 15, 13, 45)
|
|
||||||
);
|
|
||||||
|
|
||||||
projectRepository.save(project1);
|
|
||||||
projectRepository.save(project2);
|
|
||||||
projectRepository.save(project3);
|
|
||||||
projectRepository.save(project4);
|
|
||||||
projectRepository.save(project5);
|
|
||||||
|
|
||||||
return List.of(
|
|
||||||
project1,
|
|
||||||
project2,
|
|
||||||
project3,
|
|
||||||
project4,
|
|
||||||
project5
|
|
||||||
);
|
);
|
||||||
|
projectRepository.save(testProject1);
|
||||||
|
projectRepository.save(testProject2);
|
||||||
|
projectRepository.save(testProject3);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,8 @@ package de.hmmh.pmt.project;
|
||||||
|
|
||||||
import de.hmmh.pmt.IntegrationTest;
|
import de.hmmh.pmt.IntegrationTest;
|
||||||
|
|
||||||
import de.hmmh.pmt.db.Project;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.empty;
|
import static org.hamcrest.Matchers.empty;
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
@ -19,21 +16,17 @@ public class GetAllTest extends IntegrationTest {
|
||||||
mvc
|
mvc
|
||||||
.perform(get(baseUri + "/project"))
|
.perform(get(baseUri + "/project"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$", empty()))
|
.andExpect(jsonPath("$", empty()));
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void multipleProjects() throws Exception {
|
void multipleProjects() throws Exception {
|
||||||
List<Project> allProjects = createTestProjectData();
|
createTestData();
|
||||||
|
|
||||||
mvc
|
mvc
|
||||||
.perform(get(baseUri + "/project"))
|
.perform(get(baseUri + "/project"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$", hasSize(allProjects.size())))
|
.andExpect(jsonPath("$", hasSize(3)));
|
||||||
.andExpect(jsonPath("$[*].id").exists())
|
|
||||||
.andExpect(jsonPath("$[*].name").exists())
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue