ServiceDispensationRepository { public boolean save(ArrayList<ServiceDispensation> serviceDispensations) throws LMISException { return genericDao.create(serviceDispensations); } @Inject  ServiceDispensationRepository(Context context); boolean save(ArrayList<ServiceDispensation> serviceDispensations);  }
@Test public void shouldSaveServiceDispensationsWhenPtvProgramStockInformationExists() throws Exception { Period period = new Period(DateTime.now()); PTVProgram ptvProgram = PTVUtil.createDummyPTVProgram(period); Product product = Product.dummyProduct(); PTVProgramStockInformation ptvProgramStockInformation = new PTVProgramStockInformation(); ptvProgramStockInformation.setProduct(product); ptvProgramStockInformation.setPtvProgram(ptvProgram); HealthFacilityService healthFacilityService = new HealthFacilityService(); ServiceDispensation serviceDispensation = new ServiceDispensation(); serviceDispensation.setPtvProgramStockInformation(ptvProgramStockInformation); serviceDispensation.setHealthFacilityService(healthFacilityService); ServiceDispensation serviceDispensation2 = new ServiceDispensation(); serviceDispensation2.setPtvProgramStockInformation(ptvProgramStockInformation); serviceDispensation2.setHealthFacilityService(healthFacilityService); boolean isSaved = serviceDispensationRepository.save(newArrayList(serviceDispensation,serviceDispensation2)); assertThat(isSaved, is(true)); }
@Test (expected = LMISException.class) public void shouldThrowExceptionTryingToSaveServiceDispensationsWhenForeignObjectsAreNull() throws Exception { ServiceDispensation serviceDispensation = new ServiceDispensation(); ServiceDispensation serviceDispensation2 = new ServiceDispensation(); serviceDispensationRepository.save(newArrayList(serviceDispensation, serviceDispensation2)); }