Skip to content

Commit

Permalink
test cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
doom369 committed Jul 5, 2018
1 parent f6e7f4f commit 9dd695a
Show file tree
Hide file tree
Showing 33 changed files with 315 additions and 335 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void testChangeLabelPropertyViaGet() throws Exception {
clientPair.appClient.reset();

clientPair.appClient.send("loadProfileGzipped");
Profile profile = clientPair.appClient.getProfile();
Profile profile = clientPair.appClient.parseProfile(1);

Widget widget = profile.dashBoards[0].findWidgetByPin(0, (byte) 4, PinType.VIRTUAL);
assertNotNull(widget);
Expand All @@ -122,7 +122,7 @@ public void testChangeColorPropertyViaGet() throws Exception {
clientPair.appClient.reset();

clientPair.appClient.send("loadProfileGzipped");
Profile profile = clientPair.appClient.getProfile();
Profile profile = clientPair.appClient.parseProfile(1);

Widget widget = profile.dashBoards[0].findWidgetByPin(0, (byte) 4, PinType.VIRTUAL);
assertNotNull(widget);
Expand All @@ -145,7 +145,7 @@ public void testChangeOnLabelPropertyViaGet() throws Exception {

clientPair.appClient.reset();
clientPair.appClient.send("loadProfileGzipped");
Profile profile = clientPair.appClient.getProfile();
Profile profile = clientPair.appClient.parseProfile(1);

Button button = (Button) profile.dashBoards[0].findWidgetByPin(0, (byte) 2, PinType.VIRTUAL);
assertNotNull(button);
Expand All @@ -169,7 +169,7 @@ public void testChangeOffLabelPropertyViaGet() throws Exception {

clientPair.appClient.reset();
clientPair.appClient.send("loadProfileGzipped");
Profile profile = clientPair.appClient.getProfile();
Profile profile = clientPair.appClient.parseProfile(1);

Button button = (Button) profile.dashBoards[0].findWidgetByPin(0, (byte) 1, PinType.VIRTUAL);
assertNotNull(button);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public void testQRWorks() throws Exception {
}

clientPair.appClient.send("getProjectByCloneCode " + cloneToken);
DashBoard dashBoard = clientPair.appClient.getDash(2);
DashBoard dashBoard = clientPair.appClient.parseDash(2);
assertEquals("My Dashboard", dashBoard.name);
}

Expand Down Expand Up @@ -471,15 +471,15 @@ public void testIsHardwareConnecteedWithMultiDevices() throws Exception {
Device device1 = new Device(1, "My Device", "ESP8266");

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice(2);
Device device = clientPair.appClient.parseDevice(2);
assertNotNull(device);
assertNotNull(device.token);
verify(clientPair.appClient.responseMock, timeout(500)).channelRead(any(), eq(createDevice(2, device)));

clientPair.appClient.reset();

clientPair.appClient.send("getDevices 1");
Device[] devices = clientPair.appClient.getDevices();
Device[] devices = clientPair.appClient.parseDevices();

assertNotNull(devices);
assertEquals(2, devices.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public void testImprovedUploadMethodAndCheckOTAStatusForDeviceThatNeverWasOnline

clientPair.appClient.send("getDevices 1");

Device[] devices = clientPair.appClient.getDevices(2);
Device[] devices = clientPair.appClient.parseDevices(2);
assertNotNull(devices);
assertEquals(1, devices.length);
Device device = devices[0];
Expand Down Expand Up @@ -357,7 +357,7 @@ public void testImprovedUploadMethodAndCheckOTAStatusForDeviceThatWasOnline() th
verify(clientPair.hardwareClient.responseMock, timeout(500)).channelRead(any(), eq(internal(7777, "ota " + responseUrl)));

clientPair.appClient.send("getDevices 1");
Device[] devices = clientPair.appClient.getDevices(2);
Device[] devices = clientPair.appClient.parseDevices(2);

assertNotNull(devices);
assertEquals(1, devices.length);
Expand All @@ -374,7 +374,7 @@ public void testImprovedUploadMethodAndCheckOTAStatusForDeviceThatWasOnline() th
clientPair.hardwareClient.verifyResult(ok(2));

clientPair.appClient.send("getDevices 1");
devices = clientPair.appClient.getDevices(3);
devices = clientPair.appClient.parseDevices(3);

assertNotNull(devices);
assertEquals(1, devices.length);
Expand Down Expand Up @@ -466,7 +466,7 @@ public void testConnectedDeviceGotOTACommand() throws Exception {
clientPair.hardwareClient.reset();

clientPair.appClient.send("getDevices 1");
Device[] devices = clientPair.appClient.getDevices();
Device[] devices = clientPair.appClient.parseDevices();

assertNotNull(devices);
assertEquals(1, devices.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void testUpdateUser() throws Exception {
appClient.reset();

appClient.send("getDevices 1");
Device[] devices = appClient.getDevices();
Device[] devices = appClient.parseDevices();

assertNotNull(devices);
assertEquals(1, devices.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,47 +62,35 @@ public TestAppClient(String host, int port, ServerProperties properties, NioEven
this.nioEventLoopGroup = nioEventLoopGroup;
}

public Device getDevice() throws Exception {
return getDevice(1);
public Device parseDevice() throws Exception {
return parseDevice(1);
}

public Profile getProfile(int expectedMessageOrder) throws Exception {
public Profile parseProfile(int expectedMessageOrder) throws Exception {
return JsonParser.parseProfileFromString(getBody(expectedMessageOrder));
}

public Profile getProfile() throws Exception {
return getProfile(1);
}

public Device getDevice(int expectedMessageOrder) throws Exception {
public Device parseDevice(int expectedMessageOrder) throws Exception {
return JsonParser.parseDevice(getBody(expectedMessageOrder), 0);
}

public Device[] getDevices() throws Exception {
return getDevices(1);
public Device[] parseDevices() throws Exception {
return parseDevices(1);
}

public Device[] getDevices(int expectedMessageOrder) throws Exception {
public Device[] parseDevices(int expectedMessageOrder) throws Exception {
return JsonParser.MAPPER.readValue(getBody(expectedMessageOrder), Device[].class);
}

public Tag[] getTags(int expectedMessageOrder) throws Exception {
public Tag[] parseTags(int expectedMessageOrder) throws Exception {
return JsonParser.MAPPER.readValue(getBody(expectedMessageOrder), Tag[].class);
}

public App getApp(int expectedMessageOrder) throws Exception {
public App parseApp(int expectedMessageOrder) throws Exception {
return JsonParser.parseApp(getBody(expectedMessageOrder), 0);
}

public App getApp() throws Exception {
return getApp(1);
}

public DashBoard getDash() throws Exception {
return getDash(1);
}

public DashBoard getDash(int expectedMessageOrder) throws Exception {
public DashBoard parseDash(int expectedMessageOrder) throws Exception {
return JsonParser.parseDashboard(getBody(expectedMessageOrder), 0);
}

Expand All @@ -118,9 +106,9 @@ public BinaryMessage getBinaryBody() throws Exception {

@Override
public ChannelInitializer<SocketChannel> getChannelInitializer() {
return new ChannelInitializer<SocketChannel>() {
return new ChannelInitializer<>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
protected void initChannel(SocketChannel ch) {
ch.pipeline().addLast(
sslCtx.newHandler(ch.alloc(), host, port),
new AppClientMessageDecoder(),
Expand Down Expand Up @@ -275,7 +263,7 @@ public void createTemplate(int dashId, long widgetId, TileTemplate tileTemplate)
createTemplate(dashId, widgetId, JsonParser.MAPPER.writeValueAsString(tileTemplate));
}

public void createTemplate(int dashId, long widgetId, String tileTemplate) throws Exception {
public void createTemplate(int dashId, long widgetId, String tileTemplate) {
send("createTemplate " + dashId + BODY_SEPARATOR + widgetId + BODY_SEPARATOR + tileTemplate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void testSendEmailForSingleDevice() throws Exception {
appClient.verifyResult(ok(1));

clientPair.appClient.send("getDevices 1");
Device[] devices = clientPair.appClient.getDevices();
Device[] devices = clientPair.appClient.parseDevices();

assertEquals(1, devices.length);

Expand Down Expand Up @@ -121,14 +121,14 @@ public void testSendEmailForMultiDevices() throws Exception {
Device device1 = new Device(1, "My Device2", "ESP8266");

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();

assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));

clientPair.appClient.send("getDevices 1");
Device[] devices = clientPair.appClient.getDevices(2);
Device[] devices = clientPair.appClient.parseDevices(2);

appClient.send("email 1");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void testLCDOnActivateSendsCorrectBodyAdvancedMode() throws Exception {
@Test
public void testTerminalSendsSyncOnActivate() throws Exception {
clientPair.appClient.send("loadProfileGzipped");
Profile profile = clientPair.appClient.getProfile();
Profile profile = clientPair.appClient.parseProfile(1);
assertEquals(16, profile.dashBoards[0].widgets.length);

clientPair.appClient.send("getEnergy");
Expand Down Expand Up @@ -170,7 +170,7 @@ public void testTerminalSendsSyncOnActivate() throws Exception {
@Test
public void testTerminalStorageRemembersCommands() throws Exception {
clientPair.appClient.send("loadProfileGzipped");
Profile profile = clientPair.appClient.getProfile();
Profile profile = clientPair.appClient.parseProfile(1);
assertEquals(16, profile.dashBoards[0].widgets.length);

clientPair.appClient.send("getEnergy");
Expand Down Expand Up @@ -205,7 +205,7 @@ public void testTerminalStorageRemembersCommandsInNewFormat() throws Exception {
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -243,7 +243,7 @@ public void testTerminalAndAnotherWidgetOnTheSamePin() throws Exception {
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -279,7 +279,7 @@ public void testTerminalAndAnotherWidgetOnTheSamePinAndDeviceSelector() throws E
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand All @@ -293,7 +293,7 @@ public void testTerminalAndAnotherWidgetOnTheSamePinAndDeviceSelector() throws E
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -338,7 +338,7 @@ public void testTerminalAndAnotherWidgetOnTheSamePinAndDeviceSelectorAnotherOrde
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand All @@ -352,7 +352,7 @@ public void testTerminalAndAnotherWidgetOnTheSamePinAndDeviceSelectorAnotherOrde
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -397,7 +397,7 @@ public void testTerminalStorageRemembersCommandsInOldFormatAndDeviceSelector() t
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand All @@ -411,7 +411,7 @@ public void testTerminalStorageRemembersCommandsInOldFormatAndDeviceSelector() t
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -457,7 +457,7 @@ public void testTerminalStorageRemembersCommandsInNewFormatAndDeviceTiles() thro
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand All @@ -471,7 +471,7 @@ public void testTerminalStorageRemembersCommandsInNewFormatAndDeviceTiles() thro
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -521,7 +521,7 @@ public void testTerminalStorageCleanedAfterTilesAreRemoved() throws Exception {
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand All @@ -535,7 +535,7 @@ public void testTerminalStorageCleanedAfterTilesAreRemoved() throws Exception {
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -606,7 +606,7 @@ public void testTerminalStorageRemembersCommandsInNewFormatAndDeviceSelector() t
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand All @@ -620,7 +620,7 @@ public void testTerminalStorageRemembersCommandsInNewFormatAndDeviceSelector() t
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -667,7 +667,7 @@ public void testTableSyncWorkForNewCommandFormat() throws Exception {
appClient.verifyResult(ok(1));

appClient.send("loadProfileGzipped");
Profile profile = appClient.getProfile(2);
Profile profile = appClient.parseProfile(2);
assertEquals(16, profile.dashBoards[0].widgets.length);

appClient.send("getEnergy");
Expand Down Expand Up @@ -846,7 +846,7 @@ public void testSyncForDeviceSelectorAndSetProperty() throws Exception {
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand Down Expand Up @@ -891,7 +891,7 @@ public void testSyncForDeviceSelectorAndSetPropertyAndMultiValueWidget() throws
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand Down Expand Up @@ -973,7 +973,7 @@ public void testLCDOnActivateSendsCorrectBodySimpleModeAndAnotherDevice() throws
device1.status = Status.OFFLINE;

clientPair.appClient.createDevice(1, device1);
Device device = clientPair.appClient.getDevice();
Device device = clientPair.appClient.parseDevice();
assertNotNull(device);
assertNotNull(device.token);
clientPair.appClient.verifyResult(createDevice(1, device));
Expand Down
Loading

0 comments on commit 9dd695a

Please sign in to comment.