PublishPackage extends AbstractCommand { @Override public void execute() throws Exception { logger.trace("Starting {}...", this); final ProjectFile rootProject = readProject(); final String buildTarget = rootProject.getTarget(); assertNotNull(buildTarget, bind(NL_0)); if (!exists(Paths.get(buildTarget))) { new BuildProject().execute(); } final String publishRepository = append(System.getProperty("user.home"), MODULES_BASE); final Path publishPath = Paths.get(append(publishRepository, rootProject.getName())); if (exists(publishPath)) { deleteRecursively(publishPath, ALLOW_INSECURE); } createDirectories(publishPath); FileSet.from(Paths.get(".")).copyTo(publishPath); printer.println(NL_1, rootProject.getName()); printer.println(NL_2, publishPath); }  @Override void execute();  }
@Test @PrepareForTest({PublishPackage.class, FileSet.class}) public void testExecute() throws Exception { final ProjectFile projectFile = new ProjectFile(); projectFile.setTarget(randomUUID().toString()); final PublishPackage publishPackage = new PublishPackage() { @Override public ProjectFile readProject() { return projectFile; } }; FileSet fileSet = mock(FileSet.class); mockStatic(FileSet.class); when(FileSet.from(any())).thenReturn(fileSet); final BuildProject buildProject = mock(BuildProject.class); whenNew(BuildProject.class).withAnyArguments().thenReturn(buildProject); mockStatic(Files.class); publishPackage.execute(); }