@Test public void shouldGetSavedVisibilityForProgram() throws Exception { List<VaccineIvdTabVisibility> list = asList(new VaccineIvdTabVisibility()); when(repository.getVisibilityForProgram(2L)).thenReturn(list); when(repository.getAllVisibilityConfiguration()).thenReturn(null); List<VaccineIvdTabVisibility> result = service.getVisibilityForProgram(2L); assertThat(result, is(list)); verify(repository, never()).getAllVisibilityConfiguration(); }
public List<VaccineIvdTabVisibility> getVisibilityForProgram(Long programId){ List<VaccineIvdTabVisibility> visibilities = repository.getVisibilityForProgram(programId); if(emptyIfNull(visibilities).isEmpty()){ return repository.getAllVisibilityConfiguration(); } return visibilities; }
VaccineIvdTabVisibilityService { public List<VaccineIvdTabVisibility> getVisibilityForProgram(Long programId){ List<VaccineIvdTabVisibility> visibilities = repository.getVisibilityForProgram(programId); if(emptyIfNull(visibilities).isEmpty()){ return repository.getAllVisibilityConfiguration(); } return visibilities; } }
VaccineIvdTabVisibilityService { public List<VaccineIvdTabVisibility> getVisibilityForProgram(Long programId){ List<VaccineIvdTabVisibility> visibilities = repository.getVisibilityForProgram(programId); if(emptyIfNull(visibilities).isEmpty()){ return repository.getAllVisibilityConfiguration(); } return visibilities; }  }
VaccineIvdTabVisibilityService { public List<VaccineIvdTabVisibility> getVisibilityForProgram(Long programId){ List<VaccineIvdTabVisibility> visibilities = repository.getVisibilityForProgram(programId); if(emptyIfNull(visibilities).isEmpty()){ return repository.getAllVisibilityConfiguration(); } return visibilities; }  List<VaccineIvdTabVisibility> getVisibilityForProgram(Long programId); void save(List<VaccineIvdTabVisibility> visibilities, Long programId); }
VaccineIvdTabVisibilityService { public List<VaccineIvdTabVisibility> getVisibilityForProgram(Long programId){ List<VaccineIvdTabVisibility> visibilities = repository.getVisibilityForProgram(programId); if(emptyIfNull(visibilities).isEmpty()){ return repository.getAllVisibilityConfiguration(); } return visibilities; }  List<VaccineIvdTabVisibility> getVisibilityForProgram(Long programId); void save(List<VaccineIvdTabVisibility> visibilities, Long programId);  }