@Test public void shouldSyncFacilityDistributionData() { FacilityVisit facilityVisit = new FacilityVisit(); FacilityDistribution facilityDistribution = mock(FacilityDistribution.class); when(facilityDistribution.getFacilityVisit()).thenReturn(facilityVisit); FacilityDistribution syncedFacilityDistribution = new FacilityDistribution(); FacilityDistribution savedFacilityDistribution = new FacilityDistribution(); FacilityVisit syncedVisit = new FacilityVisit(); syncedFacilityDistribution.setFacilityVisit(syncedVisit); when(facilityDistributionService.setSynced(facilityDistribution)).thenReturn(syncedFacilityDistribution); when(facilityDistributionService.save(syncedFacilityDistribution)).thenReturn(savedFacilityDistribution); FacilityDistribution returnedFacilityDistribution = service.sync(facilityDistribution); verify(facilityDistributionService).setSynced(facilityDistribution); verify(facilityDistributionService).save(syncedFacilityDistribution); assertThat(returnedFacilityDistribution, is(savedFacilityDistribution)); }
@Transactional public FacilityDistribution sync(FacilityDistribution facilityDistribution) { FacilityDistribution syncedDistribution = facilityDistributionService.setSynced(facilityDistribution); return facilityDistributionService.save(syncedDistribution); }
DistributionService { @Transactional public FacilityDistribution sync(FacilityDistribution facilityDistribution) { FacilityDistribution syncedDistribution = facilityDistributionService.setSynced(facilityDistribution); return facilityDistributionService.save(syncedDistribution); } }
DistributionService { @Transactional public FacilityDistribution sync(FacilityDistribution facilityDistribution) { FacilityDistribution syncedDistribution = facilityDistributionService.setSynced(facilityDistribution); return facilityDistributionService.save(syncedDistribution); }  }
DistributionService { @Transactional public FacilityDistribution sync(FacilityDistribution facilityDistribution) { FacilityDistribution syncedDistribution = facilityDistributionService.setSynced(facilityDistribution); return facilityDistributionService.save(syncedDistribution); }  @Transactional Distribution create(Distribution distribution); @Transactional FacilityDistribution sync(FacilityDistribution facilityDistribution); Distribution get(Distribution distribution); DistributionStatus updateDistributionStatus(Long distributionId, Long modifiedBy); List<Long> getSyncedPeriodsForDeliveryZoneAndProgram(Long zoneId, Long programId); Distribution getBy(Long distributionId); }
DistributionService { @Transactional public FacilityDistribution sync(FacilityDistribution facilityDistribution) { FacilityDistribution syncedDistribution = facilityDistributionService.setSynced(facilityDistribution); return facilityDistributionService.save(syncedDistribution); }  @Transactional Distribution create(Distribution distribution); @Transactional FacilityDistribution sync(FacilityDistribution facilityDistribution); Distribution get(Distribution distribution); DistributionStatus updateDistributionStatus(Long distributionId, Long modifiedBy); List<Long> getSyncedPeriodsForDeliveryZoneAndProgram(Long zoneId, Long programId); Distribution getBy(Long distributionId);  }