Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
* extract the given object creation to smaller methods as commented on the PR.
  • Loading branch information
Leandro13Silva13 committed Apr 4, 2024
1 parent cf861b3 commit 98e9f58
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -805,19 +805,14 @@ void initializeSession_Should_initializePeerChat_When_consultingTypeSettingsHasP
void
getAllowedSessionsByConsultantAndGroupOrFeedbackGroupIds_should_only_return_the_sessions_the_consultant_can_see() {
//given
Session allowedSession =
createAnonymousNewEnquiryWithConsultingType(AGENCY_DTO_SUCHT.getConsultingType());
Session notAllowedSession =
createAnonymousNewEnquiryWithConsultingType(AGENCY_DTO_SUCHT.getConsultingType());
List<Session> sessions = new ArrayList<>();
sessions.add(notAllowedSession);
sessions.add(allowedSession);
ConsultantAgency agency = new ConsultantAgency();
agency.setAgencyId(4711L);
var consultant = createConsultantWithAgencies(agency);
allowedSession.setConsultant(consultant);
allowedSession.setId(1L);
notAllowedSession.setId(2L);
var allowedSession = giveAllowedSessionWithID(1L, consultant);
var unhallowedSession = giveUnhallowedSessionWithID(2L);
sessions.add(unhallowedSession);
sessions.add(allowedSession);
when(sessionRepository.findByGroupOrFeedbackGroupIds(singleton("rcGroupId")))
.thenReturn(sessions);
//when
Expand Down Expand Up @@ -911,6 +906,21 @@ private List<UserSessionResponseDTO> getSomeUserId(String someUserId, Session an
someUserId, singleton(anonymousEnquiry.getId()), singleton(UserRole.ANONYMOUS.getValue()));
}

private Session giveAllowedSessionWithID(Long id, Consultant consultant){
Session allowedSession =
createAnonymousNewEnquiryWithConsultingType(AGENCY_DTO_SUCHT.getConsultingType());
allowedSession.setId(id);
allowedSession.setConsultant(consultant);
return allowedSession;
}

private Session giveUnhallowedSessionWithID(Long id){
Session unhallowedSession =
createAnonymousNewEnquiryWithConsultingType(AGENCY_DTO_SUCHT.getConsultingType());
unhallowedSession.setId(id);
return unhallowedSession;
}

private Session createAnonymousNewEnquiryWithConsultingType(int consultingTypeId) {
var session = easyRandom.nextObject(Session.class);
session.setAgencyId(null);
Expand Down

0 comments on commit 98e9f58

Please sign in to comment.