### Question:
DataGatherer implements Runnable { @Override public void run() { if (logVmsToDisk && performDataGathering) { vmUsageLogger = new VmEnergyUsageLogger(new File(loggerOutputFile), true); vmUsageLogger.setConsiderIdleEnergy(loggerConsiderIdleEnergy); Thread vmUsageLoggerThread = new Thread(vmUsageLogger); vmUsageLoggerThread.setDaemon(true); vmUsageLoggerThread.start(); } while (running) { try { Logger.getLogger(DataGatherer.class.getName()).log(Level.FINE, "Data gatherer: Obtaining online host and vm list"); List<EnergyUsageSource> energyConsumers = datasource.getHostAndVmList(); List<Host> hostList = getHostList(energyConsumers); refreshKnownHostList(hostList); List<GeneralPurposePowerConsumer> generalPurposeList = datasource.getGeneralPowerConsumerList(); refreshKnownGeneralPurposeNodesList(generalPurposeList); List<VmDeployed> vmList = getVMList(energyConsumers); refreshKnownVMList(vmList); Logger.getLogger(DataGatherer.class.getName()).log(Level.FINE, "Data gatherer: Obtaining specific host information"); List<HostMeasurement> measurements = datasource.getHostData(hostList); List<HostMeasurement> generalNodeMeasurements = datasource.getHostData(GeneralPurposePowerConsumer.generalPurposeHostListToHostList(generalPurposeList)); for (HostMeasurement measurement : measurements) { Host host = knownHosts.get(measurement.getHost().getHostName()); measurement.setHost(host); if (performDataGathering) { gatherMeasurements(host, measurement, getGeneralPurposeHostsPowerConsumption(generalNodeMeasurements), vmList, vmUsageLogger); } } try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(DataGatherer.class.getName()).log(Level.SEVERE, "The data gatherer was interupted.", ex); } faultCount = (faultCount > 0 ? faultCount - 1 : 0); } catch (Exception ex) { faultCount = faultCount + 1; Logger.getLogger(DataGatherer.class.getName()).log(Level.SEVERE, "The data gatherer encountered a fault, Fault Number:" + faultCount, ex); if (faultCount > 100) { Logger.getLogger(DataGatherer.class.getName()).log(Level.SEVERE, "Many faults were seen in a row the energy modeller is now pausing from gathering data."); faultCount = 0; try { Thread.sleep(TimeUnit.MINUTES.toMillis(5)); } catch (InterruptedException e) { Logger.getLogger(DataGatherer.class.getName()).log(Level.SEVERE, "The data gatherer was interupted.", ex); } } } } } DataGatherer(HostDataSource datasource, DatabaseConnector connector, Calibrator calibrator); void stop(); double getGeneralPurposeHostsPowerConsumption(); @Override void run(); void setRule(EnergyShareRule rule); HashMap<String, Host> getHostList(); HashMap<String, GeneralPurposePowerConsumer> getGeneralPurposeHostList(); Host getHost(String hostname); HashMap<String, VmDeployed> getVmList(); HashSet<VmDeployed> getVmList(String deploymentId); VmDeployed getVm(String name); VmDeployed getVm(int vmId); boolean setVm(VmDeployed vm); ArrayList<VmDeployed> getVMsOnHost(Host host); ArrayList<VmDeployed> getVMsOnHost(Host host, List<VmDeployed> activeVMs); void setPerformDataGathering(boolean performDataGathering); boolean performDataGathering();  }### Answer:
@Test public void testRun() { System.out.println("run"); DataGatherer instance = getDataGatherer(); Thread thread = new Thread(instance); thread.start(); try { Thread.sleep(20000); } catch (InterruptedException ex) { fail("Something interuppted the thread while waiting for some data to be gathered"); } }