Patch { public List<PatchAction> getActions() { return myActions; } Patch(PatchSpec spec, UpdaterUI ui);  Patch(InputStream patchIn); List<PatchAction> getActions(); void write(OutputStream out); List<ValidationResult> validate(final File rootDir, UpdaterUI ui); ApplicationResult apply(final ZipFile patchFile,
                                 final File rootDir,
                                 final File backupDir,
                                 final Map<String, ValidationResult.Option> options,
                                 UpdaterUI ui); void revert(List<PatchAction> actions, final File backupDir, final File rootDir, UpdaterUI ui); long digestFile(File toFile, boolean normalize); Map<String, Long> digestFiles(File dir, List<String> ignoredFiles, boolean normalize, UpdaterUI ui); String getOldBuild(); String getNewBuild(); boolean isStrict(); boolean isNormalized(); boolean validateDeletion(String path);  }
@Test public void testBasics() throws Exception { List<PatchAction> expectedActions = Arrays.asList( new CreateAction(myPatch, "newDir/newFile.txt"), new UpdateAction(myPatch, "Readme.txt", CHECKSUMS.README_TXT), new UpdateZipAction(myPatch, "lib/annotations.jar", Arrays.asList("org/jetbrains/annotations/NewClass.class"), Arrays.asList("org/jetbrains/annotations/Nullable.class"), Arrays.asList("org/jetbrains/annotations/TestOnly.class"), CHECKSUMS.ANNOTATIONS_JAR), new UpdateZipAction(myPatch, "lib/bootstrap.jar", Collections.<String>emptyList(), Collections.<String>emptyList(), Arrays.asList("com/intellij/ide/ClassloaderUtil.class"), CHECKSUMS.BOOTSTRAP_JAR), new DeleteAction(myPatch, "bin/idea.bat", CHECKSUMS.IDEA_BAT)); List<PatchAction> actualActions = new ArrayList<PatchAction>(myPatch.getActions()); Collections.sort(expectedActions, COMPARATOR); Collections.sort(actualActions, COMPARATOR); assertEquals(expectedActions, actualActions); }
@Test public void testCreatingWithIgnoredFiles() throws Exception { PatchSpec spec = new PatchSpec() .setOldFolder(myOlderDir.getAbsolutePath()) .setNewFolder(myNewerDir.getAbsolutePath()) .setIgnoredFiles(Arrays.asList("Readme.txt", "bin/idea.bat")); myPatch = new Patch(spec, TEST_UI); List<PatchAction> expectedActions = Arrays.asList( new CreateAction(myPatch, "newDir/newFile.txt"), new UpdateZipAction(myPatch, "lib/annotations.jar", Arrays.asList("org/jetbrains/annotations/NewClass.class"), Arrays.asList("org/jetbrains/annotations/Nullable.class"), Arrays.asList("org/jetbrains/annotations/TestOnly.class"), CHECKSUMS.ANNOTATIONS_JAR), new UpdateZipAction(myPatch, "lib/bootstrap.jar", Collections.<String>emptyList(), Collections.<String>emptyList(), Arrays.asList("com/intellij/ide/ClassloaderUtil.class"), CHECKSUMS.BOOTSTRAP_JAR)); List<PatchAction> actualActions = new ArrayList<PatchAction>(myPatch.getActions()); Collections.sort(expectedActions, COMPARATOR); Collections.sort(actualActions, COMPARATOR); assertEquals(expectedActions, actualActions); }