DDMFormInstanceRecordExporterImpl implements DDMFormInstanceRecordExporter { protected byte[] write( String type, Map<String, String> ddmFormFieldsLabel, List<Map<String, String>> ddmFormFieldValues) throws Exception { DDMFormInstanceRecordWriter ddmFormInstanceRecordWriter = ddmFormInstanceRecordWriterTracker.getDDMFormInstanceRecordWriter( type); DDMFormInstanceRecordWriterRequest.Builder builder = DDMFormInstanceRecordWriterRequest.Builder.newBuilder( ddmFormFieldsLabel, ddmFormFieldValues); DDMFormInstanceRecordWriterRequest ddmFormInstanceRecordWriterRequest = builder.build(); DDMFormInstanceRecordWriterResponse ddmFormInstanceRecordWriterResponse = ddmFormInstanceRecordWriter.write( ddmFormInstanceRecordWriterRequest); return ddmFormInstanceRecordWriterResponse.getContent(); }  @Override DDMFormInstanceRecordExporterResponse export(
			DDMFormInstanceRecordExporterRequest
				ddmFormInstanceRecordExporterRequest);  }
@Test public void testWrite() throws Exception { DDMFormInstanceRecordExporterImpl ddmFormInstanceRecordExporterImpl = new DDMFormInstanceRecordExporterImpl(); ddmFormInstanceRecordExporterImpl.ddmFormInstanceRecordWriterTracker = _ddmFormInstanceRecordWriterTracker; DDMFormInstanceRecordWriter ddmFormInstanceRecordWriter = mock( DDMFormInstanceRecordWriter.class); when( _ddmFormInstanceRecordWriterTracker.getDDMFormInstanceRecordWriter( "txt") ).thenReturn( ddmFormInstanceRecordWriter ); DDMFormInstanceRecordWriterResponse.Builder builder = DDMFormInstanceRecordWriterResponse.Builder.newBuilder( new byte[] {1, 2, 3}); when( ddmFormInstanceRecordWriter.write( Matchers.any(DDMFormInstanceRecordWriterRequest.class)) ).thenReturn( builder.build() ); byte[] content = ddmFormInstanceRecordExporterImpl.write( "txt", Collections.emptyMap(), Collections.emptyList()); Assert.assertArrayEquals(new byte[] {1, 2, 3}, content); InOrder inOrder = Mockito.inOrder( _ddmFormInstanceRecordWriterTracker, ddmFormInstanceRecordWriter); inOrder.verify( _ddmFormInstanceRecordWriterTracker, Mockito.times(1) ).getDDMFormInstanceRecordWriter( "txt" ); inOrder.verify( ddmFormInstanceRecordWriter, Mockito.times(1) ).write( Matchers.any(DDMFormInstanceRecordWriterRequest.class) ); }