DDMFormInstanceRecordXLSWriter implements DDMFormInstanceRecordWriter { protected void createRow( int rowIndex, CellStyle cellStyle, Collection<String> values, Sheet sheet) { Row row = sheet.createRow(rowIndex); int cellIndex = 0; for (String value : values) { Cell cell = row.createCell(cellIndex++, CellType.STRING); cell.setCellStyle(cellStyle); cell.setCellValue(value); } }  @Override DDMFormInstanceRecordWriterResponse write(
			DDMFormInstanceRecordWriterRequest
				ddmFormInstanceRecordWriterRequest);  }
@Test public void testCreateRow() { DDMFormInstanceRecordXLSWriter ddmFormInstanceRecordXLSWriter = new DDMFormInstanceRecordXLSWriter(); CellStyle cellStyle = mock(CellStyle.class); Sheet sheet = mock(Sheet.class); Row row = mock(Row.class); when( sheet.createRow(0) ).thenReturn( row ); Cell cell1 = mock(Cell.class); when( row.createCell(0, CellType.STRING) ).thenReturn( cell1 ); Cell cell2 = mock(Cell.class); when( row.createCell(1, CellType.STRING) ).thenReturn( cell2 ); ddmFormInstanceRecordXLSWriter.createRow( 0, cellStyle, Arrays.asList("value1", "value2"), sheet); InOrder inOrder = Mockito.inOrder(sheet, row, cell1, cell2); inOrder.verify( sheet, Mockito.times(1) ).createRow( 0 ); inOrder.verify( row, Mockito.times(1) ).createCell( 0, CellType.STRING ); inOrder.verify( cell1, Mockito.times(1) ).setCellStyle( cellStyle ); inOrder.verify( cell1, Mockito.times(1) ).setCellValue( "value1" ); inOrder.verify( row, Mockito.times(1) ).createCell( 1, CellType.STRING ); inOrder.verify( cell2, Mockito.times(1) ).setCellStyle( cellStyle ); inOrder.verify( cell2, Mockito.times(1) ).setCellValue( "value2" ); }