### Question:
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public void writeHostHistoricData(Host host, long time, double power, double energy) { connection = getConnection(connection); if (connection == null || host == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host_measurement (host_id, clock, energy, power) VALUES (?, ?, ? , ?);")) { preparedStatement.setInt(1, host.getId()); preparedStatement.setLong(2, time); preparedStatement.setDouble(3, energy); preparedStatement.setDouble(4, power); preparedStatement.executeUpdate(); } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } } DefaultDatabaseConnector(); @Override Collection<Host> getHosts(); @Override Collection<VmDeployed> getVms(); @Override Collection<Host> getHostCalibrationData(Collection<Host> hosts); @Override Host getHostCalibrationData(Host host); @Override Host getHostProfileData(Host host); @Override void setHosts(Collection<Host> hosts); @Override void setVms(Collection<VmDeployed> vms); @Override VmDeployed getVMProfileData(VmDeployed vm); @Override Collection<VmDeployed> getVMProfileData(Collection<VmDeployed> vms); @Override void setVMProfileData(VmDeployed vm); @Override void setHostCalibrationData(Host host); @Override void setHostProfileData(Host host); @Override void writeHostHistoricData(Host host, long time, double power, double energy); @Override List<HostEnergyRecord> getHostHistoryData(Host host, TimePeriod timePeriod); @Override void writeHostVMHistoricData(Host host, long time, HostVmLoadFraction load); @Override Collection<HostVmLoadFraction> getHostVmHistoryLoadData(Host host, TimePeriod timePeriod); @Override VmLoadHistoryRecord getAverageCPUUtilisationTag(String tagName); @Override VmLoadHistoryRecord getAverageCPUUtilisationDisk(String diskRefStr); @Override List<VmLoadHistoryWeekRecord> getAverageCPUUtilisationWeekTraceForTag(String tagName); @Override List<VmLoadHistoryWeekRecord> getAverageCPUUtilisationWeekTraceForDisk(String diskRef); @Override double getVMCurrentBootTraceIndex(VmDeployed vm, int windowSize); @Override List<VmLoadHistoryBootRecord> getAverageCPUUtilisationBootTraceForTag(String tagName, int windowSize); @Override List<VmLoadHistoryBootRecord> getAverageCPUUtilisationBootTraceForDisk(String diskName, int windowSize); @Override void closeConnection();  }### Answer:
@Test public void testWriteHostHistoricData() { System.out.println("writeHostHistoricData"); Host host = CHOSEN_HOST; long time = new GregorianCalendar().getTimeInMillis() / 1000; double power = 300; double energy = 1500; DefaultDatabaseConnector instance = new DefaultDatabaseConnector(); instance.writeHostHistoricData(host, time, power, energy); }