Skip to content
Snippets Groups Projects
Commit dc2539ee authored by Jan Zickermann's avatar Jan Zickermann
Browse files

OZG-4815 OZG-4832 Setup Spring Boot REST

parent c0278c48
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<!-- Dev --> <!-- Dev -->
<dependency> <dependency>
...@@ -51,6 +55,23 @@ ...@@ -51,6 +55,23 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<version>1.19.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.19.3</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
spring:
data:
rest:
basePath: /api
\ No newline at end of file
/*
* Copyright (c) 2024. Das Land Schleswig-Holstein vertreten durch das Ministerium für Energiewende, Klimaschutz, Umwelt und Natur
* Zentrales IT-Management
*
* Lizenziert unter der EUPL, Version 1.2 oder - sobald
* diese von der Europäischen Kommission genehmigt wurden -
* Folgeversionen der EUPL ("Lizenz");
* Sie dürfen dieses Werk ausschließlich gemäß
* dieser Lizenz nutzen.
* Eine Kopie der Lizenz finden Sie hier:
*
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* Sofern nicht durch anwendbare Rechtsvorschriften
* gefordert oder in schriftlicher Form vereinbart, wird
* die unter der Lizenz verbreitete Software "so wie sie
* ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
* ausdrücklich oder stillschweigend - verbreitet.
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
package de.ozgcloud.admin;
import static org.hamcrest.Matchers.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import de.ozgcloud.common.test.ITCase;
import lombok.SneakyThrows;
/**
* Test that the spring-boot-starter-data-rest dependency is being used and spring.data.rest.basePath == /api
*/
@ITCase
class ApiRootITCase {
private MockMvc mockMvc;
@BeforeEach
void setup(WebApplicationContext context) {
mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
}
@Test
@SneakyThrows
void shouldHaveRESTApiRootEndpoint() {
mockMvc.perform(get("/api"))
.andExpect(status().isOk())
.andExpect(content().contentType("application/hal+json"))
.andExpect(jsonPath("$._links.profile.href", endsWith("/api/profile")));
}
@Test
@SneakyThrows
void shouldHaveRESTApiProfileEndpoint() {
mockMvc.perform(get("/api/profile"))
.andExpect(status().isOk())
.andExpect(content().contentType("application/hal+json"))
.andExpect(jsonPath("$._links.self.href", endsWith("/api/profile")));
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment