From 83436aa15e306d8e3000d86afe2b2d1c1f23e14a Mon Sep 17 00:00:00 2001 From: Rafael Bey Date: Wed, 5 Jun 2024 11:39:41 -0400 Subject: [PATCH] Fix test cases given new protocol class structure (update engine@4.47.2) --- .../sdlc/generation/model/TestModelGenerationFactory.java | 3 ++- .../sdlc/protocol/pure/v1/TestEntityToPureConverter.java | 5 +++-- .../sdlc/protocol/pure/v1/TestPureToEntityConverter.java | 5 +++-- .../sdlc/protocol/TestEntityToProtocolConverter.java | 3 ++- .../sdlc/protocol/TestProtocolToEntityConverter.java | 8 +++++--- pom.xml | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/legend-sdlc-generation-model/src/test/java/org/finos/legend/sdlc/generation/model/TestModelGenerationFactory.java b/legend-sdlc-generation-model/src/test/java/org/finos/legend/sdlc/generation/model/TestModelGenerationFactory.java index 31a7e45735..ec9f7387aa 100644 --- a/legend-sdlc-generation-model/src/test/java/org/finos/legend/sdlc/generation/model/TestModelGenerationFactory.java +++ b/legend-sdlc-generation-model/src/test/java/org/finos/legend/sdlc/generation/model/TestModelGenerationFactory.java @@ -15,6 +15,7 @@ package org.finos.legend.sdlc.generation.model; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; +import org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.generationSpecification.GenerationSpecification; @@ -84,7 +85,7 @@ public PureModelContextData generateModel() Class myClass = new Class(); myClass.name = "MyComplexClass"; myClass._package = "model"; - myClass.superTypes = Collections.singletonList("model::MyClass"); + myClass.superTypes = Collections.singletonList(new PackageableElementPointer("model::MyClass")); builder.addElement(myClass); return builder.build(); } diff --git a/legend-sdlc-protocol-pure/src/test/java/org/finos/legend/sdlc/protocol/pure/v1/TestEntityToPureConverter.java b/legend-sdlc-protocol-pure/src/test/java/org/finos/legend/sdlc/protocol/pure/v1/TestEntityToPureConverter.java index d41e12d3ea..9aadfcd60b 100644 --- a/legend-sdlc-protocol-pure/src/test/java/org/finos/legend/sdlc/protocol/pure/v1/TestEntityToPureConverter.java +++ b/legend-sdlc-protocol-pure/src/test/java/org/finos/legend/sdlc/protocol/pure/v1/TestEntityToPureConverter.java @@ -14,6 +14,7 @@ package org.finos.legend.sdlc.protocol.pure.v1; +import java.util.stream.Collectors; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; import org.finos.legend.sdlc.domain.model.TestTools; @@ -37,7 +38,7 @@ public void testFromEntity() Class resultClass = (Class) result; Assert.assertEquals("EmptyClass", resultClass.name); Assert.assertEquals("model::test", resultClass._package); - Assert.assertEquals(Collections.singletonList("meta::pure::metamodel::type::Any"), resultClass.superTypes); + Assert.assertEquals(Collections.singletonList("meta::pure::metamodel::type::Any"), resultClass.superTypes.stream().map(x -> x.path).collect(Collectors.toList())); Assert.assertEquals(Collections.emptyList(), resultClass.properties); IllegalArgumentException e = Assert.assertThrows(IllegalArgumentException.class, () -> this.converter.fromEntity(Entity.newEntity("not::a::real::PureEntity", "meta::unknown::NotAClassifier", Collections.emptyMap()))); @@ -60,7 +61,7 @@ public void testFromEntityIfPossible() Class resultClass = (Class) result.get(); Assert.assertEquals("EmptyClass", resultClass.name); Assert.assertEquals("model::test", resultClass._package); - Assert.assertEquals(Collections.singletonList("meta::pure::metamodel::type::Any"), resultClass.superTypes); + Assert.assertEquals(Collections.singletonList("meta::pure::metamodel::type::Any"), resultClass.superTypes.stream().map(x -> x.path).collect(Collectors.toList())); Assert.assertEquals(Collections.emptyList(), resultClass.properties); Optional nothing = this.converter.fromEntityIfPossible(Entity.newEntity("note::a::real::PureEntity", "meta::unknown::NotAClassifier", Collections.emptyMap())); diff --git a/legend-sdlc-protocol-pure/src/test/java/org/finos/legend/sdlc/protocol/pure/v1/TestPureToEntityConverter.java b/legend-sdlc-protocol-pure/src/test/java/org/finos/legend/sdlc/protocol/pure/v1/TestPureToEntityConverter.java index 2a79b40cda..aea07595c8 100644 --- a/legend-sdlc-protocol-pure/src/test/java/org/finos/legend/sdlc/protocol/pure/v1/TestPureToEntityConverter.java +++ b/legend-sdlc-protocol-pure/src/test/java/org/finos/legend/sdlc/protocol/pure/v1/TestPureToEntityConverter.java @@ -14,6 +14,7 @@ package org.finos.legend.sdlc.protocol.pure.v1; +import org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer; import org.finos.legend.sdlc.domain.model.entity.Entity; import org.junit.Assert; import org.junit.Test; @@ -31,7 +32,7 @@ public class TestPureToEntityConverter public void testToEntity() { Class cls = new Class(); - cls.superTypes = Collections.singletonList("meta::pure::metamodel::type::Any"); + cls.superTypes = Collections.singletonList(new PackageableElementPointer("meta::pure::metamodel::type::Any")); cls.name = "EmptyClass"; cls._package = "model::test"; Entity entity = this.converter.toEntity(cls); @@ -42,7 +43,7 @@ public void testToEntity() public void testToEntityIfPossible() { Class cls = new Class(); - cls.superTypes = Collections.singletonList("meta::pure::metamodel::type::Any"); + cls.superTypes = Collections.singletonList(new PackageableElementPointer("meta::pure::metamodel::type::Any")); cls.name = "EmptyClass"; cls._package = "model::test"; Optional entity = this.converter.toEntityIfPossible(cls); diff --git a/legend-sdlc-protocol/src/test/java/org/finos/legend/sdlc/protocol/TestEntityToProtocolConverter.java b/legend-sdlc-protocol/src/test/java/org/finos/legend/sdlc/protocol/TestEntityToProtocolConverter.java index cc1e12527c..b757aa8610 100644 --- a/legend-sdlc-protocol/src/test/java/org/finos/legend/sdlc/protocol/TestEntityToProtocolConverter.java +++ b/legend-sdlc-protocol/src/test/java/org/finos/legend/sdlc/protocol/TestEntityToProtocolConverter.java @@ -14,6 +14,7 @@ package org.finos.legend.sdlc.protocol; +import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; import org.finos.legend.sdlc.domain.model.TestTools; @@ -76,7 +77,7 @@ private static void assertClassEqualsEntity(Entity entity, Class cls) Assert.assertEquals(CLASS_CLASSIFIER_PATH, entity.getClassifierPath()); Assert.assertEquals(entity.getContent().get("name"), cls.name); Assert.assertEquals(entity.getContent().get("package"), cls._package); - Assert.assertEquals(entity.getContent().get("superTypes"), cls.superTypes); + Assert.assertEquals(entity.getContent().get("superTypes"), cls.superTypes.stream().map(x -> x.path).collect(Collectors.toList())); Assert.assertEquals(((Collection) entity.getContent().get("properties")).stream().map(m -> ((Map) m).get("name")).collect(Collectors.toList()), cls.properties.stream().map(p -> p.name).collect(Collectors.toList())); } diff --git a/legend-sdlc-protocol/src/test/java/org/finos/legend/sdlc/protocol/TestProtocolToEntityConverter.java b/legend-sdlc-protocol/src/test/java/org/finos/legend/sdlc/protocol/TestProtocolToEntityConverter.java index 83f46c9f10..8973eabe1d 100644 --- a/legend-sdlc-protocol/src/test/java/org/finos/legend/sdlc/protocol/TestProtocolToEntityConverter.java +++ b/legend-sdlc-protocol/src/test/java/org/finos/legend/sdlc/protocol/TestProtocolToEntityConverter.java @@ -15,7 +15,9 @@ package org.finos.legend.sdlc.protocol; import com.fasterxml.jackson.databind.json.JsonMapper; +import java.util.stream.Collectors; import org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory; +import org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; @@ -35,7 +37,7 @@ public void testToEntity() { PermissiveClassToEntityConverter converter = new PermissiveClassToEntityConverter(); Class cls = new Class(); - cls.superTypes = Collections.singletonList("meta::pure::metamodel::type::Any"); + cls.superTypes = Collections.singletonList(new PackageableElementPointer("meta::pure::metamodel::type::Any")); cls.name = "EmptyClass"; cls._package = "model::test"; Entity entity = converter.toEntity(cls); @@ -57,7 +59,7 @@ public void testToEntityIfPossible() { PermissiveClassToEntityConverter converter = new PermissiveClassToEntityConverter(); Class cls = new Class(); - cls.superTypes = Collections.singletonList("meta::pure::metamodel::type::Any"); + cls.superTypes = Collections.singletonList(new PackageableElementPointer("meta::pure::metamodel::type::Any")); cls.name = "EmptyClass"; cls._package = "model::test"; Optional entity = converter.toEntityIfPossible(cls); @@ -98,7 +100,7 @@ public static void assertEntityEqualsClass(org.finos.legend.engine.protocol.pure Assert.assertEquals(cls.name, entity.getContent().get("name")); Assert.assertEquals(cls._package, entity.getContent().get("package")); Assert.assertEquals(cls.properties, entity.getContent().get("properties")); - Assert.assertEquals(cls.superTypes, entity.getContent().get("superTypes")); + Assert.assertEquals(cls.superTypes.stream().map(x -> x.path).collect(Collectors.toList()), entity.getContent().get("superTypes")); } } diff --git a/pom.xml b/pom.xml index 78b5799ad4..34679e7e70 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ [11,12),[17,18),[21,22) - 4.47.1 + 4.47.2 5.8.1 0.25.4