@Test public void shouldGetRightsForUserAndWarehouse() { List<Right> expectedRights = new ArrayList<>(); Long userId = 1l; Long warehouseId = 2l; when(roleRightsRepository.getRightsForUserAndWarehouse(userId, warehouseId)).thenReturn(expectedRights); List<Right> rights = roleRightsService.getRightsForUserAndWarehouse(userId, warehouseId); assertThat(rights, is(expectedRights)); verify(roleRightsRepository).getRightsForUserAndWarehouse(userId, warehouseId); }
public List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId) { return roleRightsRepository.getRightsForUserAndWarehouse(userId, warehouseId); }
RoleRightsService { public List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId) { return roleRightsRepository.getRightsForUserAndWarehouse(userId, warehouseId); } }
RoleRightsService { public List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId) { return roleRightsRepository.getRightsForUserAndWarehouse(userId, warehouseId); } @Autowired  RoleRightsService(RoleRightsRepository roleRightsRepository,
                           SupervisoryNodeService supervisoryNodeService,
                           FacilityService facilityService,
                           ProgramService programService,
                           ProgramProductService programProductService); }
RoleRightsService { public List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId) { return roleRightsRepository.getRightsForUserAndWarehouse(userId, warehouseId); } @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 List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId) { return roleRightsRepository.getRightsForUserAndWarehouse(userId, warehouseId); } @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);  }