DDMFormInstanceRecordXMLWriter implements DDMFormInstanceRecordWriter { protected void addFieldElement( Element element, String label, String value) { Element fieldElement = element.addElement("field"); Element labelElement = fieldElement.addElement("label"); labelElement.addText(label); Element valueElement = fieldElement.addElement("value"); valueElement.addText(value); }  @Override DDMFormInstanceRecordWriterResponse write(
			DDMFormInstanceRecordWriterRequest
				ddmFormInstanceRecordWriterRequest);  }
@Test public void testAddFieldElement() { DDMFormInstanceRecordXMLWriter ddmFormInstanceRecordXMLWriter = new DDMFormInstanceRecordXMLWriter(); Element element = mock(Element.class); Element fieldElement = mock(Element.class); Element labelElement = mock(Element.class); Element valueElement = mock(Element.class); when( element.addElement("field") ).thenReturn( fieldElement ); when( fieldElement.addElement("label") ).thenReturn( labelElement ); when( fieldElement.addElement("value") ).thenReturn( valueElement ); ddmFormInstanceRecordXMLWriter.addFieldElement( element, "Label 1", "Value 1"); InOrder inOrder = Mockito.inOrder( element, fieldElement, labelElement, valueElement); inOrder.verify( element, Mockito.times(1) ).addElement( "field" ); inOrder.verify( fieldElement, Mockito.times(1) ).addElement( "label" ); inOrder.verify( labelElement, Mockito.times(1) ).addText( "Label 1" ); inOrder.verify( fieldElement, Mockito.times(1) ).addElement( "value" ); inOrder.verify( valueElement, Mockito.times(1) ).addText( "Value 1" ); }