/*
 Summary: Method written to separate untested functionality from the original
         send method. If the stream is valid, it gets sent to the car. If not,
         the stream is set to null before it's sent. The possibility of getting
         null is handled by the car.(?)
 Pre-condition:
         sendValid receives a stream.
 Post-condition:
         Either the original stream is sent, or the car receives a stream of
         value null.
 tc0: The stream is corrupt
 tc1: The stream is empty
 tc2: The stream is valid
 */
 public static void sendValid(ByteArrayOutputStream stream) {
   if (SensorData.isValidStream(stream)) {
     dummyCar.receiveData(stream);
     byte[] array = stream.toByteArray();
     System.out.println("Sent data: " + Arrays.toString(array));
   } else {
     stream.reset();
     dummyCar.receiveData(stream);
     System.out.println("Empty stream sent");
   }
 }
  /*
  Summary:
          Originally contained the functionality in sendValid. Another method
          was created in order to test previously untested functionality.

  tc0: The sensor values result in a data packet of the correct length and
       with correct delimiters.
  */
  static void send(double torque, double ir, double uv) throws Exception {
    SensorData data = new SensorData(torque, ir, uv);
    ByteArrayOutputStream s = SensorData.getSensorData(data);

    sendValid(s);
  }