PMT-32: testing
Some checks failed
Quality Check / Validate OAS (push) Successful in 37s
Quality Check / Testing (push) Failing after 1m7s
Quality Check / Linting (push) Successful in 1m14s
Quality Check / Static Analysis (push) Successful in 1m19s

This commit is contained in:
Ole Kück 2024-09-30 16:24:36 +02:00 committed by Dominik Säume
parent 5db4d4dab8
commit 9e811d12b7
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
4 changed files with 33 additions and 7 deletions

View file

@ -46,3 +46,5 @@ paths:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/GetAllProjectsDTO" $ref: "#/components/schemas/GetAllProjectsDTO"
500:
$ref: "#/components/responses/InternalError"

View file

@ -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

View file

@ -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 {
@Autowired protected final static String baseUri = "/api/v1";
protected MockMvc mockMvc;
//protected Repository repository; @Autowired
protected MockMvc mvc;
@Autowired
protected ProjectRepository projectRepository;
@BeforeEach @BeforeEach
void setUp() { void setUp() {
//repository.deleteAll(); projectRepository.deleteAll();
} }
} }

View 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()));
}
}