DefaultEventSourceDefinitionFactory { public EventSourceDefinition createDefaultEventSource() { final String warFileName = jndiAppNameProvider.getAppName(); final String name = warFileName + "-event-store"; final String dataSourceName = format(EVENT_STORE_DATA_SOURCE_PATTERN, warFileName); final boolean isDefault = true; return new EventSourceDefinition( name, isDefault, new Location( "JMS URI not used", empty(), of(dataSourceName) ) ); }  EventSourceDefinition createDefaultEventSource();  }
@Test public void shouldCreateADefaultDataSource() throws Exception { when(jndiAppNameProvider.getAppName()).thenReturn("my-context-service"); final EventSourceDefinition eventSourceDefinition = defaultEventSourceDefinitionFactory.createDefaultEventSource(); assertThat(eventSourceDefinition.getName(), is("my-context-service-event-store")); assertThat(eventSourceDefinition.isDefault(), is(true)); final Location location = eventSourceDefinition.getLocation(); if (location.getDataSource().isPresent()) { assertThat(location.getDataSource().get(), is("java:/app/my-context-service/DS.eventstore")); } else { fail(); } assertThat(location.getJmsUri(), is("JMS URI not used")); assertThat(location.getRestUri(), is(empty())); }