From 446ec7399cd059ddd49d0a047b64fa9c03531a16 Mon Sep 17 00:00:00 2001 From: Rafael Bey Date: Fri, 13 Dec 2024 10:59:44 -0500 Subject: [PATCH] Serialize the data as found on entities rather than read it into protocol classes --- .../context/PureModelContextResource.java | 55 ++++++++----- .../context/PureModelContextService.java | 4 +- .../context/PureModelContextServiceImpl.java | 81 ++++++++++++++----- .../TestPureModelContextDataResource.java | 4 +- .../context/TestPureModelContextService.java | 45 +++++------ 5 files changed, 121 insertions(+), 68 deletions(-) diff --git a/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/server/resources/pure/model/context/PureModelContextResource.java b/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/server/resources/pure/model/context/PureModelContextResource.java index d041f755d..e3c240d8c 100644 --- a/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/server/resources/pure/model/context/PureModelContextResource.java +++ b/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/server/resources/pure/model/context/PureModelContextResource.java @@ -18,12 +18,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.finos.legend.depot.domain.project.ProjectVersion; -import org.finos.legend.depot.domain.version.VersionValidator; -import org.finos.legend.depot.services.api.pure.model.context.PureModelContextService; -import org.finos.legend.depot.core.services.tracing.resources.TracingResource; -import org.finos.legend.depot.services.api.EtagBuilder; - +import java.util.List; import javax.inject.Inject; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -36,11 +31,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Request; import javax.ws.rs.core.Response; - -import java.util.List; - import static org.finos.legend.depot.core.services.tracing.ResourceLoggingAndTracing.GET_VERSIONS_DEPENDENCY_ENTITIES_AS_PMCD; import static org.finos.legend.depot.core.services.tracing.ResourceLoggingAndTracing.GET_VERSION_ENTITIES_AS_PMCD; +import org.finos.legend.depot.core.services.tracing.resources.TracingResource; +import org.finos.legend.depot.domain.project.ProjectVersion; +import org.finos.legend.depot.domain.version.VersionValidator; +import org.finos.legend.depot.services.api.EtagBuilder; +import org.finos.legend.depot.services.api.pure.model.context.PureModelContextService; @Path("") @Api("Pure Model Context Data") @@ -59,28 +56,44 @@ public PureModelContextResource(PureModelContextService service) @Path("projects/{groupId}/{artifactId}/versions/{versionId}/pureModelContextData") @ApiOperation(GET_VERSION_ENTITIES_AS_PMCD) @Produces(MediaType.APPLICATION_JSON) - public Response getPureModelContextData(@PathParam("groupId") String groupId, - @PathParam("artifactId") String artifactId, - @PathParam("versionId") @ApiParam(value = VersionValidator.VALID_VERSION_ID_TXT) String versionId, - @QueryParam("clientVersion") String clientVersion, + public Response getPureModelContextData(@PathParam("groupId") + String groupId, + @PathParam("artifactId") + String artifactId, + @PathParam("versionId") @ApiParam(value = VersionValidator.VALID_VERSION_ID_TXT) + String versionId, + @QueryParam("clientVersion") + String clientVersion, @QueryParam("getDependencies") - @DefaultValue("true") - @ApiParam("Whether to include entities from dependencies") boolean transitive, - @Context Request request) + @DefaultValue("true") + @ApiParam("Whether to include entities from dependencies") + boolean transitive, + @QueryParam("convertToNewProtocol") + @DefaultValue("false") + @ApiParam("Whether to convert the protocol to latest or return the protocol as initially published") + boolean convertToNewProtocol, + @Context Request request) { - return handle(GET_VERSION_ENTITIES_AS_PMCD, () -> service.getPureModelContextData(groupId, artifactId, versionId, clientVersion, transitive), request, () -> EtagBuilder.create().withGAV(groupId, artifactId, versionId).withProtocolVersion(clientVersion).build()); + return handle(GET_VERSION_ENTITIES_AS_PMCD, () -> service.getPureModelContextData(groupId, artifactId, versionId, clientVersion, transitive, convertToNewProtocol), request, () -> EtagBuilder.create().withGAV(groupId, artifactId, versionId).withProtocolVersion(clientVersion).build()); } @POST @Path("projects/dependencies/pureModelContextData") @ApiOperation(GET_VERSIONS_DEPENDENCY_ENTITIES_AS_PMCD) @Produces(MediaType.APPLICATION_JSON) - public Response getPureModelContextData(@ApiParam("projectDependencies") List projectDependencies, - @QueryParam("clientVersion") String clientVersion, + public Response getPureModelContextData(@ApiParam("projectDependencies") + List projectDependencies, + @QueryParam("clientVersion") + String clientVersion, @QueryParam("transitive") @DefaultValue("true") - @ApiParam("Whether to return transitive dependencies") boolean transitive, + @ApiParam("Whether to return transitive dependencies") + boolean transitive, + @QueryParam("convertToNewProtocol") + @DefaultValue("false") + @ApiParam("Whether to convert the protocol to latest or return the protocol as initially published") + boolean convertToNewProtocol, @Context Request request) { - return handleResponse(GET_VERSIONS_DEPENDENCY_ENTITIES_AS_PMCD, () -> service.getPureModelContextData(projectDependencies, clientVersion, transitive)); + return handleResponse(GET_VERSIONS_DEPENDENCY_ENTITIES_AS_PMCD, () -> service.getPureModelContextData(projectDependencies, clientVersion, transitive, convertToNewProtocol)); } } diff --git a/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/services/api/pure/model/context/PureModelContextService.java b/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/services/api/pure/model/context/PureModelContextService.java index 408d31f14..f97c4ce79 100644 --- a/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/services/api/pure/model/context/PureModelContextService.java +++ b/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/services/api/pure/model/context/PureModelContextService.java @@ -22,7 +22,7 @@ public interface PureModelContextService { - PureModelContextData getPureModelContextData(String groupId, String artifactId, String versionId, String clientVersion, boolean transitive); + PureModelContextData getPureModelContextData(String groupId, String artifactId, String versionId, String clientVersion, boolean transitive, boolean convertToNewProtocol); - PureModelContextData getPureModelContextData(List projectDependencies, String clientVersion, boolean transitive); + PureModelContextData getPureModelContextData(List projectDependencies, String clientVersion, boolean transitive, boolean convertToNewProtocol); } diff --git a/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/services/pure/model/context/PureModelContextServiceImpl.java b/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/services/pure/model/context/PureModelContextServiceImpl.java index ef38ba297..04445544c 100644 --- a/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/services/pure/model/context/PureModelContextServiceImpl.java +++ b/legend-depot-pure-model-context/src/main/java/org/finos/legend/depot/services/pure/model/context/PureModelContextServiceImpl.java @@ -15,6 +15,14 @@ package org.finos.legend.depot.services.pure.model.context; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.util.StdConverter; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Stream; +import javax.inject.Inject; import org.finos.legend.depot.core.services.tracing.TracerFactory; import org.finos.legend.depot.domain.entity.ProjectVersionEntities; import org.finos.legend.depot.domain.project.ProjectVersion; @@ -24,41 +32,39 @@ import org.finos.legend.engine.protocol.pure.PureClientVersions; import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; +import static org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData.newBuilder; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; import org.finos.legend.sdlc.domain.model.entity.Entity; +import org.finos.legend.sdlc.protocol.pure.v1.EntityToPureConverter; import org.finos.legend.sdlc.protocol.pure.v1.PureModelContextDataBuilder; -import javax.inject.Inject; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData.newBuilder; - public class PureModelContextServiceImpl implements PureModelContextService { private static final String PURE = "pure"; private static final String CALCULATE_COMBINED_PMCD = "calculate combined PMCD"; private static final String GA_SEPARATOR = ":"; private static final TracerFactory tracer = TracerFactory.get(); - private final EntitiesService entitiesService; + private final EntitiesService entitiesService; private final ProjectsService projectsService; + private final EntityToPureConverter entityToPureConverter = new EntityToPureConverter(); + private final EntityToRawPureConverter entityToRawPureConverter = new EntityToRawPureConverter(); @Inject - public PureModelContextServiceImpl(EntitiesService entitiesService, ProjectsService projectsService) + public PureModelContextServiceImpl(EntitiesService entitiesService, ProjectsService projectsService) { this.entitiesService = entitiesService; this.projectsService = projectsService; } @Override - public PureModelContextData getPureModelContextData(String groupId, String artifactId, String versionId, String clientVersion, boolean transitive) + public PureModelContextData getPureModelContextData(String groupId, String artifactId, String versionId, String clientVersion, boolean transitive, boolean convertToNewProtocol) { String resolvedClientVersion = resolveAndValidateClientVersion(clientVersion); String version = this.projectsService.resolveAliasesAndCheckVersionExists(groupId, artifactId, versionId); List entities = this.entitiesService.getEntities(groupId, artifactId, version); - PureModelContextData pureModelContextData = buildPureModelContextData(entities.stream(), groupId, artifactId, version, resolvedClientVersion); + PureModelContextData pureModelContextData = buildPureModelContextData(entities.stream(), groupId, artifactId, version, resolvedClientVersion, convertToNewProtocol); if (!transitive) { return pureModelContextData; @@ -67,17 +73,17 @@ public PureModelContextData getPureModelContextData(String groupId, String artif List dependenciesEntities = this.entitiesService.getDependenciesEntities(groupId, artifactId, version, true, false); return tracer.executeWithTrace(CALCULATE_COMBINED_PMCD, () -> { - PureModelContextData dependenciesPMCD = buildPureModelContextData(dependenciesEntities.stream().flatMap(dep -> dep.getEntities().stream()),groupId,artifactId,version,resolvedClientVersion); + PureModelContextData dependenciesPMCD = buildPureModelContextData(dependenciesEntities.stream().flatMap(dep -> dep.getEntities().stream()),groupId,artifactId,version,resolvedClientVersion, convertToNewProtocol); return combinePureModelContextData(pureModelContextData,dependenciesPMCD); }); } @Override - public PureModelContextData getPureModelContextData(List projectDependencies, String clientVersion, boolean transitive) + public PureModelContextData getPureModelContextData(List projectDependencies, String clientVersion, boolean transitive, boolean convertToNewProtocol) { String resolvedClientVersion = resolveAndValidateClientVersion(clientVersion); - List dependenciesEntities = (List) entitiesService.getDependenciesEntities(projectDependencies, transitive, true); - return buildPureModelContextData(dependenciesEntities.stream().flatMap(dep -> dep.getEntities().stream()), new AlloySDLC(), resolvedClientVersion); + List dependenciesEntities = entitiesService.getDependenciesEntities(projectDependencies, transitive, true); + return buildPureModelContextData(dependenciesEntities.stream().flatMap(dep -> dep.getEntities().stream()), new AlloySDLC(), resolvedClientVersion, convertToNewProtocol); } protected String resolveAndValidateClientVersion(String clientVersion) @@ -89,15 +95,17 @@ protected String resolveAndValidateClientVersion(String clientVersion) return clientVersion == null ? PureClientVersions.production : clientVersion; } - protected PureModelContextData buildPureModelContextData(Stream entities, String groupId, String artifactId, String versionId, String clientVersion) + protected PureModelContextData buildPureModelContextData(Stream entities, String groupId, String artifactId, String versionId, String clientVersion, boolean convertToNewProtocol) { - return buildPureModelContextData(entities, buildAlloySDLC(groupId, artifactId, versionId), clientVersion); + return buildPureModelContextData(entities, buildAlloySDLC(groupId, artifactId, versionId), clientVersion, convertToNewProtocol); } - protected PureModelContextData buildPureModelContextData(Stream entities, AlloySDLC alloySDLC, String clientVersion) + protected PureModelContextData buildPureModelContextData(Stream entities, AlloySDLC alloySDLC, String clientVersion, boolean convertToNewProtocol) { + EntityToPureConverter converter = convertToNewProtocol ? this.entityToPureConverter : this.entityToRawPureConverter; + return PureModelContextDataBuilder - .newBuilder() + .newBuilder(converter) .withProtocol(PURE, clientVersion) .withSDLC(alloySDLC) .withEntitiesIfPossible(entities) @@ -119,4 +127,39 @@ protected AlloySDLC buildAlloySDLC(String groupId, String artifactId, String ver sdlc.baseVersion = versionId; return sdlc; } + + private static class EntityToRawPureConverter extends EntityToPureConverter + { + @Override + public PackageableElement fromEntity(Entity entity) + { + return new EntityPackageableElement(entity); + } + + @Override + public Optional fromEntityIfPossible(Entity entity) + { + return Optional.of(this.fromEntity(entity)); + } + + @JsonSerialize(converter = EntityPackageableElementConverter.class) + private static class EntityPackageableElement extends PackageableElement + { + private final Entity entity; + + public EntityPackageableElement(Entity entity) + { + this.entity = entity; + } + } + } + + private static final class EntityPackageableElementConverter extends StdConverter> + { + @Override + public Map convert(EntityToRawPureConverter.EntityPackageableElement value) + { + return value.entity.getContent(); + } + } } diff --git a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java index 6632f729b..489e216bf 100644 --- a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java +++ b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java @@ -68,7 +68,7 @@ public void setUpData() @Test public void loadPMCD() { - Response data = resource.getPureModelContextData("test.legend", "blank-prod", "2.0.0", null, false,null); + Response data = resource.getPureModelContextData("test.legend", "blank-prod", "2.0.0", null, false,true, null); Assert.assertFalse(((PureModelContextData)data.getEntity()).getElements().isEmpty()); Assert.assertEquals(((PureModelContextData)data.getEntity()).getElements().size(), 2); @@ -77,7 +77,7 @@ public void loadPMCD() @Test public void loadDependenciesPMCD() { - Response data = resource.getPureModelContextData(List.of(new ProjectVersion("org.finos.legend","second-project","1.0.1"), new ProjectVersion("org.finos.legend","first-project","1.0.2")), null, true, null); + Response data = resource.getPureModelContextData(List.of(new ProjectVersion("org.finos.legend","second-project","1.0.1"), new ProjectVersion("org.finos.legend","first-project","1.0.2")), null, true, true, null); Assert.assertFalse(((PureModelContextData)data.getEntity()).getElements().isEmpty()); Assert.assertEquals(6, ((PureModelContextData)data.getEntity()).getElements().size()); Optional optionalPersonClass = ((PureModelContextData)data.getEntity()) diff --git a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java index 81790462c..1a8f134eb 100644 --- a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java +++ b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java @@ -18,26 +18,28 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; -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; -import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; -import org.finos.legend.depot.services.api.pure.model.context.PureModelContextService; +import java.net.URL; +import java.util.List; +import static org.finos.legend.depot.domain.version.VersionValidator.BRANCH_SNAPSHOT; import org.finos.legend.depot.services.TestBaseServices; import org.finos.legend.depot.services.api.entities.EntitiesService; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; +import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.depot.services.api.projects.ProjectsService; +import org.finos.legend.depot.services.api.projects.configuration.ProjectsConfiguration; +import org.finos.legend.depot.services.api.pure.model.context.PureModelContextService; import org.finos.legend.depot.services.entities.EntitiesServiceImpl; +import org.finos.legend.depot.services.metrics.query.InMemoryQueryMetricsRegistry; +import org.finos.legend.depot.services.metrics.query.QueryMetricsServiceImpl; import org.finos.legend.depot.services.projects.ProjectsServiceImpl; import org.finos.legend.depot.store.api.entities.UpdateEntities; import org.finos.legend.depot.store.api.metrics.query.QueryMetrics; -import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; - -import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; -import org.finos.legend.depot.services.api.projects.configuration.ProjectsConfiguration; +import org.finos.legend.depot.store.model.projects.StoreProjectData; +import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; +import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; -import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.shared.core.ObjectMapperFactory; @@ -46,11 +48,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; - -import java.net.URL; -import java.util.List; - -import static org.finos.legend.depot.domain.version.VersionValidator.BRANCH_SNAPSHOT; import static org.mockito.Mockito.mock; public class TestPureModelContextService extends TestBaseServices @@ -69,14 +66,14 @@ public class TestPureModelContextService extends TestBaseServices private final Queue queue = mock(Queue.class); ProjectsService projectsService = new ProjectsServiceImpl(projectsVersionsStore, projectsStore, metricsRegistry, queue, new ProjectsConfiguration("master")); protected UpdateEntities entitiesStore = new EntitiesMongo(mongoProvider); - private EntitiesMongoTestUtils entityUtils = new EntitiesMongoTestUtils(mongoProvider); + private EntitiesMongoTestUtils entityUtils = new EntitiesMongoTestUtils(mongoProvider); private final PureModelContextService service = new PureModelContextServiceImpl(new EntitiesServiceImpl(entitiesStore, projectsService), projectsService); private final ObjectMapper objectMapper = ObjectMapperFactory.getNewStandardObjectMapperWithPureProtocolExtensionSupports().setSerializationInclusion(JsonInclude.Include.NON_NULL); private String getPureModelContextDataAsString(String groupId, String artifactId, String versionId, String clientVersion, boolean getDependencies) { - return toString(service.getPureModelContextData(groupId, artifactId, versionId, clientVersion, getDependencies)); + return toString(service.getPureModelContextData(groupId, artifactId, versionId, clientVersion, getDependencies, true)); } private String toString(PureModelContextData contextData) @@ -100,7 +97,7 @@ private String toString(PureModelContextData contextData) @Before public void setupMetadata() { - projectsStore.createOrUpdate(new StoreProjectData("PROD-1","test.legend","blank-prod",null, "2.0.0")); + projectsStore.createOrUpdate(new StoreProjectData("PROD-1", "test.legend", "blank-prod", null, "2.0.0")); setUpProjectsVersionsFromFile(projects); Assert.assertEquals(4, projectsService.getAllProjectCoordinates().size()); entityUtils.loadEntities(versionedEntities); @@ -142,7 +139,7 @@ public void canGetEntitiesAsPureModelContextData() @Test(expected = IllegalArgumentException.class) public void testNonExistentProject() { - getPureModelContextDataAsString("non.existent.project", "test",BRANCH_SNAPSHOT("master"), CLIENT_VERSION, false); + getPureModelContextDataAsString("non.existent.project", "test", BRANCH_SNAPSHOT("master"), CLIENT_VERSION, false); } @Test @@ -173,7 +170,7 @@ public void canGetEntitiesForProjectAsPureModelContextData_WithDependencies() Assert.assertNotNull(modelContextDataAsString); Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"service\",\"autoActivateUpdates\":true,\"documentation\":\"\",\"execution\":{\"_type\":\"pureMultiExecution\",\"executionKey\":\"env\",\"executionParameters\":[{\"key\":\"PROD\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}},{\"key\":\"DEV\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}}],\"func\":{\"_type\":\"lambda\",\"body\":[{\"_type\":\"func\",\"function\":\"project\",\"parameters\":[{\"_type\":\"func\",\"function\":\"getAll\",\"parameters\":[{\"_type\":\"packageableElementPtr\",\"fullPath\":\"domain::COVIDData\"}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"lambda\",\"body\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}],\"property\":\"cases\"}],\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}]}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"string\",\"value\":\"Cases\"}]}]}],\"parameters\":[]}},\"name\":\"SomeService\",\"owners\":[\"anonymous\",\"akphi\"],\"package\":\"service\",\"pattern\":\"/9566f101-2108-408f-863f-6d7e154dc17a\",\"postValidations\":[],\"stereotypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Person\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::blank_prod::v2_0_0::blank\",\"properties\":[],\"qualifiedProperties\":[],\"sourceInformation\":{\"endColumn\":1,\"endLine\":3,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":1},\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"test\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::com\",\"properties\":[],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClassWithDependency\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.0.0\",\"packageableElementPointers\":[],\"project\":\"test.legend:blank-prod\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); - PureModelContextData pureModelContextData = service.getPureModelContextData("test.legend", "blank-prod", "2.0.0", CLIENT_VERSION, true); + PureModelContextData pureModelContextData = service.getPureModelContextData("test.legend", "blank-prod", "2.0.0", CLIENT_VERSION, true, true); Assert.assertNotNull(pureModelContextData); Assert.assertEquals("2.0.0", pureModelContextData.origin.sdlcInfo.baseVersion); Assert.assertEquals("test.legend:blank-prod", ((AlloySDLC) pureModelContextData.origin.sdlcInfo).project); @@ -186,7 +183,7 @@ public void canGetEntitiesForProjectAsPureModelContextDataWithLatestAsVersion() Assert.assertNotNull(entityList1); Assert.assertEquals(2, entityList1.size()); - String modelContextDataAsString = getPureModelContextDataAsString("test.legend", "blank-prod", "latest", CLIENT_VERSION, false); + String modelContextDataAsString = getPureModelContextDataAsString("test.legend", "blank-prod", "latest", CLIENT_VERSION, false); Assert.assertNotNull(modelContextDataAsString); Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"service\",\"autoActivateUpdates\":true,\"documentation\":\"\",\"execution\":{\"_type\":\"pureMultiExecution\",\"executionKey\":\"env\",\"executionParameters\":[{\"key\":\"PROD\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}},{\"key\":\"DEV\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}}],\"func\":{\"_type\":\"lambda\",\"body\":[{\"_type\":\"func\",\"function\":\"project\",\"parameters\":[{\"_type\":\"func\",\"function\":\"getAll\",\"parameters\":[{\"_type\":\"packageableElementPtr\",\"fullPath\":\"domain::COVIDData\"}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"lambda\",\"body\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}],\"property\":\"cases\"}],\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}]}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"string\",\"value\":\"Cases\"}]}]}],\"parameters\":[]}},\"name\":\"SomeService\",\"owners\":[\"anonymous\",\"akphi\"],\"package\":\"service\",\"pattern\":\"/9566f101-2108-408f-863f-6d7e154dc17a\",\"postValidations\":[],\"stereotypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Person\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::blank_prod::v2_0_0::blank\",\"properties\":[],\"qualifiedProperties\":[],\"sourceInformation\":{\"endColumn\":1,\"endLine\":3,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":1},\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.0.0\",\"packageableElementPointers\":[],\"project\":\"test.legend:blank-prod\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); } @@ -194,7 +191,7 @@ public void canGetEntitiesForProjectAsPureModelContextDataWithLatestAsVersion() @Test public void canGetEntitiesForProjectAsPureModelContextDataWithMetricsStored() { - getPureModelContextDataAsString("examples.metadata", "test", "2.3.1", CLIENT_VERSION, true); + getPureModelContextDataAsString("examples.metadata", "test", "2.3.1", CLIENT_VERSION, true); metricsHandler.persist(metricsRegistry); Assert.assertEquals(metrics.getAll().size(), 4); Assert.assertNotNull(metrics.get("examples.metadata", "test-dependencies", "1.0.0").get(0).getLastQueryTime()); @@ -212,6 +209,6 @@ public void canGetEntitiesAsPureModelContextDataWithHeadVersionAlias() @Test public void testErrorThrownWhenIncorrectClientVersionProvided() { - Assert.assertThrows(IllegalArgumentException.class, () -> getPureModelContextDataAsString("examples.metadata","test", "lastest", "dummy_version", false)); + Assert.assertThrows(IllegalArgumentException.class, () -> getPureModelContextDataAsString("examples.metadata", "test", "lastest", "dummy_version", false)); } }