Skip to content

Commit

Permalink
Add tests for DSL Graph (finos#890)
Browse files Browse the repository at this point in the history
* Add tests for DSL Graph

* Delete stray file

* generate test par on test-compile
  • Loading branch information
aziemchawdhary-gs authored Nov 19, 2024
1 parent b88d5f0 commit 1be8c1e
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,44 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-maven-generation-par</artifactId>
<configuration>
<sourceDirectory>${project.basedir}/src/test/resources</sourceDirectory>
<purePlatformVersion>${project.version}</purePlatformVersion>
<extraRepositories>
<extraRepository>${project.basedir}/src/test/resources/platform_dsl_graph_test.definition.json
</extraRepository>
</extraRepositories>
</configuration>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>build-pure-jar</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-m3-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-m2-dsl-graph-pure</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-m2-dsl-graph-grammar</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
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.m2.inlinedsl.graph;

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 GraphCodeTestRepositoryProvider implements CodeRepositoryProvider
{
@Override
public CodeRepository repository()
{
return GenericCodeRepository.build("platform_dsl_graph_test.definition.json");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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.m2.inlinedsl.graph;

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

public class TestGraphDSLTestCodeIntegrity extends AbstractCompiledStateIntegrityTest
{
@BeforeClass
public static void initialize()
{
initialize("platform_dsl_graph_test");
}

@Test
@Ignore
@Override
public void testReferenceUsages()
{
super.testReferenceUsages();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.finos.legend.pure.m2.inlinedsl.graph.GraphCodeTestRepositoryProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "platform_dsl_graph_test",
"pattern": "(meta::pure::graphFetch|meta::pure::functions::meta)(::.*)?",
"dependencies": [
"platform",
"platform_dsl_graph"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import meta::pure::graphFetch::test::*;

Class meta::pure::graphFetch::test::A
{
a : String[1];
}

function meta::pure::graphFetch::test::simpleFetchTree():Any[*]
{
print(#{meta::pure::graphFetch::test::A{a}}#, 2);
}

Class meta::pure::graphFetch::test::Person
{
firstName: String[1];
lastName: String[1];
address: Address[1];

nameWithTitle(title:String[1])
{
$title + ' ' + $this.firstName + ' ' + $this.lastName + ' ';
} : String[1];

nameWithPrefixAndSuffix(prefix:String[0..1], suffixes:String[*])
{
if($prefix->isEmpty(),
| if($suffixes->isEmpty(),
| $this.firstName + ' ' + $this.lastName,
| $this.firstName + ' ' + $this.lastName + ', ' + $suffixes->joinStrings(', ')),
| if($suffixes->isEmpty(),
| $prefix->toOne() + ' ' + $this.firstName + ' ' + $this.lastName,
| $prefix->toOne() + ' ' + $this.firstName + ' ' + $this.lastName + ', ' + $suffixes->joinStrings(', ')))
}:String[1];
}

Class meta::pure::graphFetch::test::Address
{
}

Class meta::pure::graphFetch::test::PersonAddress extends Address
{
}

Class meta::pure::graphFetch::test::FirmAddress extends Address
{
}

Class meta::pure::graphFetch::test::Firm
{
a: Address[1];
employees: Person[*];
}

function meta::pure::graphFetch::test::subTypeInTree():Any[*]
{
print(#{Firm{employees{address->subType(@PersonAddress)}}}#, 2);
}

function meta::pure::graphFetch::test::graphPropertyParameter():Any[*]
{
print(#{Person { nameWithTitle('Ms')}}#, 2);
}

0 comments on commit 1be8c1e

Please sign in to comment.