### Question:
CacheBase implements ApplicationContextAware { protected String buildCacheKey(final String objectId, final AnnotationData data) { if (objectId == null || objectId.length() < 1) { throw new InvalidParameterException("Ids for objects in the cache must be at least 1 character long."); } return data.getNamespace() + SEPARATOR + objectId; }  void setApplicationContext(ApplicationContext applicationContext); void setCache(MemcachedClientIF cache); void setMethodStore(CacheKeyMethodStore methodStore); void setDefaultKeyProvider(KeyProvider defaultKeyProvider);  }### Answer:
@Test public void testBuildCacheKey() { try { cut.buildCacheKey(null, (AnnotationData) null); fail("Expected exception."); } catch (InvalidParameterException ex) { assertTrue(ex.getMessage().indexOf("at least 1 character") != -1); System.out.println(ex.getMessage()); } try { cut.buildCacheKey("", (AnnotationData) null); fail("Expected exception."); } catch (InvalidParameterException ex) { assertTrue(ex.getMessage().indexOf("at least 1 character") != -1); System.out.println(ex.getMessage()); } final String objectId = RandomStringUtils.randomAlphanumeric(20); final AnnotationData annotationData = new AnnotationData(); final String namespace = RandomStringUtils.randomAlphanumeric(12); annotationData.setNamespace(namespace); final String result = cut.buildCacheKey(objectId, annotationData); assertTrue(result.indexOf(objectId) != -1); assertTrue(result.indexOf(namespace) != -1); }