Skip to content

Commit

Permalink
Merge pull request #6 from nowgnas/LF1-367--jacoco-
Browse files Browse the repository at this point in the history
add jacoco, amend entity
  • Loading branch information
nowgnas authored Nov 21, 2023
2 parents 4ec527b + 002ce1e commit 5c8254f
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 64 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy development profile about lotdiz
on:
workflow_dispatch:
push:
branches:
- 'develop'
env:
DOCKERHUB_USERNAME: ${{ secrets.DEV_DOCKER_ID }}
DOCKERHUB_PASSWORD: ${{ secrets.DEV_DOCKER_PW }}
DOCKERHUB_REPOSITORY: ${{ secrets.DOCKERHUB_REPOSITORY }}
jobs:
deploy:
needs: test
environment: develop
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPOSITORY }}:product
59 changes: 58 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '2.7.17'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'jacoco'
}

group = 'kr.bb'
Expand Down Expand Up @@ -36,9 +37,12 @@ dependencies {
implementation "org.springframework.cloud:spring-cloud-starter-bus-kafka"
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'mysql:mysql-connector-java:8.0.33'
implementation group: 'io.github.lotteon-maven', name: 'blooming-blooms-utils', version: '0.1.0-alpha1'
implementation group: 'io.github.lotteon-maven', name: 'blooming-blooms-utils', version: '0.1.0-alpha2'
// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-dynamodb
implementation group: 'com.amazonaws', name: 'aws-java-sdk-dynamodb', version: '1.12.592'
runtimeOnly 'com.h2database:h2'
implementation 'org.mapstruct:mapstruct:1.5.3.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'
}

dependencyManagement {
Expand All @@ -54,3 +58,56 @@ tasks.named('bootBuildImage') {
tasks.named('test') {
useJUnitPlatform()
}

// jacoco
jacoco {
toolVersion = '0.8.5'
}

jacocoTestCoverageVerification {
violationRules {
rule {
enabled = true
element = 'CLASS'

limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.80
}
excludes = ["*.mapper*"]
}
}
}

test {
jacoco {
destinationFile = file("$buildDir/jacoco/jacoco.exec")
}
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}

jacocoTestReport {
reports {
html.required = true
}
def Qdomains = []
for (qPattern in '**/QA'..'**/QZ') {
Qdomains.add(qPattern + '*')
}
afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, excludes: [
"**/*Application*",
"**/*generated*",
"**/*mapper*",
"**/*Config*",
"**/*Dto*",
] + Qdomains)
})
)
}
finalizedBy 'jacocoTestCoverageVerification'
}
1 change: 1 addition & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.addLombokGeneratedAnnotation = true
17 changes: 17 additions & 0 deletions src/main/java/kr/bb/product/dto/category/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package kr.bb.product.dto.category;

import kr.bb.product.entity.BaseEntity;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Category extends BaseEntity {
private Long id;
private String categoryName;
}
17 changes: 17 additions & 0 deletions src/main/java/kr/bb/product/dto/tag/Tag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package kr.bb.product.dto.tag;

import kr.bb.product.entity.BaseEntity;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Tag extends BaseEntity {
private Long id;
private String categoryName;
}
29 changes: 0 additions & 29 deletions src/main/java/kr/bb/product/entity/Category.java

This file was deleted.

4 changes: 3 additions & 1 deletion src/main/java/kr/bb/product/entity/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import kr.bb.product.dto.category.Category;
import kr.bb.product.dto.tag.Tag;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -31,7 +33,7 @@ public class Product {
private Long productPrice;

@DynamoDBAttribute(attributeName = "product_sale_status")
private String productSaleStatus;
private ProductSaleStatus productSaleStatus;

@DynamoDBAttribute(attributeName = "tag")
private Tag tag;
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/kr/bb/product/entity/ProductSaleStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package kr.bb.product.entity;

import lombok.Getter;

@Getter
public enum ProductSaleStatus {
SALE("판매 중"),
DISCONTINUED("판매 중지");
private final String message;

ProductSaleStatus(String message) {
this.message = message;
}
}
4 changes: 0 additions & 4 deletions src/main/java/kr/bb/product/entity/Review.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package kr.bb.product.entity;

import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand Down
29 changes: 0 additions & 29 deletions src/main/java/kr/bb/product/entity/Tag.java

This file was deleted.

18 changes: 18 additions & 0 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
spring:
cloud:
config:
enabled: false
datasource:
username: sa
password:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
h2:
console:
enabled: true
aws:
dynamodb:
endpoint: http://localhost:9000
region: ap-northease-2
accessKey: accessKey
secretKey: secretKey

0 comments on commit 5c8254f

Please sign in to comment.