From ad5ca2189b2e853d86f2111bb2e52f61f3ba7d3e Mon Sep 17 00:00:00 2001 From: tuanvu Date: Tue, 6 Jan 2026 16:15:23 +0100 Subject: [PATCH] tested spring boot --- back_end/pom.xml | 7 --- .../hackathon/FrisbYEE/jpa/metier/User.java | 11 +++-- .../src/main/resources/application.properties | 8 ++-- .../FrisbYEE/FrisbYeeApplicationTests.java | 27 ------------ docker-compose.yml | 43 ++++++++++++++++--- 5 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 back_end/src/test/java/hackathon/FrisbYEE/FrisbYeeApplicationTests.java diff --git a/back_end/pom.xml b/back_end/pom.xml index 4707f2a..f9adb16 100644 --- a/back_end/pom.xml +++ b/back_end/pom.xml @@ -55,13 +55,6 @@ org.thymeleaf.extras thymeleaf-extras-springsecurity6 - - - org.springframework.boot - spring-boot-docker-compose - runtime - true - org.postgresql postgresql diff --git a/back_end/src/main/java/hackathon/FrisbYEE/jpa/metier/User.java b/back_end/src/main/java/hackathon/FrisbYEE/jpa/metier/User.java index 00eb7b0..4739278 100644 --- a/back_end/src/main/java/hackathon/FrisbYEE/jpa/metier/User.java +++ b/back_end/src/main/java/hackathon/FrisbYEE/jpa/metier/User.java @@ -3,6 +3,7 @@ package hackathon.FrisbYEE.jpa.metier; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -16,17 +17,19 @@ import jakarta.persistence.Enumerated; import jakarta.persistence.CascadeType; @Entity -@Getter @Setter @NoArgsConstructor +@Getter +@Setter +@NoArgsConstructor @Access(AccessType.FIELD) - +@Table(name = "app_user") public class User implements Serializable { @Id @GeneratedValue private Integer id; - @Column(unique = true, nullable = false) //pas possible d'avoir le même nom + @Column(unique = true, nullable = false) // pas possible d'avoir le même nom private String name; - @Column (nullable = false) + @Column(nullable = false) private String motDePasse; private String email; diff --git a/back_end/src/main/resources/application.properties b/back_end/src/main/resources/application.properties index e8c426c..655b818 100644 --- a/back_end/src/main/resources/application.properties +++ b/back_end/src/main/resources/application.properties @@ -1,11 +1,9 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/frisbyee -spring.datasource.username=postgres -spring.datasource.password=postgres +spring.datasource.username=frisbyee_user +spring.datasource.password=secret spring.datasource.driver-class-name=org.postgresql.Driver spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect -spring.datasource.url=jdbc:postgresql://localhost:5432/frisbyee -spring.datasource.username=frisbyee_user -spring.datasource.password=secret \ No newline at end of file +server.port=8081 \ No newline at end of file diff --git a/back_end/src/test/java/hackathon/FrisbYEE/FrisbYeeApplicationTests.java b/back_end/src/test/java/hackathon/FrisbYEE/FrisbYeeApplicationTests.java deleted file mode 100644 index 5a4683f..0000000 --- a/back_end/src/test/java/hackathon/FrisbYEE/FrisbYeeApplicationTests.java +++ /dev/null @@ -1,27 +0,0 @@ -package hackathon.FrisbYEE; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.test.web.servlet.client.RestTestClient; - -import hackathon.FrisbYEE.rest.AthleteResource; - - -class FrisbYEEApplicationTests { - - //Controller - private AthleteResource athleteResource; - private RestTestClient mockMvc; - - @BeforeEach - void setUp() { - athleteResource = new AthleteResource(); - mockMvc = RestTestClient.bindToController(athleteResource).build(); - } - - @Test - void shouldReturnUsers() throws Exception { - //mockMvc.perform(get("/api/users")) - // .andExpect(status().isOk()); - } -} diff --git a/docker-compose.yml b/docker-compose.yml index c78c425..aa785fe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,12 +3,12 @@ services: container_name: baeldung-keycloak.openid-provider image: quay.io/keycloak/keycloak:26.4 command: - - start-dev - - --import-realm + - start-dev + - --import-realm ports: - - 8080:8080 + - 8080:8080 volumes: - - ./keycloak/:/opt/keycloak/data/import/ + - ./keycloak/:/opt/keycloak/data/import/ environment: KEYCLOAK_ADMIN: admin KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD} @@ -21,9 +21,42 @@ services: KC_HEALTH_ENABLED: true KC_METRICS_ENABLED: true extra_hosts: - - "host.docker.internal:host-gateway" + - "host.docker.internal:host-gateway" healthcheck: test: ['CMD-SHELL', '[ -f /tmp/HealthCheck.java ] || echo "public class HealthCheck { public static void main(String[] args) throws java.lang.Throwable { System.exit(java.net.HttpURLConnection.HTTP_OK == ((java.net.HttpURLConnection)new java.net.URL(args[0]).openConnection()).getResponseCode() ? 0 : 1); } }" > /tmp/HealthCheck.java && java /tmp/HealthCheck.java http://localhost:8080/auth/health/live'] interval: 5s timeout: 5s retries: 20 + postgres: + image: postgres:16 + container_name: frisbyee-postgres + ports: + - "5432:5432" + environment: + POSTGRES_DB: frisbyee + POSTGRES_USER: frisbyee_user + POSTGRES_PASSWORD: secret + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: + +version: "3.9" + postgres: + image: postgres:16 + container_name: frisbyee-postgres + ports: + - "5432:5432" + environment: + POSTGRES_DB: frisbyee + POSTGRES_USER: frisbyee_user + POSTGRES_PASSWORD: secret + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: + +version: "3.9" +