package com.heartbeat.pin.command.system;

import com.heartbeat.pin.Pin;
import com.heartbeat.pin.command.PinCommandException;
import org.junit.Test;

public class ChipSystemPinCommandTest {
    private Pin getPin() throws PinCommandException {
        final Pin pin = new Pin("P1", Pin.Mode.IN, new ChipSystemPinCommand());
        return pin;
    }

    @Test
    public void testGetMode() throws Exception {
        try {
            ChipSystemPinCommand cmd = new ChipSystemPinCommand();
            cmd.getMode(getPin());
        } catch (PinCommandException e) {
            assert e.getMessage().contains("sudo:");
        }
    }

    @Test
    public void testSetMode() throws Exception {
        try {
            ChipSystemPinCommand cmd = new ChipSystemPinCommand();
            cmd.setMode(getPin(), Pin.Mode.IN);
            assert true;
        } catch (PinCommandException e) {
            assert e.getMessage().contains("sudo:");
        }
    }

    @Test
    public void testEnable() throws Exception {
        try {
            ChipSystemPinCommand cmd = new ChipSystemPinCommand();
            cmd.enable(getPin());
            assert true;
        } catch (PinCommandException e) {
            assert e.getMessage().contains("sudo:");
        }
    }

    @Test
    public void testDisable() throws Exception {
        try {
            ChipSystemPinCommand cmd = new ChipSystemPinCommand();
            cmd.disable(getPin());
            assert true;
        } catch (PinCommandException e) {
            assert e.getMessage().contains("sudo:");
        }
    }

    @Test
    public void testRead() throws Exception {
        try {
            ChipSystemPinCommand cmd = new ChipSystemPinCommand();
            cmd.read(getPin());
            assert true;
        } catch (PinCommandException e) {
            assert e.getMessage().contains("sudo:");
        }
    }

    @Test
    public void testWrite() throws Exception {
        try {
            ChipSystemPinCommand cmd = new ChipSystemPinCommand();
            cmd.write(getPin(), false);
            assert true;
        } catch (PinCommandException e) {
            assert e.getMessage().contains("sudo:");
        }
    }

    @Test
    public void testPath() throws Exception {
        try {
            ChipSystemPinCommand cmd = new ChipSystemPinCommand();
            assert cmd.path(getPin()).equals("/sys/class/gpio/gpioP1");
        } catch (PinCommandException e) {
            assert e.getMessage().contains("sudo:");
        }
    }
}
@@ -554,32 +554,80 @@
 dException e) %7B%0A
+            System.out.println(e.getMessage());%0A
             asse
@@ -655,32 +655,32 @@
 tains(%22sudo:%22);%0A
-
         %7D%0A    %7D%0A
@@ -927,32 +927,80 @@
 dException e) %7B%0A
+            System.out.println(e.getMessage());%0A
             asse
@@ -1285,32 +1285,80 @@
 dException e) %7B%0A
+            System.out.println(e.getMessage());%0A
             asse
@@ -1645,32 +1645,80 @@
 dException e) %7B%0A
+            System.out.println(e.getMessage());%0A
             asse
@@ -1999,32 +1999,80 @@
 dException e) %7B%0A
+            System.out.println(e.getMessage());%0A
             asse
@@ -2362,32 +2362,80 @@
 dException e) %7B%0A
+            System.out.println(e.getMessage());%0A
             asse
@@ -2693,24 +2693,24 @@
 o/gpioP1%22);%0A
-
         %7D ca
@@ -2731,32 +2731,80 @@
 dException e) %7B%0A
+            System.out.println(e.getMessage());%0A
             asse

test debug info for travis OSX build