use of com.nexblocks.authguard.dal.model.PermissionDO in project AuthGuard by AuthGuard.
the class PermissionsServiceImplTest method createDuplicate.
@Test
void createDuplicate() {
final PermissionDO permission = PermissionDO.builder().build();
final PermissionBO request = PermissionBO.builder().group("test").name("read").domain("main").build();
Mockito.when(permissionsRepository.search(request.getGroup(), request.getName(), "main")).thenReturn(CompletableFuture.completedFuture(Optional.of(permission)));
Mockito.when(permissionsRepository.save(Mockito.any())).thenAnswer(invocation -> CompletableFuture.completedFuture(invocation.getArgument(0, PermissionDO.class)));
assertThatThrownBy(() -> permissionsService.create(request)).isInstanceOf(ServiceConflictException.class);
}
use of com.nexblocks.authguard.dal.model.PermissionDO in project AuthGuard by AuthGuard.
the class PermissionsServiceImplTest method getById.
@Test
void getById() {
final PermissionDO permission = PermissionDO.builder().id("permission").group("test").name("read").build();
final PermissionBO expected = PermissionBO.builder().id("permission").group("test").name("read").build();
Mockito.when(permissionsRepository.getById(permission.getId())).thenReturn(CompletableFuture.completedFuture(Optional.of(permission)));
final Optional<PermissionBO> actual = permissionsService.getById(permission.getId());
assertThat(actual).contains(expected);
}
use of com.nexblocks.authguard.dal.model.PermissionDO in project AuthGuard by AuthGuard.
the class PermissionsServiceImplTest method delete.
@Test
void delete() {
final PermissionDO permission = PermissionDO.builder().id("permission").group("test").name("read").build();
final PermissionBO expected = PermissionBO.builder().id("permission").group("test").name("read").build();
Mockito.when(permissionsRepository.delete(permission.getId())).thenReturn(CompletableFuture.completedFuture(Optional.of(permission)));
final Optional<PermissionBO> actual = permissionsService.delete(permission.getId());
assertThat(actual).contains(expected);
}
Aggregations