Skip to content

Commit

Permalink
[APHL-1201] test to ensure version ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
taha.attari@smilecdr.com committed Nov 20, 2024
1 parent 01daca2 commit ea35c62
Show file tree
Hide file tree
Showing 6 changed files with 1,662 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,4 +698,30 @@ void release_should_not_duplicate_components_as_dependencies() {
assertTrue(releasedRCTCLibrary.getRelatedArtifact().stream()
.anyMatch(ra -> ra.getType() == RelatedArtifactType.COMPOSEDOF));
}

@Test
void release_should_pin_the_latest_version_of_dependencies() {
var bundle = (Bundle) jsonParser.parseResource(
ReleaseVisitorTests.class.getResourceAsStream("Bundle-unversioned-dependency.json"));
repo.transaction(bundle);
var releaseVisitor = new ReleaseVisitor(repo);
var originalLibrary = repo.read(Library.class, new IdType("Library/SpecificationLibrary"))
.copy();
var testLibrary = originalLibrary.copy();
var libraryAdapter = new AdapterFactory().createLibrary(testLibrary);
var params =
parameters(part("version", new StringType("1.2.3")), part("versionBehavior", new CodeType("force")));
var returnResource = (Bundle) libraryAdapter.accept(releaseVisitor, params);
var maybeLib = returnResource.getEntry().stream()
.filter(entry -> entry.getResponse().getLocation().contains("Library/SpecificationLibrary"))
.findFirst();
assertTrue(maybeLib.isPresent());
var releasedLibrary =
repo.read(Library.class, new IdType(maybeLib.get().getResponse().getLocation()));
var maybeLeafRA = releasedLibrary.getRelatedArtifact().stream()
.filter(ra -> ra.getResource().getReference().contains("2.16.840.1.113762.1.4.1146.6"))
.findFirst();
assertTrue(maybeLeafRA.isPresent());
assertTrue(Canonicals.getVersion(maybeLeafRA.get().getResource().getReference()).equals("1.0.1"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,30 @@ void release_should_not_duplicate_components_as_dependencies() {
assertTrue(releasedRCTCLibrary.getRelatedArtifact().stream()
.anyMatch(ra -> ra.getType() == RelatedArtifactType.COMPOSEDOF));
}

@Test
void release_should_pin_the_latest_version_of_dependencies() {
var bundle = (Bundle) jsonParser.parseResource(
ReleaseVisitorTests.class.getResourceAsStream("Bundle-unversioned-dependency.json"));
repo.transaction(bundle);
var releaseVisitor = new ReleaseVisitor(repo);
var originalLibrary = repo.read(Library.class, new IdType("Library/SpecificationLibrary"))
.copy();
var testLibrary = originalLibrary.copy();
var libraryAdapter = new AdapterFactory().createLibrary(testLibrary);
var params =
parameters(part("version", new StringType("1.2.3")), part("versionBehavior", new CodeType("force")));
var returnResource = (Bundle) libraryAdapter.accept(releaseVisitor, params);
var maybeLib = returnResource.getEntry().stream()
.filter(entry -> entry.getResponse().getLocation().contains("Library/SpecificationLibrary"))
.findFirst();
assertTrue(maybeLib.isPresent());
var releasedLibrary =
repo.read(Library.class, new IdType(maybeLib.get().getResponse().getLocation()));
var maybeLeafRA = releasedLibrary.getRelatedArtifact().stream()
.filter(ra -> ra.getResource().contains("2.16.840.1.113762.1.4.1146.6"))
.findFirst();
assertTrue(maybeLeafRA.isPresent());
assertTrue(Canonicals.getVersion(maybeLeafRA.get().getResource()).equals("1.0.1"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,30 @@ void release_should_not_duplicate_components_as_dependencies() {
assertTrue(releasedRCTCLibrary.getRelatedArtifact().stream()
.anyMatch(ra -> ra.getType() == RelatedArtifactType.COMPOSEDOF));
}

@Test
void release_should_pin_the_latest_version_of_dependencies() {
var bundle = (Bundle) jsonParser.parseResource(
ReleaseVisitorTests.class.getResourceAsStream("Bundle-unversioned-dependency.json"));
repo.transaction(bundle);
var releaseVisitor = new ReleaseVisitor(repo);
var originalLibrary = repo.read(Library.class, new IdType("Library/SpecificationLibrary"))
.copy();
var testLibrary = originalLibrary.copy();
var libraryAdapter = new AdapterFactory().createLibrary(testLibrary);
var params =
parameters(part("version", new StringType("1.2.3")), part("versionBehavior", new CodeType("force")));
var returnResource = (Bundle) libraryAdapter.accept(releaseVisitor, params);
var maybeLib = returnResource.getEntry().stream()
.filter(entry -> entry.getResponse().getLocation().contains("Library/SpecificationLibrary"))
.findFirst();
assertTrue(maybeLib.isPresent());
var releasedLibrary =
repo.read(Library.class, new IdType(maybeLib.get().getResponse().getLocation()));
var maybeLeafRA = releasedLibrary.getRelatedArtifact().stream()
.filter(ra -> ra.getResource().contains("2.16.840.1.113762.1.4.1146.6"))
.findFirst();
assertTrue(maybeLeafRA.isPresent());
assertTrue(Canonicals.getVersion(maybeLeafRA.get().getResource()).equals("1.0.1"));
}
}
Loading

0 comments on commit ea35c62

Please sign in to comment.