### Question:
ResourceModelResolverImpl implements ResourceModelResolver { @Override public Object resolveMostSpecificModel(Resource resource) { if (resource == null) { throw new IllegalArgumentException("Method argument resource must not be null."); } return resolveMostSpecificModelForResource(resource, false, null); }  @Override Object resolveMostSpecificModelWithName(Resource resource, String name); @Override Object resolveMostSpecificModel(Resource resource); @Override Object resolveMostSpecificModelIncludingModelsForBaseTypes(Resource resource);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testResolveMostSpecificModelRequiresResource() { this.testee.resolveMostSpecificModel(null); }
@Test public void testResolutionOfSpecificModelWithModelForNtUnstructured() { withModelFoundForResourceType("nt:unstructured"); resolveMostSpecificModel(); assertResolvedModelIsNull(); }
@Test public void testResolutionOfSpecificModelWithModelForNtBase() { withModelFoundForResourceType("nt:base"); resolveMostSpecificModel(); assertResolvedModelIsNull(); }
@Test public void testResolutionOfSpecificModelWithModelForSyntheticResourceRoot() { withModelFoundForResourceType(SYNTHETIC_RESOURCETYPE_ROOT); resolveMostSpecificModel(); assertResolvedModelIsNull(); }
@Test public void testSubsequentResolutionOfSameResourceWithDifferentResourceTypeIsNotServedFromCache() { withResourcePath("/resource/path"); withResourceType("resource/type/one"); resolveMostSpecificModel(); verifyResourceIsMappedToModel(); withResourceType("resource/type/two"); resolveMostSpecificModel(); verifyResourceIsMappedToModelAgain(); }
@Test public void testSubsequentResolutionOfSameResourceWithSameResourceTypeIsServedFromCache() { withResourcePath("/resource/path"); withResourceType("resource/type/one"); resolveMostSpecificModel(); verifyResourceIsMappedToModel(); withResourceType("resource/type/one"); resolveMostSpecificModel(); verifyResourceIsMappedToModel(); }
@Test public void testNoModelIsResolvedIfNoModelIsAvailable() { withoutAnyModelInRegistry(); resolveMostSpecificModel(); assertResolvedModelIsNull(); }
@Test public void testNoModelIsResolvedIfMoreThanOneModelIsAvailable() { withTwoResolvedModels(); resolveMostSpecificModel(); assertResolvedModelIsNull(); }
@Test public void testRegistryIsNotQueriedWhenLookupFailureIsCached() { withoutAnyModelInRegistry(); resolveMostSpecificModel(); verifyRegistryWasQueriedOnceWithoutModelName(); resolveMostSpecificModel(); verifyRegistryWasQueriedOnceWithoutModelName(); }