From b1cbd55f12c3aabe0821d50172abf9a09f4497e0 Mon Sep 17 00:00:00 2001 From: gs-gunjan Date: Thu, 2 Nov 2023 15:21:49 +0530 Subject: [PATCH] return optional empty for projects which have no latest version --- .../depot/services/projects/ProjectsServiceImpl.java | 2 +- .../depot/services/projects/TestProjectsService.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ProjectsServiceImpl.java b/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ProjectsServiceImpl.java index 24e7bd0c4..94f93ba39 100644 --- a/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ProjectsServiceImpl.java +++ b/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ProjectsServiceImpl.java @@ -154,7 +154,7 @@ public Optional find(String groupId, String artifactId, if (VersionAlias.LATEST.getName().equals(versionId)) { Optional projectData = this.findCoordinates(groupId, artifactId); - if (projectData.isPresent()) + if (projectData.isPresent() && projectData.get().getLatestVersion() != null) { return projectsVersions.find(groupId, artifactId, projectData.get().getLatestVersion()); } diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java index 7ed3df47a..86411bcde 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java @@ -287,6 +287,17 @@ public void canGetProjectCoordinatesByGA() Assert.assertFalse(storeProjectData1.isPresent()); } + @Test + public void canGetProjectVersionWithLatestVersionNull() + { + projectsStore.createOrUpdate(new StoreProjectData("PROD-123", "dummy.project", "test")); + Optional storeProjectData = projectsService.findCoordinates("dummy.project", "test"); + Assert.assertTrue(storeProjectData.isPresent()); + + Optional projectVersionData = projectsService.find("dummy.project", "test", "latest"); + Assert.assertFalse(projectVersionData.isPresent()); + } + @Test public void canRestoreEvictedProjectVersion() {