### Question:
FinderFactory { public Serializable getContextResultElement(final Serializable object) { final ResourceFinder resourceFinderFor = getResourceFinderFor(object); if (resourceFinderFor != null) { return resourceFinderFor.toClientObject(object); } return object; } FinderFactory();  FinderFactory(final Map<Class<? extends ServerResource>, ResourceFinder> finders); Finder create(final Class<? extends ServerResource> clazz); Finder createExtensionResource(); ResourceFinder getResourceFinderFor(final Serializable object); Serializable getContextResultElement(final Serializable object);  }### Answer:
@Test public void should_getResourceFinderFor_return_result_of_first_handler(){ final FinderFactory finderFactory = new FinderFactory(Collections.<Class<? extends ServerResource>,ResourceFinder>singletonMap(null, new ResourceFinder() { @Override public Serializable toClientObject(final Serializable object) { return "resultA"; } @Override public boolean handlesResource(final Serializable object) { return object.equals("objectA"); } })); final Serializable objectA = finderFactory.getContextResultElement("objectA"); assertThat(objectA).isEqualTo("resultA"); }
@Test public void should_getResourceFinderFor_return_the_object_if_no_handler(){ final FinderFactory finderFactory = new FinderFactory(Collections.<Class<? extends ServerResource>,ResourceFinder>singletonMap(null, new ResourceFinder() { @Override public Serializable toClientObject(final Serializable object) { return "resultA"; } @Override public boolean handlesResource(final Serializable object) { return object.equals("objectB"); } })); final Serializable objectA = finderFactory.getContextResultElement("objectA"); assertThat(objectA).isEqualTo("objectA"); }