Extension implements Deliverable { static List<File> getPreviousVersionInstalled(File[] candidateFiles, String baseName) { return stream(candidateFiles).filter(f -> f.getName().startsWith(removePattern(endsWithVersion,baseName)) && endsWithVersion.matcher(getBaseName(f.getName())).matches()).collect(Collectors.toList()); } @JsonCreator  Extension(@JsonProperty("id") String id,
                  @JsonProperty("name") String name,
                  @JsonProperty("version") String version,
                  @JsonProperty("description") String description,
                  @JsonProperty("url") URL url,
                  @JsonProperty("type") Type type);   Extension(URL url, Type type);   Extension(URL url); @Override File download(); void install(Path extensionsDir); @Override void install(File extensionFile, Path extensionsDir); @Override void delete(Path installDir); @Override URL getUrl(); @Override String getId(); @Override String getName(); @Override String getDescription(); @Override String getVersion(); @Override Type getType(); Path getBasePath(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final String TMP_PREFIX; final String id; final String name; final String description; final URL url; final String version; final Type type; }
@Test public void test_has_previous_version() throws Exception { File[] files = new File[] {extensionsDir.newFile("extension-1.0.0.jar")}; assertThat(Extension.getPreviousVersionInstalled(files, "extension-0.1.0")).hasSize(1); assertThat(Extension.getPreviousVersionInstalled(files, "extension-1.1.0")).hasSize(1); assertThat(Extension.getPreviousVersionInstalled(files, "extension-1.1")).hasSize(1); assertThat(Extension.getPreviousVersionInstalled(files, "extension")).hasSize(1); assertThat(Extension.getPreviousVersionInstalled(files, "other-extension")).isEmpty(); assertThat(Extension.getPreviousVersionInstalled(files, "extension-other-1.2.3")).isEmpty(); }