### Question:
ContentTypeNormaliserImpl implements ContentTypeNormaliser { @Override public String getNormalisedEncoding(HttpServletRequest request) { return getEncoding(request.getContentType()); }  @Override void addValidContentTypes(final Set<String> vct, MediaType normalisedContentType); @Override void addValidEncodings(final Set<String> validEncodings); @Override MediaType getNormalisedResponseMediaType(HttpServletRequest request); @Override MediaType getNormalisedRequestMediaType(HttpServletRequest request); void setDefaultResponseFormat(String defaultResponseFormat); @Override String getNormalisedEncoding(HttpServletRequest request); static final String DEFAULT_ENCODING; }### Answer:
@Test public void testGetNormalisedEncoding() { when(request.getCharacterEncoding()).thenReturn("utf-8"); String encoding = ctn.getNormalisedEncoding(request); assertNotNull(encoding); assertEquals("utf-8", encoding); }
@Test public void testGetNormalisedEncoding_Null() { String encoding = ctn.getNormalisedEncoding(request); assertNotNull(encoding); assertEquals("utf-8", encoding); }
@Test public void testGetNormalisedEncoding_Invalid() { when(request.getCharacterEncoding()).thenReturn("utf-16"); String encoding = ctn.getNormalisedEncoding(request); assertNotNull(encoding); assertEquals("utf-8", encoding); }
@Test public void testGetNormalisedEncoding_JustPlainWrong() { when(request.getContentType()).thenReturn("text/html; charset="); String encoding = ctn.getNormalisedEncoding(request); assertNotNull(encoding); assertEquals("utf-8", encoding); when(request.getContentType()).thenReturn("text/html; charset=MadeUp"); encoding = ctn.getNormalisedEncoding(request); assertNotNull(encoding); assertEquals("utf-8", encoding); }