PackageMojo extends AbstractMuleMojo { protected File getDestinationFile(String targetFolder) throws MojoExecutionException { checkArgument(targetFolder != null, "The target folder must not be null"); Path destinationPath = Paths.get(targetFolder, getFileName()); try { Files.deleteIfExists(destinationPath); } catch (IOException e) { throw new MojoExecutionException(String.format("Exception deleting the file [%s]", destinationPath), e); } return destinationPath.toFile(); }  @Override void doExecute(); @Override String getPreviousRunPlaceholder();  }
@Test public void getDestinationFileTest() throws MojoExecutionException, IOException { mojo.classifier = Classifier.MULE_APPLICATION.toString(); when(projectMock.getPackaging()).thenReturn(MULE_APPLICATION); when(projectMock.getPackaging()).thenReturn(PackagingType.MULE_APPLICATION.toString()); File expectedDestinationFile = targetFolder.newFile(FINAL_NAME + "-" + MULE_APPLICATION + "." + TYPE); File destinationFile = mojo.getDestinationFile(targetFolder.getRoot().getPath()); assertThat("Destination file is not the expected", destinationFile.getAbsolutePath(), equalTo(expectedDestinationFile.getAbsolutePath())); }
@Test public void getDestinationFileNullArgumentTest() throws MojoExecutionException, IOException { expectedException.expect(IllegalArgumentException.class); mojo.getDestinationFile(null); }