@Test public void create_remote_connection_and_return_it() throws Exception { Connection properties = new Connection("localhost", 12345); doReturn(remoteInjector).when(connectionService).createRemoteInjector(any()); connectionService.createConnection(properties); InjectorService currentConnection = injectorHandler.getInjectorService(); Assert.assertNotNull(currentConnection); Assert.assertTrue(currentConnection instanceof RemoteInjector); }
public InjectorService getInjectorService() { Map<String, InjectorService> beansOfType = context.getBeansOfType(InjectorService.class); if (beansOfType.entrySet().isEmpty()) { throw new NoSuchBeanDefinitionException("No InjectorType found"); } return beansOfType.entrySet().iterator().next().getValue(); }
InjectorHandler { public InjectorService getInjectorService() { Map<String, InjectorService> beansOfType = context.getBeansOfType(InjectorService.class); if (beansOfType.entrySet().isEmpty()) { throw new NoSuchBeanDefinitionException("No InjectorType found"); } return beansOfType.entrySet().iterator().next().getValue(); } }
InjectorHandler { public InjectorService getInjectorService() { Map<String, InjectorService> beansOfType = context.getBeansOfType(InjectorService.class); if (beansOfType.entrySet().isEmpty()) { throw new NoSuchBeanDefinitionException("No InjectorType found"); } return beansOfType.entrySet().iterator().next().getValue(); } InjectorHandler(ApplicationContext context); }
InjectorHandler { public InjectorService getInjectorService() { Map<String, InjectorService> beansOfType = context.getBeansOfType(InjectorService.class); if (beansOfType.entrySet().isEmpty()) { throw new NoSuchBeanDefinitionException("No InjectorType found"); } return beansOfType.entrySet().iterator().next().getValue(); } InjectorHandler(ApplicationContext context); InjectorService getInjectorService(); }
InjectorHandler { public InjectorService getInjectorService() { Map<String, InjectorService> beansOfType = context.getBeansOfType(InjectorService.class); if (beansOfType.entrySet().isEmpty()) { throw new NoSuchBeanDefinitionException("No InjectorType found"); } return beansOfType.entrySet().iterator().next().getValue(); } InjectorHandler(ApplicationContext context); InjectorService getInjectorService();  }