use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithActiveBranches.
@Test
public void shouldPopulateDtoWithActiveBranches() throws Exception {
// setup
final Short branchId = userContext.getBranchId();
final Short branchId2 = Short.valueOf("2");
final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
// we typcially don't try to mock/stub value objects (DTO) as they have
// no behaviour so just use as you would in production code.
OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, 1);
OfficeDetailsDto officeStub2 = new OfficeDetailsDto(branchId2, "branchName2", levelId, 1);
List<OfficeDetailsDto> activeOffices = Arrays.asList(officeStub1, officeStub2);
// stub interaction with DAO/Persistence layer.
when(officePersistence.getActiveOffices(branchId)).thenReturn(activeOffices);
// exercise test
CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
// verification
assertThat(formDto.getActiveBranchesList(), is(activeOffices));
}
use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithValueToForceFormToRefreshedWhenMoreDropdownDataNeedsToBeFetched.
@Test
public void shouldPopulateDtoWithValueToForceFormToRefreshedWhenMoreDropdownDataNeedsToBeFetched() throws Exception {
// setup
final Short branchId = userContext.getBranchId();
final Short branchId2 = Short.valueOf("2");
final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
OfficeDetailsDto officeStub2 = new OfficeDetailsDto(branchId2, "branchName2", levelId, Integer.valueOf(1));
List<OfficeDetailsDto> activeOffices = Arrays.asList(officeStub1, officeStub2);
// stub interaction with DAO/Persistence layer.
when(officePersistence.getActiveOffices(branchId)).thenReturn(activeOffices);
// exercise test
CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
// verification
assertThat(formDto.getReloadFormAutomatically(), is(Constants.YES));
}
use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class OfficePersistenceIntegrationTest method testGetChildOffices.
@Test
public void testGetChildOffices() throws Exception {
OfficeBO headOffice = TestObjectFactory.getOffice(TestObjectFactory.HEAD_OFFICE);
List<OfficeDetailsDto> officeList = getOfficePersistence().getChildOffices(headOffice.getSearchId());
Assert.assertEquals(3, officeList.size());
officeList = null;
headOffice = null;
}
use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class OfficeListTagTest method headRegionalBranch.
private List<OfficeDetailsDto> headRegionalBranch() {
List<OfficeDetailsDto> levels = new ArrayList<OfficeDetailsDto>();
levels.add(new OfficeDetailsDto(null, null, OfficeLevel.HEADOFFICE.getValue(), "Head", 0));
levels.add(new OfficeDetailsDto(null, null, OfficeLevel.REGIONALOFFICE.getValue(), "Regional", 0));
levels.add(new OfficeDetailsDto(null, null, OfficeLevel.BRANCHOFFICE.getValue(), "Branch", 0));
return Collections.unmodifiableList(levels);
}
use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class OfficeBusinessServiceIntegrationTest method testGetChildOffices.
@Test
public void testGetChildOffices() throws ServiceException {
OfficeBO headOffice = TestObjectFactory.getOffice(TestObjectFactory.HEAD_OFFICE);
List<OfficeDetailsDto> officeList = officeBusinessService.getChildOffices(headOffice.getSearchId());
Assert.assertEquals(3, officeList.size());
officeList = null;
headOffice = null;
}
Aggregations