//-------------------------------------------------------------------------
        // Test that ScenarioArrays containing a single value are unwrapped.
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void unwrapScenarioResults() throws Exception
        public virtual void unwrapScenarioResults()
        {
            ScenarioArray <string> scenarioResult = ScenarioArray.of("foo");
            ScenarioResultFunction fn             = new ScenarioResultFunction(TestingMeasures.PRESENT_VALUE, scenarioResult);
            CalculationTaskCell    cell           = CalculationTaskCell.of(0, 0, TestingMeasures.PRESENT_VALUE, NATURAL);
            CalculationTask        task           = CalculationTask.of(TARGET, fn, cell);
            Column           column = Column.of(TestingMeasures.PRESENT_VALUE);
            CalculationTasks tasks  = CalculationTasks.of(ImmutableList.of(task), ImmutableList.of(column));

            // using the direct executor means there is no need to close/shutdown the runner
            CalculationTaskRunner test = CalculationTaskRunner.of(MoreExecutors.newDirectExecutorService());

            MarketData marketData = MarketData.empty(VAL_DATE);
            Results    results1   = test.calculate(tasks, marketData, REF_DATA);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.collect.result.Result<?> result1 = results1.get(0, 0);
            Result <object> result1 = results1.get(0, 0);

            // Check the result contains the string directly, not the result wrapping the string
            assertThat(result1).hasValue("foo");

            Results results2 = test.calculateMultiScenario(tasks, ScenarioMarketData.of(1, marketData), REF_DATA);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.collect.result.Result<?> result2 = results2.get(0, 0);
            Result <object> result2 = results2.get(0, 0);

            // Check the result contains the scenario result wrapping the string
            assertThat(result2).hasValue(scenarioResult);

            ResultsListener resultsListener = new ResultsListener();

            test.calculateAsync(tasks, marketData, REF_DATA, resultsListener);
            CompletableFuture <Results> future = resultsListener.Future;

            // The future is guaranteed to be done because everything is running on a single thread
            assertThat(future.Done).True;
            Results results3 = future.get();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.collect.result.Result<?> result3 = results3.get(0, 0);
            Result <object> result3 = results3.get(0, 0);

            // Check the result contains the string directly, not the result wrapping the string
            assertThat(result3).hasValue("foo");
        }
예제 #2
0
        //-------------------------------------------------------------------------
        public virtual Results calculateMultiScenario <T1>(CalculationRules calculationRules, IList <T1> targets, IList <Column> columns, ScenarioMarketData marketData, ReferenceData refData) where T1 : com.opengamma.strata.basics.CalculationTarget
        {
            CalculationTasks tasks = CalculationTasks.of(calculationRules, targets, columns, refData);

            return(taskRunner.calculateMultiScenario(tasks, marketData, refData));
        }