@Test
public void testCopyUnknownFieldsHandler() throws MetadataException {

    Directory d = Mockito.mock(Directory.class);
    Tag t1 = Mockito.mock(Tag.class);
    Mockito.when(t1.getTagName()).thenReturn("Image Description");
    Mockito.when(t1.getDescription()).thenReturn("t1");
    Tag t2 = Mockito.mock(Tag.class);
    Mockito.when(t2.getTagName()).thenReturn(TikaCoreProperties.SUBJECT.toString());
    Mockito.when(t2.getDescription()).thenReturn("known");
    Tag t3 = Mockito.mock(Tag.class);
    Mockito.when(t3.getTagName()).thenReturn(TikaCoreProperties.DESCRIPTION.getName());
    Mockito.when(t3.getDescription()).thenReturn("known");
    List<Tag> tags = Arrays.asList(t1, t2, t3);
    Mockito.when(d.getTags()).thenReturn(tags);
    Metadata metadata = new Metadata();
    new ImageMetadataExtractor.CopyUnknownFieldsHandler().handle(d, metadata);
    assertEquals("t1", metadata.get("Image Description"));
    assertNull("keywords should be excluded from bulk copy because it is a defined field",
            metadata.get(TikaCoreProperties.SUBJECT));
    assertNull(metadata.get(TikaCoreProperties.DESCRIPTION));
}