@Test(expected = IllegalStateOfArgumentException.class) public void renameFile_fromFileDoesNotExist() throws MalformedURLException, IOException, SecurityException, NoSuchMethodException { final File from = folder.newFile(); final IMockBuilder<File> builder = EasyMock.createMockBuilder(File.class); builder.withConstructor(URI.class); builder.withArgs(from.toURI()); builder.addMockedMethod(File.class.getMethod("exists")); final File fileMock = builder.createMock(); EasyMock.expect(fileMock.exists()).andReturn(false).anyTimes(); EasyMock.replay(fileMock); UpdateOperationWithCacheFileTask.renameFile(fileMock, folder.newFile()); EasyMock.verify(fileMock); }
protected static void renameFile(@Nonnull final File from, @Nonnull final File to) { Check.notNull(from, "from"); Check.stateIsTrue(from.exists(), "Argument 'from' must not be an existing file."); Check.notNull(to, "to"); Check.stateIsTrue(from.renameTo(to), "Renaming file from '%s' to '%s' failed.", from.getAbsolutePath(), to.getAbsolutePath()); }
UpdateOperationWithCacheFileTask extends AbstractUpdateOperation { protected static void renameFile(@Nonnull final File from, @Nonnull final File to) { Check.notNull(from, "from"); Check.stateIsTrue(from.exists(), "Argument 'from' must not be an existing file."); Check.notNull(to, "to"); Check.stateIsTrue(from.renameTo(to), "Renaming file from '%s' to '%s' failed.", from.getAbsolutePath(), to.getAbsolutePath()); } }
UpdateOperationWithCacheFileTask extends AbstractUpdateOperation { protected static void renameFile(@Nonnull final File from, @Nonnull final File to) { Check.notNull(from, "from"); Check.stateIsTrue(from.exists(), "Argument 'from' must not be an existing file."); Check.notNull(to, "to"); Check.stateIsTrue(from.renameTo(to), "Renaming file from '%s' to '%s' failed.", from.getAbsolutePath(), to.getAbsolutePath()); } UpdateOperationWithCacheFileTask(@Nonnull final AbstractRefreshableDataStore dataStore, @Nonnull final File cacheFile); }
UpdateOperationWithCacheFileTask extends AbstractUpdateOperation { protected static void renameFile(@Nonnull final File from, @Nonnull final File to) { Check.notNull(from, "from"); Check.stateIsTrue(from.exists(), "Argument 'from' must not be an existing file."); Check.notNull(to, "to"); Check.stateIsTrue(from.renameTo(to), "Renaming file from '%s' to '%s' failed.", from.getAbsolutePath(), to.getAbsolutePath()); } UpdateOperationWithCacheFileTask(@Nonnull final AbstractRefreshableDataStore dataStore, @Nonnull final File cacheFile); @Override void call(); }
UpdateOperationWithCacheFileTask extends AbstractUpdateOperation { protected static void renameFile(@Nonnull final File from, @Nonnull final File to) { Check.notNull(from, "from"); Check.stateIsTrue(from.exists(), "Argument 'from' must not be an existing file."); Check.notNull(to, "to"); Check.stateIsTrue(from.renameTo(to), "Renaming file from '%s' to '%s' failed.", from.getAbsolutePath(), to.getAbsolutePath()); } UpdateOperationWithCacheFileTask(@Nonnull final AbstractRefreshableDataStore dataStore, @Nonnull final File cacheFile); @Override void call();  }