I am trying to write a unit test for the save-as action of an editor using Mockito.
I created a temporary folder, a Mock WorkspaceRoot, and there are two files with coresponding IPaths:
public TemporaryFolder tempFolder = new TemporaryFolder();
private WorkspaceRoot root;
Afterwards I set the root location to the tempFolder, created the files and set the paths accordingly:
File location = tempFolder.newFolder("someNewFolder");
IPath path= new Path(location.getAbsolutePath());
newFile=new File(location, NEW_FILE);
originalFile=new File(location, ORIGINAL_FILE);
The plan is to call the
with the mocked workspace root and the path for the files that I created, like this:
performSaveAsAction(IWorkspaceRoot root, IPath newPath, IPath originalPath)
performSaveAsAction(root, newFilePath, originalFilePath)
This should create a new file using the newFilePath with the contents of the file found at originalFilePath.
But I cannot set the root to return either of the files, as the getFile() method needs to return an IFile and both files are java.io.File:
Any ideas on how to set the root to return the files I created, or how I could create IFiles in the desired directory, without setting up a whole project?