Skip to content

Commit

Permalink
fix testCreateEndorsement test
Browse files Browse the repository at this point in the history
  • Loading branch information
bhtibrewal committed Dec 30, 2023
1 parent c5a09ca commit f4cbbbd
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,30 @@ void testCreateEndorsement() {
// Mock data
UUID userId = UUID.randomUUID();
UUID skillId = UUID.randomUUID();
UUID endorsementId = UUID.randomUUID();
EndorsementDRO endorsementDRO = new EndorsementDRO();
endorsementDRO.setUserId(userId);
endorsementDRO.setSkillId(skillId);

UserModel mockUser = UserModel.builder().id(userId).build();
SkillModel mockSkill = SkillModel.builder().id(skillId).build();

// Mock the repository behavior
EndorsementModel mockEndorsement = EndorsementModel.builder()
.id(endorsementId)
.user(mockUser)
.skill(mockSkill)
.build();
mockEndorsement.setCreatedAt(Instant.now());
mockEndorsement.setUpdatedAt(Instant.now());
mockEndorsement.setCreatedBy(mockUser);
mockEndorsement.setUpdatedBy(mockUser);

// Mock the repository behavior
when(userRepository.findById(userId)).thenReturn(Optional.of(mockUser));
when(skillRepository.findById(skillId)).thenReturn(Optional.of(mockSkill));
when(endorsementRepository.save(any(EndorsementModel.class))).thenReturn(mockEndorsement);


// Call the service method
// Call the service method
EndorsementModel result = endorsementService.createEndorsement(endorsementDRO);

// Verify the interactions
Expand Down

0 comments on commit f4cbbbd

Please sign in to comment.