@Test public void test_getFileDownloadPath_exception() throws NoNepomukFoundException { Mockito.when(nepomukDiscoverer.getRandomNepomukInstance()).thenThrow(new NoNepomukFoundException()); IFile file = new File(); String ID = "ID"; file.setStorageId(ID); String url = serviceToTest.getFileDownloadPath(file); Assert.assertNull(url); }
@Override public String getFileDownloadPath(IFile file) { String nepomukUrl; try { nepomukUrl = nepomukDiscoverer.getRandomNepomukInstance(); } catch (NoNepomukFoundException e) { messageHandler.handleMessage("Could not download file. Nepomuk could not be reached.", e, MessageType.ERROR); return null; } if (file.getStorageId() == null) { messageHandler.handleMessage("Could not download file.", "Could not download file. No storage id present for " + file.getId() + ".", MessageType.ERROR); return null; } return nepomukUrl + propertyManager.getProperty(Properties.NEPOMUK_FILES_ENDPOINT).replace("{0}", file.getStorageId()); }
NepomukUrlService implements INepomukUrlService { @Override public String getFileDownloadPath(IFile file) { String nepomukUrl; try { nepomukUrl = nepomukDiscoverer.getRandomNepomukInstance(); } catch (NoNepomukFoundException e) { messageHandler.handleMessage("Could not download file. Nepomuk could not be reached.", e, MessageType.ERROR); return null; } if (file.getStorageId() == null) { messageHandler.handleMessage("Could not download file.", "Could not download file. No storage id present for " + file.getId() + ".", MessageType.ERROR); return null; } return nepomukUrl + propertyManager.getProperty(Properties.NEPOMUK_FILES_ENDPOINT).replace("{0}", file.getStorageId()); } }
NepomukUrlService implements INepomukUrlService { @Override public String getFileDownloadPath(IFile file) { String nepomukUrl; try { nepomukUrl = nepomukDiscoverer.getRandomNepomukInstance(); } catch (NoNepomukFoundException e) { messageHandler.handleMessage("Could not download file. Nepomuk could not be reached.", e, MessageType.ERROR); return null; } if (file.getStorageId() == null) { messageHandler.handleMessage("Could not download file.", "Could not download file. No storage id present for " + file.getId() + ".", MessageType.ERROR); return null; } return nepomukUrl + propertyManager.getProperty(Properties.NEPOMUK_FILES_ENDPOINT).replace("{0}", file.getStorageId()); }  }
NepomukUrlService implements INepomukUrlService { @Override public String getFileDownloadPath(IFile file) { String nepomukUrl; try { nepomukUrl = nepomukDiscoverer.getRandomNepomukInstance(); } catch (NoNepomukFoundException e) { messageHandler.handleMessage("Could not download file. Nepomuk could not be reached.", e, MessageType.ERROR); return null; } if (file.getStorageId() == null) { messageHandler.handleMessage("Could not download file.", "Could not download file. No storage id present for " + file.getId() + ".", MessageType.ERROR); return null; } return nepomukUrl + propertyManager.getProperty(Properties.NEPOMUK_FILES_ENDPOINT).replace("{0}", file.getStorageId()); }  @Override String getFileDownloadPath(IFile file); }
NepomukUrlService implements INepomukUrlService { @Override public String getFileDownloadPath(IFile file) { String nepomukUrl; try { nepomukUrl = nepomukDiscoverer.getRandomNepomukInstance(); } catch (NoNepomukFoundException e) { messageHandler.handleMessage("Could not download file. Nepomuk could not be reached.", e, MessageType.ERROR); return null; } if (file.getStorageId() == null) { messageHandler.handleMessage("Could not download file.", "Could not download file. No storage id present for " + file.getId() + ".", MessageType.ERROR); return null; } return nepomukUrl + propertyManager.getProperty(Properties.NEPOMUK_FILES_ENDPOINT).replace("{0}", file.getStorageId()); }  @Override String getFileDownloadPath(IFile file);  }