Search in sources :

Example 11 with RoleEntity

use of org.codenergic.theskeleton.role.RoleEntity in project theskeleton by codenergic.

the class PrivilegeServiceTest method testFindPrivilegesByRoleCode.

@Test
public void testFindPrivilegesByRoleCode() {
    Set<RolePrivilegeEntity> dbResult = new HashSet<>(Arrays.asList(new RolePrivilegeEntity().setPrivilege(new PrivilegeEntity().setName("privilege")).setRole(new RoleEntity())));
    when(rolePrivilegeRepository.findByRoleCode("role")).thenReturn(dbResult);
    Set<PrivilegeEntity> result = privilegeService.findPrivilegesByRoleCode("role");
    assertThat(result.size()).isEqualTo(1);
    assertThat(result.iterator().next()).isEqualTo(dbResult.iterator().next().getPrivilege());
    verify(rolePrivilegeRepository).findByRoleCode("role");
}
Also used : RoleEntity(org.codenergic.theskeleton.role.RoleEntity) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

RoleEntity (org.codenergic.theskeleton.role.RoleEntity)11 Test (org.junit.Test)6 Transactional (org.springframework.transaction.annotation.Transactional)5 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)3 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)3 ResultActions (org.springframework.test.web.servlet.ResultActions)3 HashSet (java.util.HashSet)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 EnableRestDocs (org.codenergic.theskeleton.core.test.EnableRestDocs)1 PrivilegeEntity (org.codenergic.theskeleton.privilege.PrivilegeEntity)1 RoleNotFoundException (org.codenergic.theskeleton.role.RoleNotFoundException)1 RolePrivilegeEntity (org.codenergic.theskeleton.role.RolePrivilegeEntity)1 RoleRestData (org.codenergic.theskeleton.role.RoleRestData)1 UserRoleEntity (org.codenergic.theskeleton.role.UserRoleEntity)1