2121
2222package com .github .devicehive .client ;
2323
24- import com .github .devicehive .client .model .*;
24+ import com .github .devicehive .client .model .CommandFilter ;
25+ import com .github .devicehive .client .model .DHResponse ;
26+ import com .github .devicehive .client .model .DeviceCommandsCallback ;
27+ import com .github .devicehive .client .model .DeviceNotification ;
28+ import com .github .devicehive .client .model .DeviceNotificationsCallback ;
29+ import com .github .devicehive .client .model .FailureData ;
30+ import com .github .devicehive .client .model .NotificationFilter ;
31+ import com .github .devicehive .client .model .Parameter ;
32+ import com .github .devicehive .client .model .TokenAuth ;
2533import com .github .devicehive .client .service .Device ;
2634import com .github .devicehive .client .service .DeviceCommand ;
2735import com .github .devicehive .client .service .DeviceHive ;
36+
2837import org .joda .time .DateTime ;
2938import org .junit .Assert ;
30- import org .junit .Ignore ;
3139import org .junit .Test ;
3240
3341import java .io .IOException ;
@@ -61,17 +69,19 @@ public class DeviceTest {
6169 @ Test
6270 public void createDevice () throws IOException {
6371 String deviceId = DEVICE_PREFIX + UUID .randomUUID ().toString ();
64- Device device = deviceHive .getDevice (deviceId );
65- Assert .assertNotNull (device );
72+ DHResponse <Device > deviceResponse = deviceHive .getDevice (deviceId );
73+ Assert .assertTrue (deviceResponse .isSuccessful ());
74+ final Device device = deviceResponse .getData ();
6675 Assert .assertTrue (device != null );
6776 Assert .assertTrue (deviceHive .removeDevice (deviceId ).isSuccessful ());
6877 }
6978
7079 @ Test
7180 public void getCommands () throws IOException {
7281 String deviceId = DEVICE_PREFIX + UUID .randomUUID ().toString ();
73- final Device device = deviceHive .getDevice (deviceId );
74- Assert .assertNotNull (device );
82+ DHResponse <Device > deviceResponse = deviceHive .getDevice (deviceId );
83+ Assert .assertTrue (deviceResponse .isSuccessful ());
84+ final Device device = deviceResponse .getData ();
7585 ScheduledExecutorService service = Executors .newScheduledThreadPool (1 );
7686 service .schedule (new Thread (new Runnable () {
7787 public void run () {
@@ -94,8 +104,9 @@ public void run() {
94104 @ Test
95105 public void subscribeCommands () throws InterruptedException {
96106 String deviceId = DEVICE_PREFIX + UUID .randomUUID ().toString ();
97- final Device device = deviceHive .getDevice (deviceId );
98- Assert .assertNotNull (device );
107+ DHResponse <Device > deviceResponse = deviceHive .getDevice (deviceId );
108+ Assert .assertTrue (deviceResponse .isSuccessful ());
109+ final Device device = deviceResponse .getData ();
99110 final ScheduledExecutorService service = Executors .newScheduledThreadPool (2 );
100111 final String commandName1 = COM_A + new Random ().nextInt ();
101112 final String commandName2 = COM_B + new Random ().nextInt ();
@@ -169,8 +180,9 @@ public void onFail(FailureData failureData) {
169180 public void subscribeNotifications () throws IOException , InterruptedException {
170181 String deviceId = DEVICE_PREFIX + UUID .randomUUID ().toString ();
171182
172- final Device device = deviceHive .getDevice (deviceId );
173- Assert .assertNotNull (device );
183+ DHResponse <Device > deviceResponse = deviceHive .getDevice (deviceId );
184+ Assert .assertTrue (deviceResponse .isSuccessful ());
185+ final Device device = deviceResponse .getData ();
174186 final CountDownLatch latch = new CountDownLatch (3 );
175187 final String notificationName1 = NOTIFICATION_A + new Random ().nextInt ();
176188 final String notificationName2 = NOTIFICATION_B + new Random ().nextInt ();
@@ -244,8 +256,9 @@ public void run() {
244256 @ Test
245257 public void getNotification () throws IOException {
246258 String deviceId = UUID .randomUUID ().toString ();
247- final Device device = deviceHive .getDevice (deviceId );
248- Assert .assertNotNull (device );
259+ DHResponse <Device > deviceResponse = deviceHive .getDevice (deviceId );
260+ Assert .assertTrue (deviceResponse .isSuccessful ());
261+ final Device device = deviceResponse .getData ();
249262 ScheduledExecutorService service = Executors .newScheduledThreadPool (1 );
250263 service .schedule (new Thread (new Runnable () {
251264 public void run () {
@@ -267,7 +280,9 @@ public void run() {
267280 @ Test
268281 public void sendNotification () throws IOException {
269282 String deviceId = DEVICE_PREFIX + UUID .randomUUID ().toString ();
270- Device device = deviceHive .getDevice (deviceId );
283+ DHResponse <Device > deviceResponse = deviceHive .getDevice (deviceId );
284+ Assert .assertTrue (deviceResponse .isSuccessful ());
285+ final Device device = deviceResponse .getData ();
271286 Assert .assertNotNull (device );
272287 List <Parameter > parameters = new ArrayList <Parameter >();
273288
0 commit comments