@Test
public void testFindByMetadataField() throws Exception
{

    String schema = "dc";
    String element = "contributor";
    String qualifier = "author";
    String value = "value";
    Iterator<Item> result = itemService.findByMetadataField(context, schema, element, qualifier, value);
    assertThat("testFindByMetadataField 0",result,notNullValue());
    assertFalse("testFindByMetadataField 1",result.hasNext());
    itemService.addMetadata(context, it, schema,element, qualifier, Item.ANY, value);
    new NonStrictExpectations(authorizeService.getClass())
    {
        {
            authorizeService.authorizeAction((Context) any, (Item) any,
                    Constants.WRITE); result = null;
        }
    };
    itemService.update(context, it);
    result = itemService.findByMetadataField(context, schema, element, qualifier, value);
    assertThat("testFindByMetadataField 3",result,notNullValue());        
    assertTrue("testFindByMetadataField 4",result.hasNext());
    assertTrue("testFindByMetadataField 5",result.next().equals(it));
}