Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage unit test #42

Merged
merged 32 commits into from
Nov 19, 2023
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9d50750
implement authentication and fix error security
Nov 2, 2023
b9249d9
refactor name version of dependencies
Nov 2, 2023
ab1a5e1
active prod environment
Nov 2, 2023
075bc75
modify relationship entities to get data
Nov 2, 2023
a920b62
add message status to response
Nov 2, 2023
32a48f7
turn on jpa auditing
Nov 2, 2023
7be8a5b
add correlationId
Nov 2, 2023
7c3f3ff
handle verify email
Nov 4, 2023
3e2b2c6
override MethodArgumentNotValidException and handle exception
Nov 6, 2023
8d60e66
create role api
Nov 6, 2023
360a06b
fix error verify email
Nov 6, 2023
8db5742
Merge branch 'master' into dev
letung999 Nov 6, 2023
9edea17
remove redudant class
Nov 6, 2023
efaee96
create a general for response api and modify response at controller
Nov 6, 2023
d45e87d
handle upload file amazon s3
Nov 7, 2023
8cc3154
dÆhandle dÆÆownload file from s3
Nov 8, 2023
4b17d5f
implement redis server
Nov 9, 2023
2229867
implement search and advance search api
Nov 9, 2023
1e01d3a
handle get ÃÃinformation company api
Nov 10, 2023
a694744
handle cache data for get all users
Nov 12, 2023
63f9575
handle cache data search users api
Nov 12, 2023
d3e5f31
add a field response data of CompanyProfile
Nov 13, 2023
741861b
add READ.ME for config send log from application to cloudWatch
Nov 14, 2023
2ccee0f
set up monitoring log by CloudWatch
Nov 14, 2023
c8d026d
add document to set up cloudWatch
Nov 14, 2023
2627fb1
Merge branch 'master' into dev
letung999 Nov 14, 2023
79773d5
create update users api and invalidate cache
Nov 17, 2023
65ba6ca
Merge branch 'master' into dev
letung999 Nov 17, 2023
223f42d
add payment class
Nov 18, 2023
cc02263
modify relationship between CompanyProfile and CompanyProfileMapping
Nov 19, 2023
4b1cba5
coverage unit tÃest for repository layer
Nov 19, 2023
20fc0c1
Merge branch 'master' into dev
letung999 Nov 19, 2023
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
88 changes: 16 additions & 72 deletions src/test/java/com/ppn/ppn/repository/CompanyRepositoryTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.ppn.ppn.entities.CompanyProfile;
import com.ppn.ppn.entities.CompanyProfileMapping;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
Expand All @@ -26,12 +27,15 @@ public class CompanyRepositoryTests {
@Autowired
private CompanyProfileMappingRepository companyProfileMappingRepository;

@Test
public void givenListCompanyProfile_whenGetListCompanyProfileByDate_thenListCompanyProfile() throws ParseException {
//setup
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date inputDate = simpleDateFormat.parse("2009-10-01");
Date inputDate1 = simpleDateFormat.parse("2004-10-01");
private SimpleDateFormat simpleDateFormat;
private Date inputDate;
private Date inputDate1;

@BeforeEach
public void setup() throws ParseException {
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
inputDate = simpleDateFormat.parse("2009-10-01");
inputDate1 = simpleDateFormat.parse("2004-10-01");

CompanyProfile companyProfile = CompanyProfile.builder()
.companyIdName("001_shopBack")
Expand All @@ -46,7 +50,6 @@ public void givenListCompanyProfile_whenGetListCompanyProfileByDate_thenListComp
CompanyProfile companyProfileSaved = companyRepository.save(companyProfile);
CompanyProfile companyProfileSaved1 = companyRepository.save(companyProfile1);


CompanyProfileMapping companyProfileMapping = CompanyProfileMapping.builder()
.companyId(companyProfileSaved.getCompanyId())
.parentCompanyId("001_shopBack")
Expand All @@ -60,6 +63,10 @@ public void givenListCompanyProfile_whenGetListCompanyProfileByDate_thenListComp

companyProfileMappingRepository.save(companyProfileMapping);
companyProfileMappingRepository.save(companyProfileMapping1);
}

@Test
public void givenListCompanyProfile_whenGetListCompanyProfileByDate_thenListCompanyProfile() throws ParseException {

//action
List<CompanyProfile> resultData = companyRepository.getListCompanyProfile(inputDate1);
Expand All @@ -71,38 +78,7 @@ public void givenListCompanyProfile_whenGetListCompanyProfileByDate_thenListComp

@Test
public void givenListCompanyProfileId_whenGetListCompanyProfileId_thenListCompanyProfileId() throws ParseException {
//setup
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date inputDate = simpleDateFormat.parse("2009-10-01");
Date inputDate1 = simpleDateFormat.parse("2004-10-01");

CompanyProfile companyProfile = CompanyProfile.builder()
.companyIdName("001_shopBack")
.dateOfEstablishment(inputDate)
.build();

CompanyProfile companyProfile1 = CompanyProfile.builder()
.companyIdName("002_ManHeim")
.dateOfEstablishment(inputDate1)
.build();

CompanyProfile companyProfileSaved = companyRepository.save(companyProfile);
CompanyProfile companyProfileSaved1 = companyRepository.save(companyProfile1);

CompanyProfileMapping companyProfileMapping = CompanyProfileMapping.builder()
.companyId(companyProfileSaved.getCompanyId())
.parentCompanyId("001_shopBack")
.companyProfile(companyProfileSaved)
.build();
CompanyProfileMapping companyProfileMapping1 = CompanyProfileMapping.builder()
.companyId(companyProfileSaved1.getCompanyId())
.parentCompanyId("002_ManHeim")
.companyProfile(companyProfileSaved1)
.build();

companyProfileMappingRepository.save(companyProfileMapping);
companyProfileMappingRepository.save(companyProfileMapping1);


PageRequest pageRequest = PageRequest.of(0, 2);

//action
Expand All @@ -116,39 +92,7 @@ public void givenListCompanyProfileId_whenGetListCompanyProfileId_thenListCompan

@Test
public void givenListCompanyProfileIdIsEmpty_whenGetListCompanyProfileId_givenListCompanyProfileIdIsEmpty() throws ParseException {
//setup
//setup
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date inputDate = simpleDateFormat.parse("2009-10-01");
Date inputDate1 = simpleDateFormat.parse("2004-10-01");

CompanyProfile companyProfile = CompanyProfile.builder()
.companyIdName("001_shopBack")
.dateOfEstablishment(inputDate)
.build();

CompanyProfile companyProfile1 = CompanyProfile.builder()
.companyIdName("002_ManHeim")
.dateOfEstablishment(inputDate1)
.build();

CompanyProfile companyProfileSaved = companyRepository.save(companyProfile);
CompanyProfile companyProfileSaved1 = companyRepository.save(companyProfile1);

CompanyProfileMapping companyProfileMapping = CompanyProfileMapping.builder()
.companyId(companyProfileSaved.getCompanyId())
.parentCompanyId("001_shopBack")
.companyProfile(companyProfileSaved)
.build();
CompanyProfileMapping companyProfileMapping1 = CompanyProfileMapping.builder()
.companyId(companyProfileSaved1.getCompanyId())
.parentCompanyId("002_ManHeim")
.companyProfile(companyProfileSaved1)
.build();

companyProfileMappingRepository.save(companyProfileMapping);
companyProfileMappingRepository.save(companyProfileMapping1);


PageRequest pageRequest = PageRequest.of(1, 2);

//action
Expand Down
Loading