### Question:
AcceptHeaderLocaleProvider implements LocaleProvider { public Optional<Locale> resolveLocale(final HttpServletRequest request) { return Optional.fromNullable(request.getLocale()); }  Optional<Locale> resolveLocale(final HttpServletRequest request);  }### Answer:
@Test public void shouldThrowNPE() throws Exception { try { acceptHeaderLocaleProvider.resolveLocale(null); fail("npe should be thrown"); } catch (Exception ex) { } }
@Test public void shouldReturnLocale() throws Exception { when(request.getLocale()).thenReturn(Locale.GERMAN); final Optional<Locale> localeOptional = acceptHeaderLocaleProvider.resolveLocale(request); Assert.assertTrue("locale should be present", localeOptional.isPresent()); Assert.assertEquals("locale should be German", Locale.GERMAN, localeOptional.get()); }