Search in sources :

Example 1 with PermissionDO

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);
}
Also used : PermissionBO(com.nexblocks.authguard.service.model.PermissionBO) PermissionDO(com.nexblocks.authguard.dal.model.PermissionDO) Test(org.junit.jupiter.api.Test)

Example 2 with PermissionDO

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);
}
Also used : PermissionBO(com.nexblocks.authguard.service.model.PermissionBO) PermissionDO(com.nexblocks.authguard.dal.model.PermissionDO) Test(org.junit.jupiter.api.Test)

Example 3 with PermissionDO

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);
}
Also used : PermissionBO(com.nexblocks.authguard.service.model.PermissionBO) PermissionDO(com.nexblocks.authguard.dal.model.PermissionDO) Test(org.junit.jupiter.api.Test)

Aggregations

PermissionDO (com.nexblocks.authguard.dal.model.PermissionDO)3 PermissionBO (com.nexblocks.authguard.service.model.PermissionBO)3 Test (org.junit.jupiter.api.Test)3