### Question:
DefaultCacheKeyFactory implements CacheKeyFactory { public CacheKey create(final HttpServletRequest request) { notNull(request); CacheKey key = null; final String groupName = groupExtractor.getGroupName(request); final ResourceType resourceType = groupExtractor.getResourceType(request); final boolean minimize = isMinimized(request); if (groupName != null && resourceType != null) { key = new CacheKey(groupName, resourceType, minimize); } return key; }  CacheKey create(final HttpServletRequest request);  }### Answer:
@Test(expected = NullPointerException.class) public void cannotBuildCacheKeyFromNullRequest() { victim.create(null); }
@Test public void shouldCreateNullCacheKeyWhenRequestDoesNotContainEnoughInfo() { assertNull(victim.create(mockRequest)); }
@Test public void shouldCreateNullCacheKeyWhenRequestDoesNotContainResourceType() { when(mockGroupExtractor.getGroupName(mockRequest)).thenReturn("g1"); when(mockGroupExtractor.getResourceType(mockRequest)).thenReturn(null); assertNull(victim.create(mockRequest)); }
@Test public void shouldCreateNullCacheKeyWhenRequestDoesNotGroupName() { when(mockGroupExtractor.getGroupName(mockRequest)).thenReturn(null); when(mockGroupExtractor.getResourceType(mockRequest)).thenReturn(ResourceType.CSS); assertNull(victim.create(mockRequest)); }