From 6799b32fed774e7b72f19de1b6872cfc2e29c76e Mon Sep 17 00:00:00 2001 From: Aziem Chawdhary Date: Thu, 14 Nov 2024 19:50:39 +0000 Subject: [PATCH] Add milestoning repository test --- legend-pure-core/legend-pure-m3-core/pom.xml | 27 +++++++++++++++++ .../TestGenericRepository.java | 6 ++-- .../TestMilestoningRepositoryProvider.java | 29 +++++++++++++++++++ ...lesystem.repository.CodeRepositoryProvider | 3 +- .../testMilestoningRepository.definition.json | 5 ++++ .../testMilestoning.pure | 14 +++++++++ 6 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/filesystem/genericrepository/config/TestMilestoningRepositoryProvider.java create mode 100644 legend-pure-core/legend-pure-m3-core/src/test/resources/testMilestoningRepository.definition.json create mode 100644 legend-pure-core/legend-pure-m3-core/src/test/resources/testMilestoningRepository/testMilestoning.pure diff --git a/legend-pure-core/legend-pure-m3-core/pom.xml b/legend-pure-core/legend-pure-m3-core/pom.xml index a2aceb6e5f..17788956b4 100644 --- a/legend-pure-core/legend-pure-m3-core/pom.xml +++ b/legend-pure-core/legend-pure-m3-core/pom.xml @@ -205,6 +205,33 @@ + + org.finos.legend.pure + legend-pure-maven-generation-par + + ${project.basedir}/src/test/resources + ${project.version} + + + + + + + + test-compile + + build-pure-jar + + + + + + org.finos.legend.pure + legend-pure-m3-core + ${project.version} + + + org.apache.maven.plugins maven-jar-plugin diff --git a/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/filesystem/genericrepository/TestGenericRepository.java b/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/filesystem/genericrepository/TestGenericRepository.java index f93b9256fe..a4946cf386 100644 --- a/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/filesystem/genericrepository/TestGenericRepository.java +++ b/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/filesystem/genericrepository/TestGenericRepository.java @@ -32,9 +32,9 @@ public class TestGenericRepository public void testRepositoryDetection() { RichIterable repositoryList = CodeRepositoryProviderHelper.findCodeRepositories(); - Assert.assertEquals(3, repositoryList.size()); + Assert.assertEquals(4, repositoryList.size()); Verify.assertAllSatisfy(repositoryList, r -> r instanceof GenericCodeRepository); - Verify.assertSetsEqual(Sets.mutable.with("platform", "test_generic_repository", "other_test_generic_repository"), repositoryList.collect(CodeRepository::getName).toSet()); + Verify.assertSetsEqual(Sets.mutable.with("platform", "test_generic_repository", "other_test_generic_repository", "test_milestoning_repository"), repositoryList.collect(CodeRepository::getName).toSet()); } @Test @@ -52,7 +52,7 @@ public void testBuildCodeStorage() throws Exception { RichIterable repositoryList = CodeRepositoryProviderHelper.findCodeRepositories(); CompositeCodeStorage codeStorage = new CompositeCodeStorage(new ClassLoaderCodeStorage(repositoryList)); - Verify.assertSetsEqual(Sets.mutable.with("platform", "test_generic_repository", "other_test_generic_repository"), codeStorage.getAllRepositories().collect(CodeRepository::getName).toSet()); + Verify.assertSetsEqual(Sets.mutable.with("platform", "test_generic_repository", "other_test_generic_repository", "test_milestoning_repository"), codeStorage.getAllRepositories().collect(CodeRepository::getName).toSet()); Verify.assertSetsEqual(Sets.mutable.with("/test_generic_repository/testBla.pure", "/other_test_generic_repository/test.pure"), codeStorage.getUserFiles().toSet().select(c -> !c.startsWith("/platform"))); } } diff --git a/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/filesystem/genericrepository/config/TestMilestoningRepositoryProvider.java b/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/filesystem/genericrepository/config/TestMilestoningRepositoryProvider.java new file mode 100644 index 0000000000..f96ce58478 --- /dev/null +++ b/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/filesystem/genericrepository/config/TestMilestoningRepositoryProvider.java @@ -0,0 +1,29 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config; + +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepository; +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider; +import org.finos.legend.pure.m3.serialization.filesystem.repository.GenericCodeRepository; + +public class TestMilestoningRepositoryProvider implements CodeRepositoryProvider +{ + + @Override + public CodeRepository repository() + { + return GenericCodeRepository.build("testMilestoningRepository.definition.json"); + } +} diff --git a/legend-pure-core/legend-pure-m3-core/src/test/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider b/legend-pure-core/legend-pure-m3-core/src/test/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider index d7d3c9e831..57ce6cc29f 100644 --- a/legend-pure-core/legend-pure-m3-core/src/test/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider +++ b/legend-pure-core/legend-pure-m3-core/src/test/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider @@ -1,2 +1,3 @@ org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config.TestGenericRepositoryProvider -org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config.TestOtherGenericRepositoryProvider \ No newline at end of file +org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config.TestOtherGenericRepositoryProvider +org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config.TestMilestoningRepositoryProvider \ No newline at end of file diff --git a/legend-pure-core/legend-pure-m3-core/src/test/resources/testMilestoningRepository.definition.json b/legend-pure-core/legend-pure-m3-core/src/test/resources/testMilestoningRepository.definition.json new file mode 100644 index 0000000000..9e4e3e320b --- /dev/null +++ b/legend-pure-core/legend-pure-m3-core/src/test/resources/testMilestoningRepository.definition.json @@ -0,0 +1,5 @@ +{ + "name" : "test_milestoning_repository", + "pattern" : "(meta)(::.*)?", + "dependencies" : ["platform"] +} diff --git a/legend-pure-core/legend-pure-m3-core/src/test/resources/testMilestoningRepository/testMilestoning.pure b/legend-pure-core/legend-pure-m3-core/src/test/resources/testMilestoningRepository/testMilestoning.pure new file mode 100644 index 0000000000..22c00aed22 --- /dev/null +++ b/legend-pure-core/legend-pure-m3-core/src/test/resources/testMilestoningRepository/testMilestoning.pure @@ -0,0 +1,14 @@ +// Copyright 2021 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +