### Question:
FixedBaseURLProvider extends BaseURLProvider { @Override void init(OpenAMSettings settings, String realm) { try { this.baseUrl = settings.getStringSetting(realm, FIXED_VALUE_SETTING); } catch (Exception e) { throw new IllegalStateException("Cannot access fixed value setting for realm " + realm); } }    }### Answer:
@Test public void testInit() throws Exception { OpenAMSettings settings = mock(OpenAMSettings.class); provider.init(settings, "realm"); verify(settings).getStringSetting("realm", "base-url-fixed-value"); }
@Test public void testGetURL() throws Exception { OpenAMSettings settings = mock(OpenAMSettings.class); when(settings.getStringSetting("realm", "base-url-fixed-value")).thenReturn("fred"); provider.init(settings, "realm"); provider.setContextPath(""); String url = provider.getRootURL(mock(HttpServletRequest.class)); assertThat(url).isEqualTo("fred"); }
@Test public void testGetURLWithContextPath() throws Exception { OpenAMSettings settings = mock(OpenAMSettings.class); when(settings.getStringSetting("realm", "base-url-fixed-value")).thenReturn("fred"); provider.init(settings, "realm"); provider.setContextPath("/openam"); HttpServletRequest request = mock(HttpServletRequest.class); when(request.getContextPath()).thenReturn("/fred"); String url = provider.getRootURL(request); assertThat(url).isEqualTo("fred/openam"); }