BaseUrlManagerImpl extends ComponentSupport implements BaseUrlManager { @Nullable @Override public String detectUrl() { if (force && !Strings.isNullOrEmpty(url)) { return url; } HttpServletRequest request = httpRequest(); if (request != null) { StringBuffer url = request.getRequestURL(); String uri = request.getRequestURI(); String ctx = request.getContextPath(); return url.substring(0, url.length() - uri.length() + ctx.length()); } if (!Strings.isNullOrEmpty(url)) { return url; } return null; } @Inject  BaseUrlManagerImpl(final Provider<HttpServletRequest> requestProvider,
                            @Named("${org.sonatype.nexus.internal.app.BaseUrlManagerImpl.force:-false}") final boolean force); @Override void setUrl(final String url); @Override String getUrl(); @Override boolean isForce(); @Override void setForce(final boolean force); @Nullable @Override String detectUrl(); @Override void detectAndHoldUrl();  }
@Test public void noBaseUrl() { when(requestProvider.get()).thenReturn(null); assertThat(underTest.detectUrl(), nullValue()); }