Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
528cca6
Complete Task 5: Jenkins Pipeline with JUnit and JaCoCo
tienthanhnguyen331 Apr 7, 2026
5985526
Edit Jenkinsfile
tienthanhnguyen331 Apr 7, 2026
d08e46e
Edit pom.xml
tienthanhnguyen331 Apr 7, 2026
74e7d90
Edit version of java
tienthanhnguyen331 Apr 7, 2026
2c270ab
Edit Jenkinsfile
tienthanhnguyen331 Apr 7, 2026
c92432a
Change report search logic
tienthanhnguyen331 Apr 7, 2026
a235975
Adjust Jenkinsfile to test coverage in media
tienthanhnguyen331 Apr 10, 2026
3cccf9d
Fix 0% coverage%
tienthanhnguyen331 Apr 10, 2026
c2d4b04
Finish task 5
tienthanhnguyen331 Apr 12, 2026
15e34c7
Turned off integration test
tienthanhnguyen331 Apr 12, 2026
bcc477a
test: add unit test for UserAddressService to increase coverage
tienthanhnguyen331 Apr 25, 2026
0bcdc2d
test: add unit tests for rating module to improve coverage
tienthanhnguyen331 Apr 25, 2026
1f07004
fix: compilation error in CustomerServiceTest
tienthanhnguyen331 Apr 25, 2026
6ede375
fix: clear SecurityContext after each test to prevent test pollution
tienthanhnguyen331 Apr 25, 2026
ac24b16
Add unit tests for OrderService and ProductService in order module
tienthanhnguyen331 Apr 26, 2026
493d819
Fix compilation errors in OrderServiceTest
tienthanhnguyen331 Apr 26, 2026
f48adc6
Fix test failure in OrderServiceTest
tienthanhnguyen331 Apr 26, 2026
c2c51ed
Increase coverage and update Jenkinsfile coverage limits
tienthanhnguyen331 Apr 26, 2026
8c72992
Boost test coverage for Order module to > 70%
tienthanhnguyen331 Apr 26, 2026
94dda6c
Fix AuthenticationUtils import in OrderServiceTest
tienthanhnguyen331 Apr 26, 2026
bd7a59f
Fix compilation error in OrderServiceTest: replace isCompleted with i…
tienthanhnguyen331 Apr 26, 2026
937bd8e
Fix all failing tests in order module: mock mvc date mapping, csv exp…
tienthanhnguyen331 Apr 26, 2026
95fc3b7
Fix compile errors in order tests: verify correct Csv package and han…
tienthanhnguyen331 Apr 26, 2026
8aff2bc
Fix compile error: instantiate OrderItemCsv using Mockito instead of …
tienthanhnguyen331 Apr 26, 2026
2726f20
Fix NPE in OrderSpecificationTest by mocking subquery.select()
tienthanhnguyen331 Apr 26, 2026
eaf2189
Fix remaining NPEs in OrderSpecificationTest by mocking criteriaBuild…
tienthanhnguyen331 Apr 26, 2026
943c0b9
Add more unit test
tienthanhnguyen331 Apr 29, 2026
6f4df16
Fix assertion in SecurityConfigTest
tienthanhnguyen331 Apr 29, 2026
b172738
Fix jacoco check phase and excludes tag in order pom
tienthanhnguyen331 Apr 29, 2026
0777fb7
Add lombok.config to exclude generated code and boost coverage
tienthanhnguyen331 Apr 29, 2026
5538700
Add more unit tests
tienthanhnguyen331 Apr 29, 2026
4b538e2
Fix CheckoutStatusPutVm import, remove JaCoCo exclusions, add compreh…
tienthanhnguyen331 Apr 29, 2026
f47dbee
Add branch tests to OrderService and OrderSpecification to fix JaCoCo…
tienthanhnguyen331 Apr 29, 2026
adf10c8
Add more unit test
tienthanhnguyen331 Apr 29, 2026
b193525
Fix synstax error in OrdeMapperTest
tienthanhnguyen331 Apr 29, 2026
9ee5548
Fix syntax error in OrderMapperTest
tienthanhnguyen331 Apr 29, 2026
433c883
Refactor Order and Checkout unit tests with pure Mockito for 90% cove…
tienthanhnguyen331 Apr 29, 2026
ef16466
Fix syntax errors in OrderServiceTest and CheckoutServiceTest
tienthanhnguyen331 Apr 29, 2026
d7425fb
Fix PÔM
tienthanhnguyen331 Apr 29, 2026
d476411
Remove excludes tag
tienthanhnguyen331 Apr 29, 2026
a2ca5d6
Add more unit test
tienthanhnguyen331 Apr 29, 2026
b9d9d59
Fix compile errors in FarmingCoverageTest
tienthanhnguyen331 Apr 29, 2026
5514885
Fix parameter mismatches for OrderGetVm and OrderBriefVm
tienthanhnguyen331 Apr 29, 2026
fb32197
Fix NullPointerException for primitive mocking in FarmingCoverageTest
tienthanhnguyen331 Apr 29, 2026
20b80b9
Fix CheckoutStatusPutVm reference in CheckoutServiceTest
tienthanhnguyen331 Apr 29, 2026
117a0a1
Scope CI to order
tienthanhnguyen331 Apr 29, 2026
400a992
Fix: Only set line coverage
tienthanhnguyen331 Apr 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
pipeline {
agent any

tools {
maven 'Maven3'
jdk 'Java21'
}

// Ép Java21
environment {
PATH_TO_JAVA = tool name: 'Java21', type: 'jdk'
JAVA_HOME = "${PATH_TO_JAVA}"
PATH = "${PATH_TO_JAVA}/bin:${env.PATH}"
}

stages {
stage('Checkout') {
steps {
// Lấy code từ GitHub về
checkout scm
}
}

stage('Determine Changed Services') {
steps {
script {
// Lấy các thay đổi từ commit mới nhất
def changedFiles = sh(script: "git diff-tree --no-commit-id --name-only -r HEAD || true", returnStdout: true).trim()

def changedModules = []
def lines = changedFiles.split('\n')
for (line in lines) {
if (line.contains('/')) {
def module = line.substring(0, line.indexOf('/'))
// Chỉ lấy các thư mục có file pom.xml
if (fileExists("${module}/pom.xml") && !changedModules.contains(module)) {
changedModules.add(module)
}
}
}

if (changedModules.isEmpty()) {
env.MAVEN_PROJECT_LIST = ""
echo "Không phát hiện thay đổi trong các service cụ thể. Sẽ build toàn bộ hệ thống."
} else {
env.MAVEN_PROJECT_LIST = changedModules.join(',')
echo "Phát hiện thay đổi ở các service: ${env.MAVEN_PROJECT_LIST}. Chỉ build và test các service này."
}

if (env.BRANCH_NAME == 'feature/add-test-order') {
env.MAVEN_PROJECT_LIST = 'order'
echo "Branch feature/add-test-order: chỉ chạy service order."
}
}
}
}

stage('Test & Coverage') {
steps {
echo 'Đang kiểm tra phiên bản Java...'
sh 'java -version'

script {
def mavenArgs = ""
if (env.MAVEN_PROJECT_LIST != "") {
mavenArgs = "-pl ${env.MAVEN_PROJECT_LIST} -am"
echo "Đang chạy Unit Test và tạo report Coverage cho các service thay đổi: ${env.MAVEN_PROJECT_LIST}..."
} else {
echo 'Đang chạy Unit Test và tạo report Coverage cho toàn bộ dự án...'
}

sh "mvn clean verify ${mavenArgs} '-Dsurefire.excludes=**/*IT.java,**/*IT\$*.java,**/ProductCdcConsumerTest.java,**/ProductVectorRepositoryTest.java,**/VectorQueryTest.java' '-Dfailsafe.excludes=**/*IT.java,**/*IT\$*.java'"
}
}
}

stage('Build') {
steps {
script {
def mavenArgs = ""
if (env.MAVEN_PROJECT_LIST != "") {
mavenArgs = "-pl ${env.MAVEN_PROJECT_LIST} -am"
echo "Đang đóng gói các service thay đổi: ${env.MAVEN_PROJECT_LIST}..."
} else {
echo 'Đang đóng gói toàn bộ ứng dụng...'
}

sh "mvn package -DskipTests -DskipCompile=false ${mavenArgs}"
}
}
}
}

//Lấy báo cáo
post {
always {
echo 'Pipeline hoàn thành (Dù Pass hay Fail). Đang kéo báo cáo Test và Coverage...'


junit allowEmptyResults: true, testResults: '**/target/surefire-reports/*.xml'


script {
def classPatterns = '**/target/classes'
def sourcePatterns = '**/src/main/java'
def execPatterns = '**/target/jacoco.exec'

if (env.MAVEN_PROJECT_LIST?.trim()) {
classPatterns = env.MAVEN_PROJECT_LIST.split(',').collect { "${it}/target/classes" }.join(',')
sourcePatterns = env.MAVEN_PROJECT_LIST.split(',').collect { "${it}/src/main/java" }.join(',')
execPatterns = env.MAVEN_PROJECT_LIST.split(',').collect { "${it}/target/jacoco.exec" }.join(',')
}

jacoco execPattern: execPatterns,
classPattern: classPatterns,
sourcePattern: sourcePatterns,
changeBuildStatus: true,
minimumLineCoverage: '0.80'
}
}
}
}
39 changes: 39 additions & 0 deletions customer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,45 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.70</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.70</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Loading