Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate CalculationListener.calculationsStarted() #1458

Merged
merged 1 commit into from Dec 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,6 +17,7 @@

import com.opengamma.strata.basics.CalculationTarget;
import com.opengamma.strata.basics.ReferenceData;
import com.opengamma.strata.calc.Column;
import com.opengamma.strata.calc.Results;
import com.opengamma.strata.collect.ArgChecker;
import com.opengamma.strata.collect.Messages;
Expand Down Expand Up @@ -217,6 +218,11 @@ private UnwrappingListener(CalculationListener delegate) {
this.delegate = delegate;
}

@Override
public void calculationsStarted(List<CalculationTarget> targets, List<Column> columns) {
delegate.calculationsStarted(targets, columns);
}

@Override
public void resultReceived(CalculationTarget target, CalculationResult calculationResult) {
Result<?> result = calculationResult.getResult();
Expand Down
Expand Up @@ -10,11 +10,11 @@
import static com.opengamma.strata.collect.CollectProjectAssertions.assertThat;
import static com.opengamma.strata.collect.TestHelper.assertThrowsIllegalArg;
import static com.opengamma.strata.collect.TestHelper.date;
import static org.assertj.core.api.Assertions.assertThat;

import java.time.LocalDate;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

import org.testng.annotations.Test;

Expand Down Expand Up @@ -52,7 +52,7 @@ public class DefaultCalculationTaskRunnerTest {
/**
* Test that ScenarioArrays containing a single value are unwrapped.
*/
public void unwrapScenarioResults() {
public void unwrapScenarioResults() throws Exception {
ScenarioArray<String> scenarioResult = ScenarioArray.of("foo");
ScenarioResultFunction fn = new ScenarioResultFunction(TestingMeasures.PRESENT_VALUE, scenarioResult);
CalculationTaskCell cell = CalculationTaskCell.of(0, 0, TestingMeasures.PRESENT_VALUE, NATURAL);
Expand All @@ -73,6 +73,16 @@ public void unwrapScenarioResults() {
Result<?> 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.getFuture();
// The future is guaranteed to be done because everything is running on a single thread
assertThat(future.isDone()).isTrue();
Results results3 = future.get();
Result<?> result3 = results3.get(0, 0);
// Check the result contains the string directly, not the result wrapping the string
assertThat(result3).hasValue("foo");
}

/**
Expand Down