All Downloads are FREE. Search and download functionalities are using the official Maven repository.

core_servicestore.tests.testRouting.pure Maven / Gradle / Ivy

The newest version!
// 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.

import meta::pure::graphFetch::execution::*;
import meta::external::store::service::extension::*;

import meta::external::store::service::tests::domain::*;
import meta::external::store::service::tests::mapping::*;
import meta::external::store::service::tests::runtime::*;
import meta::external::store::service::tests::router::*;

function meta::external::store::service::tests::router::serviceStoreTestExtensions():meta::pure::extension::Extension[*]
{
  meta::pure::extension::defaultExtensions()->concatenate(serviceStoreExtensions())
}

function <> meta::external::store::service::tests::router::testServiceStoreRoutingSimple():Boolean[1]
{
   let tree = #{
      S_Trade {
         s_tradeId,
         s_traderDetails,
         s_tradeDetails
      }
   }#;
   
   let query  = {|S_Trade.all()->graphFetch($tree)->serialize($tree)};
   let routed = $query->routeFunction(serviceStoreMapping(), serviceStoreRuntime(), ^meta::pure::runtime::ExecutionContext(), serviceStoreTestExtensions(), noDebug());
   assertEquals(' | {Platform> [strategy_wrapper /{meta::external::store::service::tests::store::TradeProductServiceStore> [1 s_trade_set/[1 s_trade_set/[1 s_trade_set/Class S_Trade].all()] -> graphFetch({meta::external::store::service::tests::store::TradeProductServiceStore> [s_trade_set / meta::external::store::service::tests::domain::S_Trade] {@(s_trade_set->)@ [ / s_tradeId], @(s_trade_set->)@ [ / s_traderDetails], @(s_trade_set->)@ [ / s_tradeDetails]}})]} -> serialize(#{meta::external::store::service::tests::domain::S_Trade {s_tradeId, s_traderDetails, s_tradeDetails}}#)]};', $routed->meta::pure::router::printer::asString());
}

function <> meta::external::store::service::tests::router::testServiceStoreRoutingWithFilter():Boolean[1]
{
   let tree  = #{
      S_Product {
         s_productId,
         s_productName,
         s_description
      }
   }#;
   
   let query  = {|S_Product.all()->filter(p | $p.s_productId == 'xyz')->graphFetch($tree)->serialize($tree)};
   let routed = $query->routeFunction(serviceStoreMapping(), serviceStoreRuntime(), ^meta::pure::runtime::ExecutionContext(), serviceStoreTestExtensions(), noDebug());
   assertEquals(' | {Platform> [strategy_wrapper /{meta::external::store::service::tests::store::TradeProductServiceStore> [1 s_prod_set/[1 s_prod_set/[1 s_prod_set/[1 s_prod_set/Class S_Product].all()] -> filter([Routed Func:p:meta::external::store::service::tests::domain::S_Product[1] | [1 @s_productId(s_prod_set->)@ s_prod_set/[1 s_prod_set/$p].s_productId] == \'xyz\';])] -> graphFetch({meta::external::store::service::tests::store::TradeProductServiceStore> [s_prod_set / meta::external::store::service::tests::domain::S_Product] {@(s_prod_set->)@ [ / s_productId], @(s_prod_set->)@ [ / s_productName], @(s_prod_set->)@ [ / s_description]}})]} -> serialize(#{meta::external::store::service::tests::domain::S_Product {s_productId, s_productName, s_description}}#)]};', $routed->meta::pure::router::printer::asString());
}

function <> meta::external::store::service::tests::router::testServiceStoreRoutingWithAndFilter():Boolean[1]
{
   let tree  = #{
      S_Product {
         s_productId,
         s_productName,
         s_description
      }
   }#;
   
   let query  = {|S_Product.all()->filter(p | $p.s_productId == 'xyz' && $p.s_productName == 'dummy')->graphFetch($tree)->serialize($tree)};
   let routed = $query->routeFunction(serviceStoreMapping(), serviceStoreRuntime(), ^meta::pure::runtime::ExecutionContext(), serviceStoreTestExtensions(), noDebug());
   assertEquals(' | {Platform> [strategy_wrapper /{meta::external::store::service::tests::store::TradeProductServiceStore> [1 s_prod_set/[1 s_prod_set/[1 s_prod_set/[1 s_prod_set/Class S_Product].all()] -> filter([Routed Func:p:meta::external::store::service::tests::domain::S_Product[1] | [1 @s_productId(s_prod_set->)@ s_prod_set/[1 s_prod_set/$p].s_productId] == \'xyz\' -> and([1 @s_productName(s_prod_set->)@ s_prod_set/[1 s_prod_set/$p].s_productName] == \'dummy\');])] -> graphFetch({meta::external::store::service::tests::store::TradeProductServiceStore> [s_prod_set / meta::external::store::service::tests::domain::S_Product] {@(s_prod_set->)@ [ / s_productId], @(s_prod_set->)@ [ / s_productName], @(s_prod_set->)@ [ / s_description]}})]} -> serialize(#{meta::external::store::service::tests::domain::S_Product {s_productId, s_productName, s_description}}#)]};', $routed->meta::pure::router::printer::asString());
}

