/** Tests the basic insert step. */
 @Test
 public void testHandle() {
   display.setProjectId(ID2);
   final BaseResult result = mock(BaseResult.class);
   when(result.getSourceName()).thenReturn(TEST_SOURCE_NAME);
   when(calcDao.findCalculationId(ID2, TEST_SOURCE_NAME)).thenReturn(null);
   when(calcDao.insertCalculation(eq(ID2), eq(TEST_SOURCE_NAME), anyListOf(Long.class)))
       .thenReturn(ID);
   display.write(null, result);
   verify(calcDao).insertSummary(ID, result);
 }
 /** Tests init plus insert. */
 @SuppressWarnings({"unchecked", "rawtypes"})
 @Test
 public void testSetupHandle() {
   final List<String> catNames = Arrays.asList(CAT1, CAT2);
   when(calcDao.findCategories(catNames))
       .thenReturn(
           (List)
               Arrays.asList(
                   new DefaultCalculationCategory(CAT1, CAT_ID1),
                   new DefaultCalculationCategory(CAT2, CAT_ID2)));
   when(calcDao.findProjectId(TEST_PROJ_NAME)).thenReturn(ID2);
   display.setProjectConfig(TEST_PROJ_NAME, catNames);
   final BaseResult result = mock(BaseResult.class);
   when(result.getSourceName()).thenReturn(TEST_SOURCE_NAME);
   when(calcDao.findCalculationId(ID2, TEST_SOURCE_NAME)).thenReturn(null);
   when(calcDao.insertCalculation(
           eq(ID2), eq(TEST_SOURCE_NAME), (Collection<Long>) argThat(hasItems(CAT_ID1, CAT_ID2))))
       .thenReturn(ID);
   display.write(null, result);
   display.finish(null);
   verify(calcDao).insertSummary(ID, result);
 }