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

Add test milestone repository and integrity test #893

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
@@ -0,0 +1,28 @@
// 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;

import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest;
import org.junit.BeforeClass;

public class TestMilestoningCompileStateIntegrityTest extends AbstractCompiledStateIntegrityTest
{
@BeforeClass
public static void initialize()
{
initialize("test_milestoning_repository");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public class TestGenericRepository
public void testRepositoryDetection()
{
RichIterable<CodeRepository> 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
Expand All @@ -52,7 +52,7 @@ public void testBuildCodeStorage() throws Exception
{
RichIterable<CodeRepository> 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")));
}
}
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config.TestGenericRepositoryProvider
org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config.TestOtherGenericRepositoryProvider
org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config.TestOtherGenericRepositoryProvider
org.finos.legend.pure.m3.serialization.filesystem.genericrepository.config.TestMilestoningRepositoryProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "test_milestoning_repository",
"pattern" : "(meta)(::.*)?",
"dependencies" : ["platform"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2021 Goldman Sachs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2021 Goldman Sachs
// 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.

Class <<temporal.businesstemporal>> meta::test::milestoning::A
{
a : String[1];
}

Class <<temporal.processingtemporal>> meta::test::milestoning::B
{
b : String[1];
}

Comment on lines +15 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Class <<temporal.businesstemporal>> meta::test::milestoning::A
{
a : String[1];
}
Class <<temporal.processingtemporal>> meta::test::milestoning::B
{
b : String[1];
}
Class <<temporal.businesstemporal>> meta::test::milestoning::A
{
a : String[1];
}
Class <<temporal.processingtemporal>> meta::test::milestoning::B
{
b : String[1];
}

Class <<temporal.businesstemporal>> meta::test::milestoning::Account
{
}

Class <<temporal.businesstemporal>> meta::test::milestoning::FirmAccount extends meta::test::milestoning::Account
{
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also have a bitemporal class and a non-milestoned class, and connections between each type. Also, properties from associations.

function meta::test::testSubClassOfBusinessTemporal():Any[*]
{
let res = ^meta::test::milestoning::FirmAccount(businessDate=%2021);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.collections.api.factory.Sets;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.set.ImmutableSet;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.impl.utility.ArrayIterate;
import org.finos.legend.pure.m3.exception.PureAssertFailException;
Expand Down Expand Up @@ -56,6 +57,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Objects;
import java.util.Set;

import static org.finos.legend.pure.m3.pct.shared.PCTTools.isPCTTest;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -189,7 +191,8 @@ public static CompiledExecutionSupport getClassLoaderExecutionSupport()

public static CompiledExecutionSupport getClassLoaderExecutionSupport(ClassLoader classLoader)
{
RichIterable<CodeRepository> codeRepos = CodeRepositoryProviderHelper.findCodeRepositories().select(r -> !r.getName().equals("test_generic_repository") && !r.getName().equals("other_test_generic_repository"));
ImmutableSet<String> testRepos = Sets.immutable.of("test_generic_repository", "other_test_generic_repository", "test_milestoning_repository");
RichIterable<CodeRepository> codeRepos = CodeRepositoryProviderHelper.findCodeRepositories().select(r -> !testRepos.contains(r.getName()));
return new CompiledExecutionSupport(
new JavaCompilerState(null, classLoader),
new CompiledProcessorSupport(classLoader, MetadataLazy.fromClassLoader(classLoader, codeRepos.collect(CodeRepository::getName)), Sets.mutable.empty()),
Expand Down
Loading