From ce437b28c4e6008a1431f56bf4cba55aeb0600a4 Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Thu, 4 May 2023 08:53:19 +0000 Subject: [PATCH 01/20] Added Repository Junit Test --- src/main/resources/application.properties | 2 +- .../repository/NoteRepositoryTest.java | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/example/easynotes/repository/NoteRepositoryTest.java diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d357d46..db495c2 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ ## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false spring.datasource.username = root -spring.datasource.password = callicoder +spring.datasource.password = Come1999? ## Hibernate Properties diff --git a/src/test/java/com/example/easynotes/repository/NoteRepositoryTest.java b/src/test/java/com/example/easynotes/repository/NoteRepositoryTest.java new file mode 100644 index 0000000..e97597b --- /dev/null +++ b/src/test/java/com/example/easynotes/repository/NoteRepositoryTest.java @@ -0,0 +1,51 @@ +package com.example.easynotes.repository; + +import com.example.easynotes.model.Note; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.ArrayList; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.*; + +@SpringBootTest +class NoteRepositoryTest { + + @Autowired + NoteRepository noteRepository; + + + @Test + void deleteNote(){ + Note note = new Note(); + note.setId(2l); + note.setTitle("Today's List"); + note.setContent("Buy Book today"); + noteRepository.delete(note); + + } + @Test + void getAllNotes(){ + + ArrayList arrayList = (ArrayList) noteRepository.findAll(); + + assertNotNull(arrayList); + } + + @Test + void addNote(){ + + Note note = new Note(); + note.setTitle("Today's List"); + note.setContent("Read a book"); + + noteRepository.save(note); + + + + } + + +} \ No newline at end of file From 299366affbc30a7b3c4491ef84ba03f4fd4e9619 Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Thu, 4 May 2023 09:04:18 +0000 Subject: [PATCH 02/20] Added Workflow file --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9efdff5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + push: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 1.8 + uses: actions/setup-java@v2 + with: + java-version: 1.8 + + - name: Build with Maven + run: mvn clean install + + - name: Run tests + run: mvn test From c6e91f43cf5581ab23b5fab26bc3067377490feb Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Thu, 4 May 2023 09:06:47 +0000 Subject: [PATCH 03/20] remove workflows file --- .github/workflows/ci.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 9efdff5..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: CI - -on: - push: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up JDK 1.8 - uses: actions/setup-java@v2 - with: - java-version: 1.8 - - - name: Build with Maven - run: mvn clean install - - - name: Run tests - run: mvn test From d1a32d75b9075ba081e75b7b6c9c3076fa4d6252 Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 09:08:41 +0000 Subject: [PATCH 04/20] add ci.yml workflow filr --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0edf106 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + push: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 1.8 + uses: actions/setup-java@v2 + with: + java-version: 1.8 + + - name: Build with Maven + run: mvn clean install + + - name: Run tests + run: mvn test From 7f815ff606d5df400c81afd45396d751740eaef7 Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Thu, 4 May 2023 09:15:02 +0000 Subject: [PATCH 05/20] make change to index controller --- .../java/com/example/easynotes/controller/IndexController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/easynotes/controller/IndexController.java b/src/main/java/com/example/easynotes/controller/IndexController.java index f9c5ea4..ea15260 100644 --- a/src/main/java/com/example/easynotes/controller/IndexController.java +++ b/src/main/java/com/example/easynotes/controller/IndexController.java @@ -11,6 +11,6 @@ public class IndexController { @GetMapping public String sayHello() { - return "Hello and Welcome to the EasyNotes application. You can create a new Note by making a POST request to /api/notes endpoint."; + return "Hello and Welcome to the Note application. You can create a new Note by making a POST request to this url /api/notes endpoint."; } } From adcb4a15b8c6c3222c391298a19872aca0eb5cca Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 09:22:52 +0000 Subject: [PATCH 06/20] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0edf106..5481dab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [ main ] + branches: [ master ] jobs: build: From 51745b4d1867f9f08ccdb9058708f852dfe4252d Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 09:28:03 +0000 Subject: [PATCH 07/20] Update ci.yml --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5481dab..3b9eb72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,12 +11,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v1 - - name: Set up JDK 1.8 - uses: actions/setup-java@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 8 - name: Build with Maven run: mvn clean install From b4260bb6adde0acd45477b5ef53268013509e19b Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 09:32:09 +0000 Subject: [PATCH 08/20] Update ci.yml file --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b9eb72..b4a19ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,12 +11,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v1 + - name: Set up JDK 11 + uses: actions/setup-java@v2 with: - java-version: 8 + java-version: 11 - name: Build with Maven run: mvn clean install From 27f9f975cec5033add523d6646dbc961b4d8be1c Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 09:36:46 +0000 Subject: [PATCH 09/20] Update ci.yml --- .github/workflows/ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4a19ea..799ceab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,7 @@ on: branches: [ master ] jobs: - build: - + build-and-deploy: runs-on: ubuntu-latest steps: @@ -21,5 +20,12 @@ jobs: - name: Build with Maven run: mvn clean install - - name: Run tests + - name: Run tests with Maven run: mvn test + + - name: Deploy to Maven repository + uses: maven-publish/action@v1 + with: + server-id: my-maven-server + repo-url: https://my-maven-repo.com/repository/maven-releases/ + distribution: repoUrl From b37e881cfba59fcf108c0f29eb2121da654ab22d Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Thu, 4 May 2023 09:39:34 +0000 Subject: [PATCH 10/20] updated the pom file --- pom.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index baec0d9..fffa504 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ jar easy-notes - Rest API for a Simple Note Taking Application + Rest API for a Simple Note-Taking Application org.springframework.boot @@ -63,5 +63,13 @@ + + + my-maven-server + My Maven Repository + https://my-maven-repo.com/repository/maven-releases/ + + + From bc0baf60038cd0782d0ed96d94824fa437d8bc3a Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 09:43:41 +0000 Subject: [PATCH 11/20] Update ci.yml --- .github/workflows/ci.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 799ceab..cd8b16a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: branches: [ master ] jobs: - build-and-deploy: + build-and-test: runs-on: ubuntu-latest steps: @@ -22,10 +22,3 @@ jobs: - name: Run tests with Maven run: mvn test - - - name: Deploy to Maven repository - uses: maven-publish/action@v1 - with: - server-id: my-maven-server - repo-url: https://my-maven-repo.com/repository/maven-releases/ - distribution: repoUrl From 4d9e3079e26da918a35079becb428049a4a57839 Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 09:55:24 +0000 Subject: [PATCH 12/20] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd8b16a..c502587 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v2 - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/setup-java@v1 with: java-version: 11 From 262b1f259a70aaa80788df1f0a79f4ba151bb38d Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Thu, 4 May 2023 10:02:04 +0000 Subject: [PATCH 13/20] updated the pom file --- pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pom.xml b/pom.xml index fffa504..b093c36 100644 --- a/pom.xml +++ b/pom.xml @@ -63,13 +63,5 @@ - - - my-maven-server - My Maven Repository - https://my-maven-repo.com/repository/maven-releases/ - - - From 696c2b6395d7b03d3a10a8ddcc99b242bd2a04c5 Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Thu, 4 May 2023 10:51:15 +0000 Subject: [PATCH 14/20] updated the pom file --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index db495c2..2034f8a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ ## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) -spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false +spring.datasource.url=jdbc:mysql://localhost:3306/notes_app?useSSL=false&serverTimezone=UTC spring.datasource.username = root spring.datasource.password = Come1999? From ce3c7e2a47f01f49de1d52154a3791a95bd464a4 Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 11:04:25 +0000 Subject: [PATCH 15/20] Update ci.yml --- .github/workflows/ci.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c502587..ba6d255 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,10 @@ -name: CI +name: JUnit Test -on: - push: - branches: [ master ] +on: [push, pull_request] jobs: - build-and-test: - runs-on: ubuntu-latest + build: + runs-on: windows-latest steps: - name: Checkout code @@ -20,5 +18,5 @@ jobs: - name: Build with Maven run: mvn clean install - - name: Run tests with Maven + - name: Run tests run: mvn test From 2e7bd455c6b846a21e25671bbb44387058baebef Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 11:06:02 +0000 Subject: [PATCH 16/20] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba6d255..c907891 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,10 @@ name: JUnit Test -on: [push, pull_request] +on: [push] jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - name: Checkout code From 20f49d70281ac2736a637a7e028850093f47ea08 Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Thu, 4 May 2023 11:15:15 +0000 Subject: [PATCH 17/20] Update ci.yml --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c907891..81ecf48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,3 @@ jobs: - name: Build with Maven run: mvn clean install - - name: Run tests - run: mvn test From d8ec1f25d3132afde433bbdedaa99a5830325154 Mon Sep 17 00:00:00 2001 From: EnochEnagbem <80125546+EnochEnagbem@users.noreply.github.com> Date: Fri, 5 May 2023 07:26:41 +0000 Subject: [PATCH 18/20] Update ci.yml --- .github/workflows/ci.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81ecf48..c502587 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,11 @@ -name: JUnit Test +name: CI -on: [push] +on: + push: + branches: [ master ] jobs: - build: + build-and-test: runs-on: ubuntu-latest steps: @@ -18,3 +20,5 @@ jobs: - name: Build with Maven run: mvn clean install + - name: Run tests with Maven + run: mvn test From 3623db26ff4d03afa0254d4718180f91d9b0da42 Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Fri, 5 May 2023 07:42:15 +0000 Subject: [PATCH 19/20] update application.properties file --- src/main/resources/application.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 2034f8a..fbcc976 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,8 @@ ## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) -spring.datasource.url=jdbc:mysql://localhost:3306/notes_app?useSSL=false&serverTimezone=UTC +spring.datasource.url=jdbc:mysql://localhost:3306/notes_app?serverTimezone=UTC&characterEncoding=UTF-8 spring.datasource.username = root spring.datasource.password = Come1999? +spring.datasource.drive-class-name = com.mysql.cj.jdbc.Driver ## Hibernate Properties From 980f9023d490015e50d736359ec7d6c747a143a3 Mon Sep 17 00:00:00 2001 From: Enoch Enagbem Date: Fri, 5 May 2023 12:19:23 +0000 Subject: [PATCH 20/20] make change to application file --- src/main/resources/application.properties | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fbcc976..cd02958 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ ## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) -spring.datasource.url=jdbc:mysql://localhost:3306/notes_app?serverTimezone=UTC&characterEncoding=UTF-8 +spring.datasource.url=jdbc:mysql://localhost:3306/notes_app?useSSL=false&allowPublicKeyRetrieval=true spring.datasource.username = root spring.datasource.password = Come1999? spring.datasource.drive-class-name = com.mysql.cj.jdbc.Driver @@ -8,7 +8,8 @@ spring.datasource.drive-class-name = com.mysql.cj.jdbc.Driver ## Hibernate Properties # The SQL dialect makes Hibernate generate better SQL for the chosen database -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect # Hibernate ddl auto (create, create-drop, validate, update) -spring.jpa.hibernate.ddl-auto = update \ No newline at end of file +spring.jpa.hibernate.ddl-auto = update +spring.jpa.generate-ddl=true \ No newline at end of file