ConerCoreApplication extends Application<ConerCoreConfiguration> { @Override public void run( ConerCoreConfiguration conerCoreConfiguration, Environment environment ) throws Exception { initComponents(conerCoreConfiguration); JerseyEnvironment jersey = environment.jersey(); jersey.register(components.eventsResource()); jersey.register(components.eventRegistrationsResource()); jersey.register(components.eventRunsResource()); jersey.register(components.eventResultsResource()); jersey.register(components.handicapGroupsResource()); jersey.register(components.handicapGroupSetsResource()); jersey.register(components.competitionGroupsResource()); jersey.register(components.competitionGroupSetsResource()); jersey.register(components.domainServiceExceptionMapper()); jersey.register(components.runtimeExceptionUnwrappingMapper()); optionallyRegisterHsqlDatabaseManagerSwingTask(environment, conerCoreConfiguration); }  static void main(String[] args); @Override void initialize(
            Bootstrap<ConerCoreConfiguration> bootstrap
    ); @Override void run(
            ConerCoreConfiguration conerCoreConfiguration,
            Environment environment
    );  }
@Test public void itShouldRegisterComponents() throws Exception { Object[] expectedComponents = { components.eventsResource(), components.eventRegistrationsResource(), components.eventRunsResource(), components.eventResultsResource(), components.handicapGroupsResource(), components.handicapGroupSetsResource(), components.competitionGroupsResource(), components.competitionGroupSetsResource(), components.domainServiceExceptionMapper(), components.runtimeExceptionUnwrappingMapper() }; application.run(config, environment); Arrays.stream(expectedComponents).forEach(o -> verify(jersey).register(o)); verifyNoMoreInteractions(jersey); }
@Test public void itShouldConsultHsqlDatabaseManagerTaskForRegistration() throws Exception { application.run(config, environment); verify(components.hsqlDatabaseManagerSwingTask()).shouldRegister(anyMap()); }
@Test public void whenHsqlDatabaseManagerTaskDeclinesItShouldNeverRegister() throws Exception { when(components.hsqlDatabaseManagerSwingTask().shouldRegister(anyMap())).thenReturn(false); application.run(config, environment); verify(environment.admin(), never()).addTask(components.hsqlDatabaseManagerSwingTask()); }
@Test public void whenHsqlDatabaseManagerTaskAcceptsItShouldRegister() throws Exception { when(components.hsqlDatabaseManagerSwingTask().shouldRegister(anyMap())).thenReturn(true); application.run(config, environment); verify(environment.admin()).addTask(components.hsqlDatabaseManagerSwingTask()); }