}
@Test
public void field_attachment() throws Exception {
GroupInstanceHelper group = tool.get("group1").getDefaultInstance();
FieldHelper field = group.get("field1");
// no attachment
assertEquals(null, field.getAttachment());
assertEquals("", field.getAttachmentEncoded());
assertEquals(false, field.hasAttachment());
input attachmentTag = field.getAttachmentHiddenField();
assertThat(attachmentTag.toString(),
containsAll("<input", "name='_fm.g._0.f.attach'", "type='hidden'", "value=''", "/>"));
// with attachment
field.setAttachment("attachedObject");
assertEquals("attachedObject", field.getAttachment());
assertEquals("eNpb85aBtYSBL7GkJDE5IzXFPykrNbkEAFOhB7Y%3D", field.getAttachmentEncoded());
assertEquals(true, field.hasAttachment());
attachmentTag = field.getAttachmentHiddenField();
assertThat(
attachmentTag.toString(),
containsAll("<input", "name='_fm.g._0.f.attach'", "type='hidden'",
"value='eNpb85aBtYSBL7GkJDE5IzXFPykrNbkEAFOhB7Y%3D'", "/>"));
// clear attachment
field.clearAttachment();
assertEquals(null, field.getAttachment());
assertEquals("", field.getAttachmentEncoded());
assertEquals(false, field.hasAttachment());
}