@Test public void shouldGetRoleById() { Role role = new Role(); Long roleId = 1L; when(roleRightsRepository.getRole(roleId)).thenReturn(role); assertThat(roleRightsService.getRole(roleId), is(role)); verify(roleRightsRepository).getRole(roleId); }
public Role getRole(Long id) { return roleRightsRepository.getRole(id); }
RoleRightsService { public Role getRole(Long id) { return roleRightsRepository.getRole(id); } }
RoleRightsService { public Role getRole(Long id) { return roleRightsRepository.getRole(id); } @Autowired  RoleRightsService(RoleRightsRepository roleRightsRepository,
                           SupervisoryNodeService supervisoryNodeService,
                           FacilityService facilityService,
                           ProgramService programService,
                           ProgramProductService programProductService); }
RoleRightsService { public Role getRole(Long id) { return roleRightsRepository.getRole(id); } @Autowired  RoleRightsService(RoleRightsRepository roleRightsRepository,
                           SupervisoryNodeService supervisoryNodeService,
                           FacilityService facilityService,
                           ProgramService programService,
                           ProgramProductService programProductService); @Transactional void saveRole(Role role); Map<String, List<Role>> getAllRolesMap(); Role getRole(Long id); List<Role> getAllRoles(); void updateRole(Role role); List<Right> getRights(Long userId); List<Right> getRightsForUserAndFacilityProgram(Long userId, Facility facility, Program program); List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId); List<Right> getRightsForUserFacilityAndProductCode(Long userId, Long facilityId, String productCode); RightType getRightTypeForRoleId(Long roleId); }
RoleRightsService { public Role getRole(Long id) { return roleRightsRepository.getRole(id); } @Autowired  RoleRightsService(RoleRightsRepository roleRightsRepository,
                           SupervisoryNodeService supervisoryNodeService,
                           FacilityService facilityService,
                           ProgramService programService,
                           ProgramProductService programProductService); @Transactional void saveRole(Role role); Map<String, List<Role>> getAllRolesMap(); Role getRole(Long id); List<Role> getAllRoles(); void updateRole(Role role); List<Right> getRights(Long userId); List<Right> getRightsForUserAndFacilityProgram(Long userId, Facility facility, Program program); List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId); List<Right> getRightsForUserFacilityAndProductCode(Long userId, Long facilityId, String productCode); RightType getRightTypeForRoleId(Long roleId);  }