PersonnelServiceFacadeWebTier implements PersonnelServiceFacade { @Override public DefinePersonnelDto retrieveInfoForNewUserDefinition(Short officeId) { String officeName = ""; if (officeId != null) { OfficeBO office = officeDao.findOfficeById(officeId); officeName = office.getOfficeName(); } List<ValueListElement> titles = customerDao.retrieveTitles(); List<ListElement> titleList = new ArrayList<ListElement>(); for (ValueListElement element : titles) { ListElement listElement = new ListElement(element.getId(), element.getName()); titleList.add(listElement); } List<PersonnelLevelEntity> personnelLevels = customerDao.retrievePersonnelLevels(); List<ListElement> personnelLevelList = new ArrayList<ListElement>(); for (PersonnelLevelEntity level : personnelLevels) { String name = level.getLookUpValue().getLookUpName(); String localisedName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(name); ListElement listElement = new ListElement(new Integer(level.getId()), localisedName); personnelLevelList.add(listElement); } List<ValueListElement> genders = customerDao.retrieveGenders(); List<ListElement> genderList = new ArrayList<ListElement>(); for (ValueListElement element : genders) { ListElement listElement = new ListElement(element.getId(), element.getName()); genderList.add(listElement); } List<ValueListElement> maritalStatuses = customerDao.retrieveMaritalStatuses(); List<ListElement> maritalStatusList = new ArrayList<ListElement>(); for (ValueListElement element : maritalStatuses) { ListElement listElement = new ListElement(element.getId(), element.getName()); maritalStatusList.add(listElement); } List<RoleBO> roles = new ArrayList<RoleBO>(); try { roles = rolesPermissionsPersistence.getRoles(); } catch (PersistenceException e) { throw new MifosRuntimeException(e); } List<ListElement> roleList = new ArrayList<ListElement>(); for (RoleBO element : roles) { ListElement listElement = new ListElement(new Integer(element.getId()), element.getName()); roleList.add(listElement); } List<ListElement> languageList = Localization.getInstance().getLocaleList(); DefinePersonnelDto defineUserDto = new DefinePersonnelDto(officeName, titleList, personnelLevelList, genderList, maritalStatusList, languageList, roleList); return defineUserDto; } @Autowired  PersonnelServiceFacadeWebTier(OfficeDao officeDao, CustomerDao customerDao, PersonnelDao personnelDao, ApplicationConfigurationDao applicationConfigurationDao, LegacyRolesPermissionsDao rolesPermissionsPersistence); @Override SystemUserSearchResultsDto searchUser(UserSearchDto searchDto); @Override DefinePersonnelDto retrieveInfoForNewUserDefinition(Short officeId); @Override PersonnelInformationDto getPersonnelInformationDto(final Long userId, final String globalNumber); @Override UserDetailDto createPersonnelInformation(CreateOrUpdatePersonnelInformation personnel); @Override UserDetailDto updatePersonnel(CreateOrUpdatePersonnelInformation personnel); @Override UserSettingsDto retrieveUserSettings(); @Override UserSettingsDto retrieveUserSettings(Integer genderId, Integer maritalStatusId, Integer localeId, Short sitePreferenceId); @Override UserDetailDto retrieveUserInformation(Short personnelId); @Override void updateUserSettings(Short personnelId, String emailId, Name name, Integer maritalStatusValue, Integer genderValue,
            AddressDto address, Short preferredLocale, Short sitePreference); @Override void unLockUserAccount(String globalAccountNum); @Override Locale getUserPreferredLocale(); @Override Locale getUserPreferredLocale(@SuppressWarnings("unused") HttpServletRequest request); @Override Short changeUserLocale(Short id, HttpServletRequest request); @Override List<ValueListElement> getDisplayLocaleList(); @Override CustomerHierarchyDto getLoanOfficerCustomersHierarchyForDay(Short loanOfficerId, DateTime day); @Override List<PersonnelDto> retrieveActiveLoanOfficersUnderOffice(Short officeId); @Override SitePreferenceType retrieveSitePreference(Integer userId);  }
@Test public void shouldRetrieveOfficeName() { Short officeId = Short.valueOf("3"); OfficeBO office = new OfficeBuilder().withName("officeTestName").build(); when(officeDao.findOfficeById(officeId)).thenReturn(office); DefinePersonnelDto personnelDto = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId); assertThat(personnelDto.getOfficeName(), is("officeTestName")); }