@Test public void shouldReturnTransformedTableOnExecute() throws Exception { Table expected = createTable(); when(tableGigaSpace.read(new Table())).thenReturn(expected); TableSummary tableSummary = underTest.execute(); assertEquals(expected.summarise(gameRules), tableSummary); }
@Test(expected = UnsupportedOperationException.class) public void shouldThrowExceptionIfReturnedAsResult() throws Exception { final Table aTable = createTable(); List<AsyncResult<TableSummary>> results = new ArrayList<AsyncResult<TableSummary>>(); results.add( new AsyncResult<TableSummary>() { @Override public TableSummary getResult() { return aTable.summarise(gameRules); } @Override public Exception getException() { return new UnsupportedOperationException(); } }); underTest.reduce(results); }
@Test public void shouldReturnMergedResults() throws Exception { final Table aTable = createTable(); List<AsyncResult<TableSummary>> taskResults = new ArrayList<AsyncResult<TableSummary>>(); final TableSummary expected = aTable.summarise(gameRules); taskResults.add( new AsyncResult<TableSummary>() { @Override public TableSummary getResult() { return expected; } @Override public Exception getException() { return null; } }); TableSummary result = underTest.reduce(taskResults); assertEquals(expected, result); }