Class InfluxConnectorTest

java.lang.Object
test.de.iip_ecosphere.platform.connectors.influx.InfluxConnectorTest

@PrepareForTest({com.influxdb.client.InfluxDBClient.class,com.influxdb.client.InfluxDBClientFactory.class}) public class InfluxConnectorTest extends Object
Tests the InfluxConnector.
Author:
Holger Eichelberger, SSE
  • Field Details

    • written

      private com.influxdb.client.write.Point written
    • expectedData

      private List<test.de.iip_ecosphere.platform.connectors.MachineData> expectedData
  • Constructor Details

    • InfluxConnectorTest

      public InfluxConnectorTest()
  • Method Details

    • getDataTable

      private List<com.influxdb.query.FluxTable> getDataTable()
      Creates/returns INFLUX data/query result for mocking.
      Returns:
      the table(s)
    • addFluxRecord

      private void addFluxRecord(List<com.influxdb.query.FluxRecord> records, Instant now, String field, Object value)
      Adds a flux record to records.
      Parameters:
      records - the records list to modify
      now - the time stamp(s) of the record
      field - the field to represent
      value - the value of the field
    • toMachineCommand

      private test.de.iip_ecosphere.platform.connectors.MachineCommand toMachineCommand(com.influxdb.client.write.Point point)
      Turns a point back to a machine command.
      Parameters:
      point - the point
      Returns:
      the machine command instance, null if value access is not possible
    • toBoolean

      private boolean toBoolean(Map<String,Object> fields, String field)
      Turns an INFLUX object value to a boolean.
      Parameters:
      fields - the point fields to read the value from
      field - the field to read the value from
      Returns:
      the boolean value, false if the value does not exist
    • toInt

      private int toInt(Map<String,Object> fields, String field, int dflt)
      Turns an INFLUX object value to an int.
      Parameters:
      fields - the point fields to read the value from
      field - the field to read the value from
      dflt - a default value if the stored object does not exist or cannot be converted
      Returns:
      the int value or dflt
    • getBucket

      private com.influxdb.client.domain.Bucket getBucket()
      Returns a bucket.
      Returns:
      the bucket
    • testInfluxConnector

      public void testInfluxConnector() throws IOException
      Tests the InfluxConnector.
      Throws:
      IOException - shall not occur