### Question:
UserRoleFromContextService { public UserContextRole getUserRoleInUnitId(Long unitId) { OkrChildUnit contextDepartment = getUnitOfId(unitId); return getUserRoleInUnit(contextDepartment); } @Autowired  UserRoleFromContextService(
      UnitRepository<OkrChildUnit> unitRepository,
      ObjectiveRepository objectiveRepository,
      KeyResultRepository keyResultRepository,
      NoteRepository noteRepository,
      AdminUserRepository adminUserRepository,
      UserService userService); UserContextRole getUserRoleWithoutContext(); UserContextRole getUserRoleInUnitId(Long unitId); UserContextRole getUserRoleInObjectiveId(Long objectiveId); UserContextRole getUserRoleInKeyResultId(Long keyResultId); UserContextRole getUserRoleInNoteId(Long noteId); UserContextRole getUserRoleInUnit(OkrUnit okrUnit);  }### Answer:
@Test public void getRoleFromDepartment_OkrMaster_expectedManagerRole() { when(currentUser.getId()).thenReturn(okrMasterId); UserContextRole actualRole = userRoleFromContextService.getUserRoleInUnitId(departmentId); Assert.assertEquals(UserContextRole.OKRMANAGER, actualRole); }
@Test public void getRoleFromDepartment_OkrTopicSponsor_expectedManagerRole() { when(currentUser.getId()).thenReturn(okrThemenpateId); UserContextRole actualRole = userRoleFromContextService.getUserRoleInUnitId(departmentId); Assert.assertEquals(UserContextRole.OKRMANAGER, actualRole); }
@Test public void getRoleFromDepartment_OkrMember_expectedMemberRole() { when(currentUser.getId()).thenReturn(okrMemberId); UserContextRole actualRole = userRoleFromContextService.getUserRoleInUnitId(departmentId); Assert.assertEquals(UserContextRole.OKRMEMBER, actualRole); }
@Test public void getRoleFromDepartment_User_expectedUserRole() { when(currentUser.getId()).thenReturn(unrelatedUserId); UserContextRole actualRole = userRoleFromContextService.getUserRoleInUnitId(departmentId); Assert.assertEquals(UserContextRole.USER, actualRole); }