/*                                                                      *\
**                    SICU Stress Measurement System                    **
**                      Project P04  |  C380 Team A                     **
**          EBME 380: Biomedical Engineering Design Experience          **
**                    Case Western Reserve University                   **
**                          2016 Fall Semester                          **
\*                                                                      */

package edu.cwru.sicu_sms.util;

import jssc.SerialPortEvent;
import org.junit.jupiter.api.*;

import java.util.Arrays;

/**
 * Test class for {@link EKGSerialPort}.
 *
 * @since December 14, 2016
 * @author Ted Frohlich <ttf10@case.edu>
 * @author Abby Walker <amw138@case.edu>
 */
class EKGSerialPortTest {
    
    private static long READ_DURATION = (long) 3e9;  // 3 seconds, expressed in nanoseconds
    
    private EKGSerialPort serialPort;
    
    @BeforeEach
    void setUp() {
        serialPort = new EKGSerialPort() {
            @Override
            public void serialEvent(SerialPortEvent serialPortEvent) {
                
            }
        };
        serialPort.openPort();
    }
    
    @AfterEach
    void tearDown() {
        serialPort.closePort();
    }
    
    @Test
    void testInTerminal() {
        int[] data;
        
        long startTime = System.nanoTime();
        do {
            data = serialPort.readIntArray();
            
            if (data != null && data.length > 0) {
                System.out.println(Arrays.toString(data));
            }
        } while (System.nanoTime() - startTime < READ_DURATION);
    }
    
}
@@ -556,37 +556,8 @@
 l;%0A%0A
-import jssc.SerialPortEvent;%0A
 impo
@@ -1023,144 +1023,8 @@
 rt()
- %7B%0A            @Override%0A            public void serialEvent(SerialPortEvent serialPortEvent) %7B%0A                %0A            %7D%0A        %7D
 ;%0A  
@@ -1185,37 +1185,8 @@
 ) %7B%0A
-        int%5B%5D data;%0A        %0A
     
@@ -1237,31 +1237,16 @@
     
-do %7B%0A    
+%0A
        
- data =
  ser
@@ -1257,36 +1257,45 @@
 ort.
-readIntArray();%0A            
+setEventListener(serialPortEvent -%3E %7B
 %0A   
@@ -1308,50 +1308,47 @@
    i
-f (
+nt%5B%5D 
 data 
-!
 = 
-null && data.length %3E 0) %7B%0A    
+serialPort.readIntArray();%0A
     
@@ -1410,21 +1410,28 @@
     
+%7D);%0A    
     
-%7D
 %0A       
  %7D w
@@ -1426,18 +1426,16 @@
 %0A       
- %7D
  while (
@@ -1493,9 +1493,66 @@
  %7D%0A    %0A
+    @Test%0A    void testInFXChart() %7B%0A        %0A    %7D%0A    %0A
 %7D

Reimplement test method 'testInTerminal' to use serial port event listener