diff --git a/src/test/java/com/ays/assignment/service/impl/AssignmentSearchServiceImplTest.java b/src/test/java/com/ays/assignment/service/impl/AssignmentSearchServiceImplTest.java index fdf5c08f6..f4e3ef9be 100644 --- a/src/test/java/com/ays/assignment/service/impl/AssignmentSearchServiceImplTest.java +++ b/src/test/java/com/ays/assignment/service/impl/AssignmentSearchServiceImplTest.java @@ -99,6 +99,14 @@ void givenValidAssignmentSearchRequest_whenUserIsNotReady_thenThrowAysAssignment UserEntity mockUserEntity = new UserEntityBuilder() .withValidFields() .build(); + Point mockAssignmentPoint = AysLocationUtil.generatePoint( + mockAssignmentSearchRequest.getLongitude(), + mockAssignmentSearchRequest.getLatitude() + ); + AssignmentEntity mockAssignmentEntity = new AssignmentEntityBuilder() + .withValidFields() + .withPoint(mockAssignmentPoint) + .build(); // When Mockito.when(identity.getUserId()).thenReturn(mockUserEntity.getId()); @@ -120,6 +128,9 @@ void givenValidAssignmentSearchRequest_whenUserIsNotReady_thenThrowAysAssignment Mockito.verify(identity, Mockito.times(1)).getInstitutionId(); Mockito.verify(userRepository, Mockito.times(1)) .findByIdAndInstitutionId(mockUserEntity.getId(), mockUserEntity.getInstitutionId()); + Mockito.verify(assignmentRepository, Mockito.times(0)) + .findNearestAvailableAssignment(mockAssignmentPoint, mockUserEntity.getInstitutionId()); + Mockito.verify(assignmentRepository, Mockito.times(0)).save(mockAssignmentEntity); } @Test @@ -137,6 +148,10 @@ void givenInValidAssignmentSearchRequest_whenAssignmentNotExistForSearching_then mockAssignmentSearchRequest.getLongitude(), mockAssignmentSearchRequest.getLatitude() ); + AssignmentEntity mockAssignmentEntity = new AssignmentEntityBuilder() + .withValidFields() + .withPoint(mockAssignmentPoint) + .build(); // When Mockito.when(identity.getUserId()).thenReturn(mockUserEntity.getId()); @@ -166,6 +181,7 @@ void givenInValidAssignmentSearchRequest_whenAssignmentNotExistForSearching_then .findByIdAndInstitutionId(mockUserEntity.getId(), mockUserEntity.getInstitutionId()); Mockito.verify(assignmentRepository, Mockito.times(1)) .findNearestAvailableAssignment(mockAssignmentPoint, mockUserEntity.getInstitutionId()); + Mockito.verify(assignmentRepository, Mockito.times(0)).save(mockAssignmentEntity); } }