-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1966525
commit 3911ce9
Showing
10 changed files
with
154 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package jlifx.packet; | ||
|
||
public class WifiInfoResponsePacket { | ||
private final Packet packet; | ||
public class WifiInfoResponsePacket extends Packet { | ||
|
||
public WifiInfoResponsePacket(Packet packet) { | ||
this.packet = packet; | ||
super(packet); | ||
} | ||
|
||
public float getSignalStrength() { | ||
return 0; // TODO | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package jlifx.bulb; | ||
|
||
import java.io.PrintStream; | ||
import java.util.Collections; | ||
|
||
import jlifx.commandline.AbstractBulbCommand; | ||
|
||
import org.apache.commons.io.output.ByteArrayOutputStream; | ||
import org.easymock.EasyMockSupport; | ||
|
||
public class AbstractJLifxTestCase extends EasyMockSupport { | ||
private final IBulb mockedBulb = createMock(IBulb.class); | ||
|
||
protected IBulb getMockedBulb() { | ||
return mockedBulb; | ||
} | ||
|
||
protected PrintStream getPrintStream() { | ||
return new PrintStream(new ByteArrayOutputStream()); | ||
} | ||
|
||
protected void executeCommand(AbstractBulbCommand command, IBulb bulb, String... commandArgs) throws Exception { | ||
command.execute(Collections.singletonList(bulb), commandArgs, getPrintStream()); | ||
} | ||
} |
14 changes: 4 additions & 10 deletions
14
src/test/java/jlifx/commandline/command/BlinkCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/test/java/jlifx/commandline/command/DimCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package jlifx.commandline.command; | ||
|
||
import static org.easymock.EasyMock.expectLastCall; | ||
import jlifx.bulb.AbstractJLifxTestCase; | ||
import jlifx.bulb.IBulb; | ||
|
||
import org.junit.Test; | ||
|
||
public class DimCommandTest extends AbstractJLifxTestCase { | ||
|
||
@Test | ||
public void testDimBulb() throws Exception { | ||
DimCommand command = new DimCommand(); | ||
IBulb bulb = getMockedBulb(); | ||
bulb.setDim(0.5F); | ||
expectLastCall().once(); | ||
replayAll(); | ||
|
||
executeCommand(command, bulb, "dim", "0.5"); | ||
|
||
verifyAll(); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/jlifx/commandline/command/RainbowCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package jlifx.commandline.command; | ||
|
||
import static org.easymock.EasyMock.isA; | ||
|
||
import java.awt.Color; | ||
|
||
import jlifx.bulb.AbstractJLifxTestCase; | ||
import jlifx.bulb.IBulb; | ||
|
||
import org.easymock.EasyMock; | ||
import org.junit.Test; | ||
|
||
public class RainbowCommandTest extends AbstractJLifxTestCase { | ||
|
||
@Test | ||
public void testTimed() throws Exception { | ||
IBulb bulb = getMockedBulb(); | ||
bulb.colorize(isA(Color.class), EasyMock.gt(0), EasyMock.eq(1.0F)); | ||
EasyMock.expectLastCall().atLeastOnce(); | ||
replayAll(); | ||
|
||
executeCommand(new RainbowCommand(), bulb, "duration", "2"); | ||
|
||
verifyAll(); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/jlifx/commandline/command/SwitchCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package jlifx.commandline.command; | ||
|
||
import static org.easymock.EasyMock.expectLastCall; | ||
import jlifx.bulb.AbstractJLifxTestCase; | ||
import jlifx.bulb.IBulb; | ||
|
||
import org.junit.Test; | ||
|
||
public class SwitchCommandTest extends AbstractJLifxTestCase { | ||
|
||
@Test | ||
public void testSwitchOn() throws Exception { | ||
IBulb bulb = getMockedBulb(); | ||
bulb.switchOn(); | ||
expectLastCall().once(); | ||
replayAll(); | ||
|
||
executeCommand(new SwitchCommand(), bulb, "switch", "on"); | ||
|
||
verifyAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters