Example #1
0
 /*
 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");
   }
 }