@Test
public void testFindOne() throws Exception {

    Class<Object> expectedClass = Object.class;
    when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
    when(odmMock.filterFor(expectedClass,
            new EqualsFilter("ou", "somevalue"))).thenReturn(new EqualsFilter("ou", "somevalue"));
    DirContextAdapter expectedObject = new DirContextAdapter();
    SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes());
    singleSearchResult(searchControlsRecursive(), searchResult);
    Object expectedResult = expectedObject;
    when(odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult);
    Object result = tested.findOne(query()
            .where("ou").is("somevalue"), expectedClass);
    verify(namingEnumerationMock).close();
    verify(dirContextMock).close();
    assertThat(result).isSameAs(expectedResult);
}