@Test(expectedExceptions = InitializationException.class) public void startWithAlreadyStoppedAgent() { final SnmpmanAgent mock = Mockito.mock(SnmpmanAgent.class); Mockito.when(mock.getAgentState()).thenReturn(BaseAgent.STATE_STOPPED); final List<SnmpmanAgent> snmpmanAgents = Collections.singletonList(mock); Snmpman.start(snmpmanAgents); }
public static Snmpman start(final File configurationFile) { Preconditions.checkNotNull(configurationFile, "the configuration file may not be null"); Preconditions.checkArgument(configurationFile.exists() && configurationFile.isFile(), "configuration does not exist or is not a file"); log.debug("started with configuration in path {}", configurationFile.getAbsolutePath()); try { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final AgentConfiguration[] configurations = mapper.readValue(configurationFile, AgentConfiguration[].class); return Snmpman.start(Arrays.stream(configurations).map(SnmpmanAgent::new).collect(Collectors.toList())); } catch (final IOException e) { throw new InitializationException("could not parse configuration at path: " + configurationFile.getAbsolutePath(), e); } }
Snmpman { public static Snmpman start(final File configurationFile) { Preconditions.checkNotNull(configurationFile, "the configuration file may not be null"); Preconditions.checkArgument(configurationFile.exists() && configurationFile.isFile(), "configuration does not exist or is not a file"); log.debug("started with configuration in path {}", configurationFile.getAbsolutePath()); try { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final AgentConfiguration[] configurations = mapper.readValue(configurationFile, AgentConfiguration[].class); return Snmpman.start(Arrays.stream(configurations).map(SnmpmanAgent::new).collect(Collectors.toList())); } catch (final IOException e) { throw new InitializationException("could not parse configuration at path: " + configurationFile.getAbsolutePath(), e); } } }
Snmpman { public static Snmpman start(final File configurationFile) { Preconditions.checkNotNull(configurationFile, "the configuration file may not be null"); Preconditions.checkArgument(configurationFile.exists() && configurationFile.isFile(), "configuration does not exist or is not a file"); log.debug("started with configuration in path {}", configurationFile.getAbsolutePath()); try { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final AgentConfiguration[] configurations = mapper.readValue(configurationFile, AgentConfiguration[].class); return Snmpman.start(Arrays.stream(configurations).map(SnmpmanAgent::new).collect(Collectors.toList())); } catch (final IOException e) { throw new InitializationException("could not parse configuration at path: " + configurationFile.getAbsolutePath(), e); } } private  Snmpman(final List<SnmpmanAgent> agents); }
Snmpman { public static Snmpman start(final File configurationFile) { Preconditions.checkNotNull(configurationFile, "the configuration file may not be null"); Preconditions.checkArgument(configurationFile.exists() && configurationFile.isFile(), "configuration does not exist or is not a file"); log.debug("started with configuration in path {}", configurationFile.getAbsolutePath()); try { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final AgentConfiguration[] configurations = mapper.readValue(configurationFile, AgentConfiguration[].class); return Snmpman.start(Arrays.stream(configurations).map(SnmpmanAgent::new).collect(Collectors.toList())); } catch (final IOException e) { throw new InitializationException("could not parse configuration at path: " + configurationFile.getAbsolutePath(), e); } } private  Snmpman(final List<SnmpmanAgent> agents); static Snmpman start(final File configurationFile); static Snmpman start(final List<SnmpmanAgent> agents); void stop(); }
Snmpman { public static Snmpman start(final File configurationFile) { Preconditions.checkNotNull(configurationFile, "the configuration file may not be null"); Preconditions.checkArgument(configurationFile.exists() && configurationFile.isFile(), "configuration does not exist or is not a file"); log.debug("started with configuration in path {}", configurationFile.getAbsolutePath()); try { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final AgentConfiguration[] configurations = mapper.readValue(configurationFile, AgentConfiguration[].class); return Snmpman.start(Arrays.stream(configurations).map(SnmpmanAgent::new).collect(Collectors.toList())); } catch (final IOException e) { throw new InitializationException("could not parse configuration at path: " + configurationFile.getAbsolutePath(), e); } } private  Snmpman(final List<SnmpmanAgent> agents); static Snmpman start(final File configurationFile); static Snmpman start(final List<SnmpmanAgent> agents); void stop();  }