PMT-32: testing
This commit is contained in:
parent
5db4d4dab8
commit
7a1cd15552
6 changed files with 36 additions and 8 deletions
|
@ -100,6 +100,9 @@ jobs:
|
||||||
${{ runner.os }}-gradle-
|
${{ runner.os }}-gradle-
|
||||||
- name: "Prepare Gradle"
|
- name: "Prepare Gradle"
|
||||||
run: gradle clean
|
run: gradle clean
|
||||||
|
- name: Install Docker
|
||||||
|
run: |
|
||||||
|
rm $(which docker) && curl -fsSL https://get.docker.com | sh
|
||||||
- name: "Generate OAS Boilerplate"
|
- name: "Generate OAS Boilerplate"
|
||||||
run: gradle generateSwaggerCode
|
run: gradle generateSwaggerCode
|
||||||
- name: "Run Tests"
|
- name: "Run Tests"
|
||||||
|
|
|
@ -45,4 +45,6 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/GetAllProjectsDTO"
|
$ref: "#/components/schemas/GetAllProjectsDTO"
|
||||||
|
500:
|
||||||
|
$ref: "#/components/responses/InternalError"
|
|
@ -95,7 +95,6 @@ swaggerSources {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
withType()
|
|
||||||
withType<Checkstyle> {
|
withType<Checkstyle> {
|
||||||
reports {
|
reports {
|
||||||
xml.required.set(true)
|
xml.required.set(true)
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
|
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
|
||||||
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
||||||
import org.springframework.security.web.session.HttpSessionEventPublisher;
|
import org.springframework.security.web.session.HttpSessionEventPublisher;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
|
|
|
@ -8,19 +8,23 @@ import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
import de.hmmh.pmt.db.ProjectRepository;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc(addFilters = false)
|
||||||
@ActiveProfiles("test")
|
@ActiveProfiles("test")
|
||||||
@ContextConfiguration(initializers = PostgresContextInitializer.class)
|
@ContextConfiguration(initializers = PostgresContextInitializer.class)
|
||||||
public abstract class IntegrationTest {
|
public abstract class IntegrationTest {
|
||||||
|
|
||||||
|
protected final static String baseUri = "/api/v1";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected MockMvc mockMvc;
|
protected MockMvc mvc;
|
||||||
|
@Autowired
|
||||||
//protected Repository repository;
|
protected ProjectRepository projectRepository;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
//repository.deleteAll();
|
projectRepository.deleteAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
src/test/java/de/hmmh/pmt/project/GetAllTest.java
Normal file
21
src/test/java/de/hmmh/pmt/project/GetAllTest.java
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package de.hmmh.pmt.project;
|
||||||
|
|
||||||
|
import de.hmmh.pmt.IntegrationTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.empty;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
public class GetAllTest extends IntegrationTest {
|
||||||
|
@Test
|
||||||
|
void emptyList() throws Exception {
|
||||||
|
assert projectRepository.findAll().isEmpty();
|
||||||
|
mvc
|
||||||
|
.perform(get(baseUri + "/project"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$", empty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue