### Question:
DefaultKeyProvider implements KeyProvider { String generateObjectId(final Method keyMethod, final Object keyObject) throws Exception { final String objectId = (String) keyMethod.invoke(keyObject, null); if (objectId == null || objectId.length() < 1) { throw new RuntimeException("Got an empty key value from " + keyMethod.getName()); } return objectId; }  void setMethodStore(CacheKeyMethodStore methodStore); String generateKey(final Object keyObject); List<String> generateKeys(final List<Object> keyObjects);  }### Answer:
@Test public void testGenerateCacheKey() throws Exception { final Method method = KeyObject.class.getMethod("toString", null); try { cut.generateObjectId(method, new KeyObject(null)); fail("Expected Exception."); } catch (RuntimeException ex) { assertTrue(ex.getMessage().indexOf("empty key value") != -1); } try { cut.generateObjectId(method, new KeyObject("")); fail("Expected Exception."); } catch (RuntimeException ex) { assertTrue(ex.getMessage().indexOf("empty key value") != -1); } final String result = "momma"; assertEquals(result, cut.generateObjectId(method, new KeyObject(result))); }