@Test public void initShouldRethrowAndLogException(@Mocked final Files unused) { try { new Expectations() { { Files.createDirectory((Path) any); result = new IOException("testException123"); } }; } catch (IOException e) { fail("Unexpected exception in expectations block: " + e); } try { new FileSystemStorageService(mockOdeProperties).init(); } catch (Exception e) { assertEquals("Incorrect exception thrown.", StorageException.class, e.getClass()); assertTrue("Incorrect exception message", e.getMessage().startsWith("Failed to initialize storage service")); } new Verifications() { { EventLogger.logger.info("Failed to initialize storage service {}", (Path) any); } }; }
@Override public void init() { try { Files.createDirectory(rootLocation); } catch (IOException e) { EventLogger.logger.info("Failed to initialize storage service {}", this.rootLocation); throw new StorageException("Failed to initialize storage service " + this.rootLocation, e); } }
FileSystemStorageService implements StorageService { @Override public void init() { try { Files.createDirectory(rootLocation); } catch (IOException e) { EventLogger.logger.info("Failed to initialize storage service {}", this.rootLocation); throw new StorageException("Failed to initialize storage service " + this.rootLocation, e); } } }
FileSystemStorageService implements StorageService { @Override public void init() { try { Files.createDirectory(rootLocation); } catch (IOException e) { EventLogger.logger.info("Failed to initialize storage service {}", this.rootLocation); throw new StorageException("Failed to initialize storage service " + this.rootLocation, e); } } @Autowired  FileSystemStorageService(OdeProperties properties); }
FileSystemStorageService implements StorageService { @Override public void init() { try { Files.createDirectory(rootLocation); } catch (IOException e) { EventLogger.logger.info("Failed to initialize storage service {}", this.rootLocation); throw new StorageException("Failed to initialize storage service " + this.rootLocation, e); } } @Autowired  FileSystemStorageService(OdeProperties properties); @Override void store(MultipartFile file, String type); @Override Stream<Path> loadAll(); @Override Path load(String filename); @Override Resource loadAsResource(String filename); @Override void deleteAll(); @Override void init(); Path getRootLocation(); void setRootLocation(Path rootLocation); }
FileSystemStorageService implements StorageService { @Override public void init() { try { Files.createDirectory(rootLocation); } catch (IOException e) { EventLogger.logger.info("Failed to initialize storage service {}", this.rootLocation); throw new StorageException("Failed to initialize storage service " + this.rootLocation, e); } } @Autowired  FileSystemStorageService(OdeProperties properties); @Override void store(MultipartFile file, String type); @Override Stream<Path> loadAll(); @Override Path load(String filename); @Override Resource loadAsResource(String filename); @Override void deleteAll(); @Override void init(); Path getRootLocation(); void setRootLocation(Path rootLocation);  }