Skip to content

Commit

Permalink
Create nonMilestonedSourceToMilestonedTargetProperty.pure
Browse files Browse the repository at this point in the history
  • Loading branch information
PrateekGarg-gs authored Sep 14, 2023
1 parent 4c9fab1 commit 9a9014e
Showing 1 changed file with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright 2023 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.

###Pure
import meta::pure::mapping::*;
import meta::pure::milestoning::*;
import meta::pure::graphFetch::tests::m2m2r::milestoning::*;
import meta::pure::graphFetch::execution::*;
import meta::pure::alloy::connections::alloy::specification::*;
import meta::pure::alloy::connections::alloy::authentication::*;
import meta::pure::runtime::*;

//empty target property in result because source is not milestoned
function <<test.Test, test.AlloyOnly>> meta::pure::graphFetch::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::testWithHardcodedDate():Boolean[1]
{
let mapping = meta::relational::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::TargetToModelMappingWithMilestonedComplexProperty;
let runtime = getModelChainRuntime($mapping);

let query={|meta::relational::tests::milestoning::TargetProductMilestoned.all(%2023-10-15T00:00:00)->graphFetch(
#{
meta::relational::tests::milestoning::TargetProductMilestoned{
id,
name,
synonymsMilestoned(%2020-10-15T00:00:00)
{synonym}
}
}#
)->serialize(
#{
meta::relational::tests::milestoning::TargetProductMilestoned{
id,
name,
synonymsMilestoned(%2020-10-15T00:00:00)
{synonym}
}
}#
)
->meta::pure::mapping::from($mapping,$runtime)
};
let result = meta::legend::executeLegendQuery($query, [], ^meta::pure::runtime::ExecutionContext(), meta::relational::extension::relationalExtensions());
assertJsonStringsEqual('{"builder":{"_type":"json"},"values":['+
'{"id":2,"name":"ProductName2","synonymsMilestoned(2020-10-15T00:00:00+0000)":[]},'+
'{"id":3,"name":"ProductName3","synonymsMilestoned(2020-10-15T00:00:00+0000)":[]}'+
']}', $result);
}

//todo - fix source tree calc for allVersions on target
function <<test.Test, test.AlloyOnly, test.ToFix>> meta::pure::graphFetch::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::testAllVersionsQuery():Boolean[1]
{
let mapping =meta::relational::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::TargetToModelMappingWithMilestonedComplexProperty;
let runtime = getModelChainRuntime($mapping);

let query={|meta::relational::tests::milestoning::TargetProductMilestoned.all(%2023-10-15T00:00:00)->graphFetch(
#{
meta::relational::tests::milestoning::TargetProductMilestoned{
id,
name,
synonymsMilestonedAllVersions
{synonym}
}
}#
)->serialize(
#{
meta::relational::tests::milestoning::TargetProductMilestoned{
id,
name,
synonymsMilestonedAllVersions
{synonym}
}
}#
)
->meta::pure::mapping::from($mapping,$runtime)
};
let result = meta::legend::executeLegendQuery($query, [], ^meta::pure::runtime::ExecutionContext(), meta::relational::extension::relationalExtensions());
assertJsonStringsEqual('{"builder":{"_type":"json"},"values":['+
'{"id":2,"name":"ProductName2","synonymNames":["GS-Mod-S0","GS-Mod-S1","GS-Mod-S2","GS-Mod-S3"]},'+
'{"id":3,"name":"ProductName3","synonymNames":["GS-Mod-S2","GS-Mod-S3"]}'+
']}', $result);
}


###Mapping
import meta::relational::tests::*;
Mapping meta::relational::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::TargetToModelMappingWithMilestonedComplexProperty
(
include meta::relational::tests::milestoning::milestoningMapSmall

*meta::relational::tests::milestoning::TargetProductMilestoned: Pure
{
~src meta::relational::tests::milestoning::ProductMilestoned
id: $src.id,
name: $src.name,
synonymsMilestonedAllVersions: $src.synonymsNonMilestoned
}

*meta::relational::tests::milestoning::TargetProductSynonymMilestoned: Pure
{
~src meta::relational::tests::milestoning::ProductSynonymNonMilestoned
synonym: $src.synonym
}
)

0 comments on commit 9a9014e

Please sign in to comment.