Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions src/test/java/com/bigboxer23/switch_bot/IDeviceCommandsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.bigboxer23.switch_bot;

import static org.junit.jupiter.api.Assertions.*;

import com.bigboxer23.switch_bot.data.DeviceCommand;
import org.junit.jupiter.api.Test;

public class IDeviceCommandsTest {

@Test
public void testCommandConstants() {
assertEquals("turnOff", IDeviceCommands.TURN_OFF);
assertEquals("turnOn", IDeviceCommands.TURN_ON);
}

@Test
public void testCurtainCloseCommand() {
DeviceCommand curtainClose = IDeviceCommands.CURTAIN_CLOSE;
assertNotNull(curtainClose);
assertEquals("turnOff", curtainClose.getCommand());
assertEquals("default", curtainClose.getParameter());
}

@Test
public void testCurtainOpenCommand() {
DeviceCommand curtainOpen = IDeviceCommands.CURTAIN_OPEN;
assertNotNull(curtainOpen);
assertEquals("turnOn", curtainOpen.getCommand());
assertEquals("default", curtainOpen.getParameter());
}

@Test
public void testPlugMiniOffCommand() {
DeviceCommand plugMiniOff = IDeviceCommands.PLUG_MINI_OFF;
assertNotNull(plugMiniOff);
assertEquals("turnOff", plugMiniOff.getCommand());
assertEquals("default", plugMiniOff.getParameter());
}

@Test
public void testPlugMiniOnCommand() {
DeviceCommand plugMiniOn = IDeviceCommands.PLUG_MINI_ON;
assertNotNull(plugMiniOn);
assertEquals("turnOn", plugMiniOn.getCommand());
assertEquals("default", plugMiniOn.getParameter());
}

@Test
public void testCommandConsistency() {
assertEquals(IDeviceCommands.CURTAIN_CLOSE.getCommand(), IDeviceCommands.PLUG_MINI_OFF.getCommand());
assertEquals(IDeviceCommands.CURTAIN_OPEN.getCommand(), IDeviceCommands.PLUG_MINI_ON.getCommand());

assertEquals(IDeviceCommands.CURTAIN_CLOSE.getParameter(), IDeviceCommands.CURTAIN_OPEN.getParameter());
assertEquals(IDeviceCommands.PLUG_MINI_OFF.getParameter(), IDeviceCommands.PLUG_MINI_ON.getParameter());
}

@Test
public void testCommandObjectsAreNotNull() {
assertNotNull(IDeviceCommands.CURTAIN_CLOSE);
assertNotNull(IDeviceCommands.CURTAIN_OPEN);
assertNotNull(IDeviceCommands.PLUG_MINI_OFF);
assertNotNull(IDeviceCommands.PLUG_MINI_ON);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,26 @@ public void testConcurrentCacheRefresh() throws InterruptedException {
fail("Verification failed: " + e.getMessage());
}
}

@Test
public void testSendDeviceControlCommandsInputValidation() {
DeviceCommand command = new DeviceCommand("turnOn", "default");
String deviceId = "test-device-id";

assertNotNull(command);
assertEquals("turnOn", command.getCommand());
assertEquals("default", command.getParameter());
assertNotNull(deviceId);
}

@Test
public void testGetDeviceStatusReturnsNullForNullInput() throws IOException {
Device result = deviceApi.getDeviceStatus(null);
assertNull(result);
}

@Test
public void testDeviceApiNotNull() {
assertNotNull(deviceApi);
}
}