function <> meta::external::store::service::tests::router::testServiceStoreRoutingWithFilterOnParam():Boolean[1]
{
   let tree  = #{
      S_Product {
         s_productId,
         s_productName,
         s_description
      }
   }#;
   
   let query  = {id:String[1]|S_Product.all()->filter(p | $p.s_productId == $id)->graphFetch($tree)->serialize($tree)};
   let routed = $query->routeFunction(serviceStoreMapping(), serviceStoreRuntime(), ^meta::pure::runtime::ExecutionContext(), serviceStoreTestExtensions(), noDebug());
   assertEquals('id:String[1] | {Platform> [strategy_wrapper /{meta::external::store::service::tests::store::TradeProductServiceStore> [1 s_prod_set/[1 s_prod_set/[1 s_prod_set/[1 s_prod_set/Class S_Product].all()] -> filter([Routed Func:p:meta::external::store::service::tests::domain::S_Product[1] | [1 @s_productId(s_prod_set->)@ s_prod_set/[1 s_prod_set/$p].s_productId] == $id;])] -> graphFetch({meta::external::store::service::tests::store::TradeProductServiceStore> [s_prod_set / meta::external::store::service::tests::domain::S_Product] {@(s_prod_set->)@ [ / s_productId], @(s_prod_set->)@ [ / s_productName], @(s_prod_set->)@ [ / s_description]}})]} -> serialize(#{meta::external::store::service::tests::domain::S_Product {s_productId, s_productName, s_description}}#)]};', $routed->meta::pure::router::printer::asString());
}

function <> meta::external::store::service::tests::router::testServiceStoreRoutingWithComplexProperty():Boolean[1]
{
   let tree  = #{
      S_Product {
         s_productId,
         s_productName,
         s_description,
         s_synonyms{
            s_type,
            s_name
         }
      }
   }#;
   
   let query  = {|S_Product.all()->graphFetch($tree)->serialize($tree)};
   let routed = $query->routeFunction(serviceStoreMapping(), serviceStoreRuntime(), ^meta::pure::runtime::ExecutionContext(), serviceStoreTestExtensions(), noDebug());
   assertEquals(' | {Platform> [strategy_wrapper /{meta::external::store::service::tests::store::TradeProductServiceStore> [1 s_prod_set/[1 s_prod_set/[1 s_prod_set/Class S_Product].all()] -> graphFetch({meta::external::store::service::tests::store::TradeProductServiceStore> [s_prod_set / meta::external::store::service::tests::domain::S_Product] {@(s_prod_set->)@ [ / s_productId], @(s_prod_set->)@ [ / s_productName], @(s_prod_set->)@ [ / s_description], @(s_prod_set->s_synonym_set)@ [s_synonym_set / s_synonyms] {@(s_synonyms->)@ [ / s_type], @(s_synonyms->)@ [ / s_name]}}})]} -> serialize(#{meta::external::store::service::tests::domain::S_Product {s_productId, s_productName, s_description, s_synonyms {s_type, s_name}}}#)]};', $routed->meta::pure::router::printer::asString());
}

