-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/ADPRO-C11/review into sonar
- Loading branch information
Showing
13 changed files
with
628 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Java CI Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: "temurin" | ||
java-version: "21" | ||
cache: "gradle" | ||
|
||
- name: Cache Gradle dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Make gradlew executable | ||
run: chmod +x ./gradlew | ||
- name: Build with Gradle | ||
run: | | ||
./gradlew assemble | ||
# (Optional) Add steps for running tests and generating reports | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: java-app | ||
path: build/libs/*.jar | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
needs: build | ||
services: | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: snackscription_review | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: "temurin" | ||
java-version: "21" | ||
cache: "gradle" | ||
|
||
|
||
- name: Make gradlew executable | ||
run: chmod +x ./gradlew | ||
|
||
|
||
- name: Cache Gradle dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Test with Gradle | ||
run: | | ||
./gradlew check --info --stacktrace | ||
./gradlew test | ||
./gradlew jacocoTestReport | ||
env: | ||
PRODUCTION: test | ||
# (Optional) Add steps for generating coverage report and other post-test tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
scrape_configs: | ||
- job_name: 'MyAppMetrics' | ||
- job_name: 'Snackscription Metrics' | ||
metrics_path: '/actuator/prometheus' | ||
scrape_interval: 3s | ||
static_configs: | ||
- targets: ['host.docker.internal:8080'] | ||
labels: | ||
application: 'Snackscription Review' | ||
application: 'Snackscription Review' | ||
- targets: ['34.124.152.90'] | ||
labels: | ||
application: 'Snackscription Review (deployed)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/snackscription/review/controller/ReviewAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package snackscription.review.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import snackscription.review.model.Review; | ||
import snackscription.review.service.ReviewServiceImpl; | ||
|
||
import java.util.List; | ||
|
||
@CrossOrigin | ||
@RestController | ||
@RequestMapping("/admin") | ||
public class ReviewAdminController { | ||
private ReviewServiceImpl reviewService; | ||
|
||
public ReviewAdminController(ReviewServiceImpl reviewService) { | ||
this.reviewService = reviewService; | ||
} | ||
|
||
@PutMapping("/subscription-boxes/{subsbox}/users/{user}/approve") | ||
public ResponseEntity<Review> approveReview(@PathVariable String subsbox, @PathVariable String user) { | ||
try { | ||
Review review = reviewService.approveReview(subsbox, user); | ||
return new ResponseEntity<>(review, HttpStatus.OK); | ||
} catch (Exception e) { | ||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||
} | ||
} | ||
|
||
@PutMapping("/subscription-boxes/{subsbox}/users/{user}/reject") | ||
public ResponseEntity<Review> rejectReview(@PathVariable String subsbox, @PathVariable String user) { | ||
try { | ||
Review review = reviewService.rejectReview(subsbox, user); | ||
return new ResponseEntity<>(review, HttpStatus.OK); | ||
} catch (Exception e) { | ||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||
} | ||
} | ||
|
||
@GetMapping("/subscription-boxes/{subsbox}/reviews") | ||
public ResponseEntity<List<Review>> getSubsboxReviews( | ||
@PathVariable String subsbox, | ||
@RequestParam(required = false) String state) throws Exception { | ||
List<Review> reviews = reviewService.getSubsboxReview(subsbox, state); | ||
return ResponseEntity.ok().body(reviews); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.