Skip to content

Commit

Permalink
rename method and write tests to see if it works
Browse files Browse the repository at this point in the history
  • Loading branch information
Vakmeth committed Nov 17, 2023
1 parent 4d80d2e commit 64d8262
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private OverviewDto createOverviewDto(Overview overview) {
return new OverviewDto(
new OverviewTeamDto(overview.getOverviewId().getTeamId(), overview.getTeamName(),
overview.isWriteable(),
organisationBusinessService.teamHasInactiveOrganisations(overview.getOverviewId().getTeamId())),
organisationBusinessService.teamHasInActiveOrganisations(overview.getOverviewId().getTeamId())),
objectives);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<Organisation> getActiveOrganisations() {
return persistenceService.getActiveOrganisations();
}

public boolean teamHasInactiveOrganisations(Long teamId) {
public boolean teamHasInActiveOrganisations(Long teamId) {
return !getOrganisationsByTeam(teamId).stream()
.filter(organisation -> organisation.getState() == OrganisationState.INACTIVE).toList().isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

Expand All @@ -34,6 +36,9 @@ class OrganisationBusinessServiceTest {
private static final Organisation organisationThree = Organisation.Builder.builder().withId(2L)
.withOrgName("org_three").withState(OrganisationState.ACTIVE).build();

private static final Organisation organisationInActive = Organisation.Builder.builder().withId(2L)
.withOrgName("org_in_active").withState(OrganisationState.INACTIVE).build();

@Mock
LdapTemplate ldapTemplate;

Expand Down Expand Up @@ -78,4 +83,18 @@ void getOrganisationsByTeamId() {
organisationBusinessService.getOrganisationsByTeam(1L);
verify(organisationPersistenceService, times(1)).getOrganisationsByTeamId(1L);
}

@Test
void teamHasInActiveOrganisations() {
when(organisationPersistenceService.getOrganisationsByTeamId(anyLong()))
.thenReturn(List.of(organisationInActive, organisationOne, organisationTwo));
assertTrue(organisationBusinessService.teamHasInActiveOrganisations(1L));
}

@Test
void teamHasNoInActiveOrganisations() {
when(organisationPersistenceService.getOrganisationsByTeamId(anyLong()))
.thenReturn(List.of(organisationOne, organisationTwo, organisationThree));
assertFalse(organisationBusinessService.teamHasInActiveOrganisations(1L));
}
}

0 comments on commit 64d8262

Please sign in to comment.