/// <summary> /// Test two derived function composed together /// </summary> public virtual void calculateMeasuresNestedDerivedClasses() { TestTarget target = new TestTarget(10); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(CASH_FLOWS, com.opengamma.strata.collect.result.Result.success(3), PAR_RATE, com.opengamma.strata.collect.result.Result.success(5), PRESENT_VALUE, com.opengamma.strata.collect.result.Result.success(7)); IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5), PRESENT_VALUE, Result.success(7)); DerivedFn derivedFn1 = new DerivedFn(BUCKETED_PV01); DerivedFn derivedFn2 = new DerivedFn(PRESENT_VALUE_MULTI_CCY); DerivedCalculationFunctionWrapper <TestTarget, int> wrapper = new DerivedCalculationFunctionWrapper <TestTarget, int>(derivedFn1, new DelegateFn(delegateResults)); wrapper = new DerivedCalculationFunctionWrapper <>(derivedFn2, wrapper); ISet <Measure> measures = ImmutableSet.of(BUCKETED_PV01, PRESENT_VALUE_MULTI_CCY, CASH_FLOWS, PAR_RATE, PRESENT_VALUE); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> results = wrapper.calculate(target, measures, CalculationParameters.empty(), com.opengamma.strata.data.scenario.ScenarioMarketData.empty(), com.opengamma.strata.basics.ReferenceData.standard()); IDictionary <Measure, Result <object> > results = wrapper.calculate(target, measures, CalculationParameters.empty(), ScenarioMarketData.empty(), ReferenceData.standard()); assertThat(wrapper.supportedMeasures()).isEqualTo(measures); assertThat(wrapper.targetType()).isEqualTo(typeof(TestTarget)); assertThat(results.Keys).isEqualTo(measures); assertThat(results[BUCKETED_PV01]).hasValue(35); assertThat(results[PRESENT_VALUE_MULTI_CCY]).hasValue(35); assertThat(results[CASH_FLOWS]).hasValue(3); assertThat(results[PAR_RATE]).hasValue(5); assertThat(results[PRESENT_VALUE]).hasValue(7); }
public virtual void oneDerivedFunction() { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(CASH_FLOWS, com.opengamma.strata.collect.result.Result.success(3), PAR_RATE, com.opengamma.strata.collect.result.Result.success(5)); IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5)); DelegateFn delegateFn = new DelegateFn(delegateResults); DerivedFn derivedFn = new DerivedFn(); CalculationFunctions calculationFunctions = CalculationFunctions.of(delegateFn); CalculationFunctions derivedFunctions = calculationFunctions.composedWith(derivedFn); TestTarget target = new TestTarget(42); //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint: //ORIGINAL LINE: CalculationFunction<? super TestTarget> function = derivedFunctions.getFunction(target); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: CalculationFunction <object> function = derivedFunctions.getFunction(target); ImmutableSet <Measure> expectedMeasures = ImmutableSet.of(BUCKETED_PV01, CASH_FLOWS, PAR_RATE); assertThat(function.supportedMeasures()).isEqualTo(expectedMeasures); }
/// <summary> /// Test that multiple derived functions for the same target type are correctly combined when one derived function /// depends on another. /// </summary> public virtual void multipleDerivedFunctionsForSameTargetTypeWithDependencyBetweenDerivedFunctions() { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(CASH_FLOWS, com.opengamma.strata.collect.result.Result.success(3), PAR_RATE, com.opengamma.strata.collect.result.Result.success(5)); IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5)); DelegateFn delegateFn = new DelegateFn(delegateResults); DerivedFn derivedFn1 = new DerivedFn(); // This depends on the measure calculated by derivedFn1 DerivedFn derivedFn2 = new DerivedFn(PRESENT_VALUE_MULTI_CCY, ImmutableSet.of(BUCKETED_PV01)); CalculationFunctions calculationFunctions = CalculationFunctions.of(delegateFn); // The derived functions must be specified in the correct order. // The function higher up the dependency chain must come second CalculationFunctions derivedFunctions = calculationFunctions.composedWith(derivedFn1, derivedFn2); TestTarget target = new TestTarget(42); //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint: //ORIGINAL LINE: CalculationFunction<? super TestTarget> function = derivedFunctions.getFunction(target); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: CalculationFunction <object> function = derivedFunctions.getFunction(target); ImmutableSet <Measure> expectedMeasures = ImmutableSet.of(BUCKETED_PV01, CASH_FLOWS, PAR_RATE, PRESENT_VALUE_MULTI_CCY); assertThat(function.supportedMeasures()).isEqualTo(expectedMeasures); }