Skip to content

Commit

Permalink
Add control for methods should not work in AssignmentSearchService.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimdenizz committed Sep 3, 2023
1 parent 48f068a commit cc00bd2
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand All @@ -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());
Expand Down Expand Up @@ -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);
}

}

0 comments on commit cc00bd2

Please sign in to comment.