mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
Adapt unit test
This commit is contained in:
@@ -89,8 +89,7 @@ class DefaultRepositoryRoleManagerTest {
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void authorizeUser() {
|
void authorizeUser() {
|
||||||
when(subject.isPermitted("repositoryRole:read")).thenReturn(true);
|
when(subject.isPermitted("repositoryRole:write")).thenReturn(true);
|
||||||
when(subject.isPermitted("repositoryRole:modify")).thenReturn(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -184,8 +183,15 @@ class DefaultRepositoryRoleManagerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldThrowException_forGet() {
|
void shouldReturnNull_forNotExistingRole() {
|
||||||
assertThrows(UnauthorizedException.class, () -> manager.get("any"));
|
RepositoryRole role = manager.get("noSuchRole");
|
||||||
|
assertThat(role).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldReturnRole_forExistingRole() {
|
||||||
|
RepositoryRole role = manager.get(CUSTOM_ROLE_NAME);
|
||||||
|
assertThat(role).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -201,18 +207,25 @@ class DefaultRepositoryRoleManagerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnEmptyList() {
|
void shouldReturnAllRoles() {
|
||||||
assertThat(manager.getAll()).isEmpty();
|
List<RepositoryRole> allRoles = manager.getAll();
|
||||||
|
assertThat(allRoles).containsExactly(CUSTOM_ROLE, SYSTEM_ROLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnEmptyFilteredList() {
|
void shouldReturnFilteredList() {
|
||||||
assertThat(manager.getAll(x -> true, null)).isEmpty();
|
Collection<RepositoryRole> allRoles = manager.getAll(role -> CUSTOM_ROLE_NAME.equals(role.getName()), null);
|
||||||
|
assertThat(allRoles).containsExactly(CUSTOM_ROLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnEmptyPaginatedList() {
|
void shouldReturnPaginatedRoles() {
|
||||||
assertThat(manager.getAll(1, 1)).isEmpty();
|
Collection<RepositoryRole> allRoles =
|
||||||
|
manager.getAll(
|
||||||
|
Comparator.comparing(RepositoryRole::getType),
|
||||||
|
1, 1
|
||||||
|
);
|
||||||
|
assertThat(allRoles).containsExactly(CUSTOM_ROLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user