diff --git a/skill-tree/src/main/java/com/RDS/skilltree/Endorsement/EndorsementServiceImpl.java b/skill-tree/src/main/java/com/RDS/skilltree/Endorsement/EndorsementServiceImpl.java index 357a3339..fce1ed63 100644 --- a/skill-tree/src/main/java/com/RDS/skilltree/Endorsement/EndorsementServiceImpl.java +++ b/skill-tree/src/main/java/com/RDS/skilltree/Endorsement/EndorsementServiceImpl.java @@ -1,4 +1,5 @@ package com.RDS.skilltree.Endorsement; + import com.RDS.skilltree.Common.Response.GenericResponse; import com.RDS.skilltree.Exceptions.EntityAlreadyExistsException; import com.RDS.skilltree.Exceptions.InvalidParameterException; diff --git a/skill-tree/src/test/java/com/RDS/skilltree/unit/EndorsementServiceTest.java b/skill-tree/src/test/java/com/RDS/skilltree/unit/EndorsementServiceTest.java index c4f43cf3..2ee4dcef 100644 --- a/skill-tree/src/test/java/com/RDS/skilltree/unit/EndorsementServiceTest.java +++ b/skill-tree/src/test/java/com/RDS/skilltree/unit/EndorsementServiceTest.java @@ -10,6 +10,7 @@ import com.RDS.skilltree.Exceptions.NoEntityException; import com.RDS.skilltree.Skill.SkillModel; import com.RDS.skilltree.Skill.SkillRepository; +import com.RDS.skilltree.User.UserModel; import com.RDS.skilltree.User.UserRepository; import com.RDS.skilltree.User.UserRole; import com.fasterxml.jackson.core.type.TypeReference; @@ -643,23 +644,22 @@ public void itShouldReturnInvalidStatusGivenInvalidEndorsementStatus() { public void itShouldThrowEntityAlreadyExistsExceptionGivenEndorsementIsUpdated() { setupUpdateEndorsementTests(true); - UUID userId = UUID.randomUUID(); + UUID endorseeId = UUID.randomUUID(); UUID skillId = UUID.randomUUID(); UUID endorsementId = UUID.randomUUID(); - UserModel mockUser = UserModel.builder().id(userId).build(); SkillModel mockSkill = SkillModel.builder().id(skillId).build(); EndorsementModel mockEndorsement = EndorsementModel.builder() .id(endorsementId) .status(EndorsementStatus.APPROVED) - .user(mockUser) + .endorseeId(endorseeId) .skill(mockSkill) .build(); mockEndorsement.setCreatedAt(Instant.now()); mockEndorsement.setUpdatedAt(Instant.now()); - mockEndorsement.setCreatedBy(mockUser); - mockEndorsement.setUpdatedBy(mockUser); + mockEndorsement.setCreatedBy(endorseeId); + mockEndorsement.setUpdatedBy(endorseeId); when(endorsementRepository.findById(endorsementId)).thenReturn(Optional.of(mockEndorsement)); @@ -699,24 +699,23 @@ public void itShouldReturnEndorsementNotFoundGivenUnknownEndorsementId() { public void itShouldUpdateEndorsementStatusGivenEndorsementIdAndStatusApprovedOrRejected() { setupUpdateEndorsementTests(true); - UUID userId = UUID.randomUUID(); + UUID endorseeId = UUID.randomUUID(); UUID skillId = UUID.randomUUID(); UUID endorsementId = UUID.randomUUID(); EndorsementStatus status = EndorsementStatus.APPROVED; - UserModel mockUser = UserModel.builder().id(userId).build(); SkillModel mockSkill = SkillModel.builder().id(skillId).build(); EndorsementModel mockEndorsement = EndorsementModel.builder() .id(endorsementId) .status(EndorsementStatus.PENDING) - .user(mockUser) + .endorseeId(endorseeId) .skill(mockSkill) .build(); mockEndorsement.setCreatedAt(Instant.now()); mockEndorsement.setUpdatedAt(Instant.now()); - mockEndorsement.setCreatedBy(mockUser); - mockEndorsement.setUpdatedBy(mockUser); + mockEndorsement.setCreatedBy(endorseeId); + mockEndorsement.setUpdatedBy(endorseeId); when(endorsementRepository.findById(endorsementId)).thenReturn(Optional.of(mockEndorsement)); @@ -729,14 +728,14 @@ public void itShouldUpdateEndorsementStatusGivenEndorsementIdAndStatusApprovedOr EndorsementModel updatedMockEndorsement = EndorsementModel.builder() .id(endorsementId) - .user(mockUser) + .endorseeId(endorseeId) .skill(mockSkill) .status(EndorsementStatus.APPROVED) .build(); mockEndorsement.setCreatedAt(Instant.now()); mockEndorsement.setUpdatedAt(Instant.now()); - mockEndorsement.setCreatedBy(mockUser); - mockEndorsement.setUpdatedBy(mockUser); + mockEndorsement.setCreatedBy(endorseeId); + mockEndorsement.setUpdatedBy(endorseeId); when(endorsementRepository.findById(endorsementId)) .thenReturn(Optional.of(updatedMockEndorsement));