@Test
public void testExport() throws Exception {

	DDMFormInstanceRecordExporterImpl ddmFormInstanceRecordExporterImpl =
		mock(DDMFormInstanceRecordExporterImpl.class);
	ddmFormInstanceRecordExporterImpl.ddmFormInstanceRecordLocalService =
		_ddmFormInstanceRecordLocalService;
	DDMFormInstanceRecordExporterRequest.Builder builder =
		DDMFormInstanceRecordExporterRequest.Builder.newBuilder(1, "csv");
	OrderByComparator<DDMFormInstanceRecord> orderByComparator = mock(
		OrderByComparator.class);
	Locale locale = new Locale("pt", "BR");
	DDMFormInstanceRecordExporterRequest
		ddmFormInstanceRecordExporterRequest = builder.withStatus(
			WorkflowConstants.STATUS_APPROVED
		).withLocale(
			locale
		).withStart(
			1
		).withEnd(
			5
		).withOrderByComparator(
			orderByComparator
		).build();
	List<DDMFormInstanceRecord> ddmFormInstanceRecords =
		Collections.emptyList();
	when(
		_ddmFormInstanceRecordLocalService.getFormInstanceRecords(
			1, WorkflowConstants.STATUS_APPROVED, 1, 5, orderByComparator)
	).thenReturn(
		ddmFormInstanceRecords
	);
	Map<String, DDMFormField> ddmFormFields = Collections.emptyMap();
	when(
		ddmFormInstanceRecordExporterImpl.getDistinctFields(1)
	).thenReturn(
		ddmFormFields
	);
	Map<String, String> ddmFormFieldsLabel = Collections.emptyMap();
	when(
		ddmFormInstanceRecordExporterImpl.getDDMFormFieldsLabel(
			ddmFormFields, locale)
	).thenReturn(
		ddmFormFieldsLabel
	);
	List<Map<String, String>> ddmFormFieldsValues = Collections.emptyList();
	when(
		ddmFormInstanceRecordExporterImpl.getDDMFormFieldValues(
			ddmFormFields, ddmFormInstanceRecords, locale)
	).thenReturn(
		ddmFormFieldsValues
	);
	when(
		ddmFormInstanceRecordExporterImpl.write(
			"csv", ddmFormFieldsLabel, ddmFormFieldsValues)
	).thenReturn(
		new byte[] {1, 2, 3}
	);
	when(
		ddmFormInstanceRecordExporterImpl.export(
			ddmFormInstanceRecordExporterRequest)
	).thenCallRealMethod();
	DDMFormInstanceRecordExporterResponse
		ddmFormInstanceRecordExporterResponse =
			ddmFormInstanceRecordExporterImpl.export(
				ddmFormInstanceRecordExporterRequest);
	Assert.assertArrayEquals(
		new byte[] {1, 2, 3},
		ddmFormInstanceRecordExporterResponse.getContent());
	InOrder inOrder = Mockito.inOrder(
		_ddmFormInstanceRecordLocalService,
		ddmFormInstanceRecordExporterImpl);
	inOrder.verify(
		_ddmFormInstanceRecordLocalService, Mockito.times(1)
	).getFormInstanceRecords(
		1, WorkflowConstants.STATUS_APPROVED, 1, 5, orderByComparator
	);
	inOrder.verify(
		ddmFormInstanceRecordExporterImpl, Mockito.times(1)
	).getDistinctFields(
		1
	);
	inOrder.verify(
		ddmFormInstanceRecordExporterImpl, Mockito.times(1)
	).getDDMFormFieldsLabel(
		ddmFormFields, locale
	);
	inOrder.verify(
		ddmFormInstanceRecordExporterImpl, Mockito.times(1)
	).getDDMFormFieldValues(
		ddmFormFields, ddmFormInstanceRecords, locale
	);
	inOrder.verify(
		ddmFormInstanceRecordExporterImpl, Mockito.times(1)
	).write(
		"csv", ddmFormFieldsLabel, ddmFormFieldsValues
	);
}