ApiContextHandlerFactory implements ReactorHandlerFactory<Api> { @Override public ReactorHandler create(Api api) { if (api.isEnabled()) { AbstractApplicationContext internalApplicationContext = createApplicationContext(api); ApiReactorHandler handler = internalApplicationContext.getBean(ApiReactorHandler.class); return handler; } else { logger.warn("Api is disabled !"); return null; } }  @Override ReactorHandler create(Api api); void setGatewayApplicationContext(ApplicationContext gatewayApplicationContext);  }
@Test public void shouldNotCreateContext() { when(api.isEnabled()).thenReturn(false); ReactorHandler handler = apiContextHandlerFactory.create(api); assertNull(handler); }