ContextNameProvider { public String getContextName() { final String warName = serviceContextNameProvider.getServiceContextName(); final int index = warName.indexOf('-'); if (index == -1) { return warName; } return warName.substring(0, index); }  String getContextName();  }
@Test public void shouldGetTheNameOfTheContextAsTheAppNameUpToTheFirstDash() throws Exception { final String appName = "somecontext-service"; when(serviceContextNameProvider.getServiceContextName()).thenReturn(appName); assertThat(contextNameProvider.getContextName(), is("somecontext")); }
@Test public void shouldHandleContextNamesWithoutADash() throws Exception { final String appName = "somecontext"; when(serviceContextNameProvider.getServiceContextName()).thenReturn(appName); assertThat(contextNameProvider.getContextName(), is(appName)); }