function <> meta::external::store::service::tests::router::testServiceStoreRoutingWithCrossStore():Boolean[1]
{
   let tree = #{
         S_Trade{
            s_tradeId,
            s_traderDetails,
            s_tradeDetails,
            s_product{
               s_productId,
               s_productName,
               s_description,
               s_synonyms{
                  s_name,
                  s_type
               }
            }
         }
      }#;
   
   let query  = {|S_Trade.all()->graphFetch($tree)->serialize($tree)};
   let routed = $query->routeFunction(serviceStoreMapping(), serviceStoreRuntime(), ^meta::pure::runtime::ExecutionContext(), serviceStoreTestExtensions(), noDebug());
   assertEquals(' | {Platform> [strategy_wrapper /{meta::external::store::service::tests::store::TradeProductServiceStore> [1 s_trade_set/[1 s_trade_set/[1 s_trade_set/Class S_Trade].all()] -> graphFetch({meta::external::store::service::tests::store::TradeProductServiceStore> [s_trade_set / meta::external::store::service::tests::domain::S_Trade] {@(s_trade_set->)@ [ / s_tradeId], @(s_trade_set->)@ [ / s_traderDetails], {meta::external::store::service::tests::store::TradeProductServiceStore> @(s_trade_set->s_prod_set)@ [s_prod_set / s_product] {@(s_prod_set->)@ [ / s_productId], @(s_prod_set->)@ [ / s_productName], @(s_prod_set->)@ [ / s_description], @(s_prod_set->s_synonym_set)@ [s_synonym_set / s_synonyms] {@(s_synonyms->)@ [ / s_name], @(s_synonyms->)@ [ / s_type]}, @(s_prod_set->)@ [ / s_tradeId]}}, @(s_trade_set->)@ [ / s_tradeDetails]}})]} -> serialize(#{meta::external::store::service::tests::domain::S_Trade {s_tradeId, s_traderDetails, s_tradeDetails, s_product {s_productId, s_productName, s_description, s_synonyms {s_name, s_type}}}}#)]};', $routed->meta::pure::router::printer::asString());
}

function <> meta::external::store::service::tests::router::testServiceStoreRoutingWithToOne():Boolean[1]
{
   let tree = #{
      S_Trade {
         s_tradeId,
         s_traderDetails,
         s_tradeDetails
      }
   }#;
   
   let query  = {|S_Trade.all()->toOne()->graphFetch($tree)->serialize($tree)};
   let routed = $query->routeFunction(serviceStoreMapping(), serviceStoreRuntime(), ^meta::pure::runtime::ExecutionContext(), serviceStoreTestExtensions(), noDebug());
   assertEquals(' | {Platform> [strategy_wrapper /{meta::external::store::service::tests::store::TradeProductServiceStore> [1 s_trade_set/[1 s_trade_set/[1 s_trade_set/[1 s_trade_set/Class S_Trade].all()] -> toOne()] -> graphFetch({meta::external::store::service::tests::store::TradeProductServiceStore> [s_trade_set / meta::external::store::service::tests::domain::S_Trade] {@(s_trade_set->)@ [ / s_tradeId], @(s_trade_set->)@ [ / s_traderDetails], @(s_trade_set->)@ [ / s_tradeDetails]}})]} -> serialize(#{meta::external::store::service::tests::domain::S_Trade {s_tradeId, s_traderDetails, s_tradeDetails}}#)]};', $routed->meta::pure::router::printer::asString());
}

function <> meta::external::store::service::tests::router::testServiceStoreRoutingWithTake():Boolean[1]
{
   let tree = #{
      S_Trade {
         s_tradeId,
         s_traderDetails,
         s_tradeDetails
      }
   }#;

   let query  = {|S_Trade.all()->take(10)->graphFetch($tree)->serialize($tree)};
   let routed = $query->routeFunction(serviceStoreMapping(), serviceStoreRuntime(), ^meta::pure::runtime::ExecutionContext(), serviceStoreTestExtensions(), noDebug());
   assertEquals(' | {Platform> [strategy_wrapper /{meta::external::store::service::tests::store::TradeProductServiceStore> [1 s_trade_set/[1 s_trade_set/[1 s_trade_set/[1 s_trade_set/Class S_Trade].all()] -> take(10)] -> graphFetch({meta::external::store::service::tests::store::TradeProductServiceStore> [s_trade_set / meta::external::store::service::tests::domain::S_Trade] {@(s_trade_set->)@ [ / s_tradeId], @(s_trade_set->)@ [ / s_traderDetails], @(s_trade_set->)@ [ / s_tradeDetails]}})]} -> serialize(#{meta::external::store::service::tests::domain::S_Trade {s_tradeId, s_traderDetails, s_tradeDetails}}#)]};', $routed->meta::pure::router::printer::asString());
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy