Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable etag on latest version by resolving latest #479

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.finos.legend.depot.services.api.entities.EntitiesService;
import org.finos.legend.depot.core.services.tracing.resources.TracingResource;
import org.finos.legend.depot.services.api.EtagBuilder;
import org.finos.legend.depot.services.api.projects.ProjectsService;

import javax.inject.Inject;
import javax.ws.rs.DefaultValue;
Expand All @@ -45,11 +46,13 @@
public class EntitiesResource extends TracingResource
{
private final EntitiesService entitiesService;
private final ProjectsService projectsService;

@Inject
public EntitiesResource(EntitiesService entitiesService)
public EntitiesResource(EntitiesService entitiesService, ProjectsService projectsService)
{
this.entitiesService = entitiesService;
this.projectsService = projectsService;
}

@GET
Expand All @@ -61,7 +64,8 @@ public Response getEntities(@PathParam("groupId") String groupId,
@PathParam("versionId") @ApiParam(value = VersionValidator.VALID_VERSION_ID_TXT) String versionId,
@Context Request request)
{
return handle(GET_VERSION_ENTITIES, () -> this.entitiesService.getEntities(groupId, artifactId, versionId), request, () -> EtagBuilder.create().withGAV(groupId, artifactId, versionId).build());
String resolvedVersionId = this.projectsService.resolveAliasesAndCheckVersionExists(groupId, artifactId, versionId);
return handle(GET_VERSION_ENTITIES, () -> this.entitiesService.getEntities(groupId, artifactId, resolvedVersionId), request, () -> EtagBuilder.create().withGAV(groupId, artifactId, resolvedVersionId).build());
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.finos.legend.depot.domain.project.ProjectVersion;
import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService;
import org.finos.legend.depot.services.api.projects.ProjectsService;
import org.finos.legend.depot.services.metrics.query.InMemoryQueryMetricsRegistry;
import org.finos.legend.depot.services.metrics.query.QueryMetricsServiceImpl;
import org.finos.legend.depot.store.model.projects.StoreProjectData;
Expand Down Expand Up @@ -60,8 +61,9 @@ public class TestEntitiesResource extends TestBaseServices
private final Queue queue = mock(Queue.class);
private UpdateEntities entitiesStore = new EntitiesMongo(mongoProvider);
private EntitiesMongoTestUtils entityUtils = new EntitiesMongoTestUtils(mongoProvider);
private final EntitiesService entitiesService = new EntitiesServiceImpl(entitiesStore,new ProjectsServiceImpl(projectsVersions, projects, metricsRegistry, queue, new ProjectsConfiguration("master")));
private EntitiesResource entitiesResource = new EntitiesResource(entitiesService);
private ProjectsService projectsService = new ProjectsServiceImpl(projectsVersions, projects, metricsRegistry, queue, new ProjectsConfiguration("master"));
private final EntitiesService entitiesService = new EntitiesServiceImpl(entitiesStore,projectsService);
private EntitiesResource entitiesResource = new EntitiesResource(entitiesService, projectsService);
private QueryMetricsMongo metricsStore = new QueryMetricsMongo(mongoProvider);
private QueryMetricsService metricsHandler = new QueryMetricsServiceImpl(metricsStore);

Expand Down Expand Up @@ -135,7 +137,7 @@ public void canGetMetrics() throws InterruptedException
metricsHandler.persist(metricsRegistry);

Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime());
Assert.assertEquals(2, metricsStore.getAllStoredEntities().size());
Assert.assertEquals(3, metricsStore.getAllStoredEntities().size());
MauricioUyaguari marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
Expand Down
Loading