@Test
public void testWrite() throws Exception {

	Map<String, String> ddmFormFieldsLabel = Collections.emptyMap();
	List<Map<String, String>> ddmFormFieldValues =
		new ArrayList<Map<String, String>>() {
			{
				add(
					HashMapBuilder.put(
						"field1", "2"
					).build());
				add(
					HashMapBuilder.put(
						"field1", "1"
					).build());
			}
		};
	DDMFormInstanceRecordWriterRequest.Builder builder =
		DDMFormInstanceRecordWriterRequest.Builder.newBuilder(
			ddmFormFieldsLabel, ddmFormFieldValues);
	DDMFormInstanceRecordWriterRequest ddmFormInstanceRecordWriterRequest =
		builder.build();
	DDMFormInstanceRecordXLSWriter ddmFormInstanceRecordXLSWriter = mock(
		DDMFormInstanceRecordXLSWriter.class);
	ByteArrayOutputStream byteArrayOutputStream = mock(
		ByteArrayOutputStream.class);
	when(
		ddmFormInstanceRecordXLSWriter.createByteArrayOutputStream()
	).thenReturn(
		byteArrayOutputStream
	);
	when(
		byteArrayOutputStream.toByteArray()
	).thenReturn(
		new byte[] {1, 2, 3}
	);
	Workbook workbook = mock(Workbook.class);
	when(
		ddmFormInstanceRecordXLSWriter.createWorkbook()
	).thenReturn(
		workbook
	);
	Mockito.doNothing(
	).when(
		workbook
	).write(
		byteArrayOutputStream
	);
	when(
		ddmFormInstanceRecordXLSWriter.write(
			ddmFormInstanceRecordWriterRequest)
	).thenCallRealMethod();
	DDMFormInstanceRecordWriterResponse
		ddmFormInstanceRecordWriterResponse =
			ddmFormInstanceRecordXLSWriter.write(builder.build());
	Assert.assertArrayEquals(
		new byte[] {1, 2, 3},
		ddmFormInstanceRecordWriterResponse.getContent());
	InOrder inOrder = Mockito.inOrder(
		ddmFormInstanceRecordXLSWriter, workbook, byteArrayOutputStream);
	inOrder.verify(
		workbook, Mockito.times(1)
	).createSheet();
	inOrder.verify(
		ddmFormInstanceRecordXLSWriter, Mockito.times(1)
	).createCellStyle(
		Matchers.any(Workbook.class), Matchers.anyBoolean(),
		Matchers.anyString(), Matchers.anyByte()
	);
	inOrder.verify(
		ddmFormInstanceRecordXLSWriter, Mockito.times(1)
	).createRow(
		Matchers.anyInt(), Matchers.any(CellStyle.class),
		Matchers.anyCollection(), Matchers.any(Sheet.class)
	);
	inOrder.verify(
		ddmFormInstanceRecordXLSWriter, Mockito.times(1)
	).createCellStyle(
		Matchers.any(Workbook.class), Matchers.anyBoolean(),
		Matchers.anyString(), Matchers.anyByte()
	);
	inOrder.verify(
		ddmFormInstanceRecordXLSWriter, Mockito.times(2)
	).createRow(
		Matchers.anyInt(), Matchers.any(CellStyle.class),
		Matchers.anyCollection(), Matchers.any(Sheet.class)
	);
	inOrder.verify(
		workbook, Mockito.times(1)
	).write(
		byteArrayOutputStream
	);
	inOrder.verify(
		byteArrayOutputStream, Mockito.times(1)
	).toByteArray();
}