### Question:
DicomWebViewer { public String getDicomViewerUrl(RadiologyStudy radiologyStudy) { if (radiologyStudy == null) { throw new IllegalArgumentException("study cannot be null"); } else if (radiologyStudy.getStudyInstanceUid() == null) { throw new IllegalArgumentException("studyInstanceUid cannot be null"); } final UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.newInstance() .scheme("http") .host(radiologyProperties.getDicomWebViewerAddress()) .port(Integer.valueOf(radiologyProperties.getDicomWebViewerPort())) .path(radiologyProperties.getDicomWebViewerBaseUrl()) .queryParam("studyUID", radiologyStudy.getStudyInstanceUid()); final String serverName = radiologyProperties.getDicomWebViewerLocalServerName(); if (StringUtils.isNotBlank(serverName)) { uriComponentsBuilder.queryParam("serverName", serverName); } return uriComponentsBuilder.buildAndExpand() .encode() .toString(); }  String getDicomViewerUrl(RadiologyStudy radiologyStudy);  }### Answer:
@Test public void shouldReturnAUrlToOpenDicomImagesOfTheGivenStudyInTheConfiguredDicomViewer() { RadiologyStudy radiologyStudy = getMockStudy(); assertThat(dicomviewer.getDicomViewerUrl(radiologyStudy), is("http: }
@Test public void shouldAddQueryParamServerNameToUrlIfLocalServerNameIsNotBlank() { when(radiologyProperties.getDicomWebViewerBaseUrl()).thenReturn("/oviyam2/viewer.html"); when(radiologyProperties.getDicomWebViewerLocalServerName()).thenReturn("oviyamlocal"); RadiologyStudy radiologyStudy = getMockStudy(); assertThat(dicomviewer.getDicomViewerUrl(radiologyStudy), is("http: + radiologyStudy.getStudyInstanceUid() + "&serverName=oviyamlocal")); }
@Test public void shouldFailGivenNull() throws Exception { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(is("study cannot be null")); dicomviewer.getDicomViewerUrl(null); }
@Test public void shouldFailGivenAStudyWithStudyInstanceUidNull() throws Exception { RadiologyStudy radiologyStudy = new RadiologyStudy(); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(is("studyInstanceUid cannot be null")); dicomviewer.getDicomViewerUrl(radiologyStudy); }