2 * In Samsung Ukraine R&D Center (SRK under a contract between)
3 * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
6 package com.samsung.samserver.web.rest.service.device;
8 import com.samsung.samserver.SamserverApp;
9 import com.samsung.samserver.domain.*;
10 import com.samsung.samserver.service.*;
11 import com.samsung.samserver.web.rest.errors.DeviceServiceError;
12 import com.samsung.samserver.web.rest.service.vm.Data;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.boot.test.context.SpringBootTest;
15 import org.springframework.http.ResponseEntity;
16 import org.springframework.test.context.junit4.SpringRunner;
17 import org.slf4j.Logger;
18 import org.junit.runner.RunWith;
22 import static org.mockito.Mockito.*;
25 * Test class for the SendDataRestService.
27 * @see SendDataRestService
29 @RunWith(SpringRunner.class)
30 @SpringBootTest(classes = SamserverApp.class)
31 public class SendDataRestServiceTest {
35 DeviceService deviceService;
37 ReportService reportService;
39 ReportTypeService reportTypeService;
41 AnalyzeService analyzeService;
43 UpdatesService updatesService;
46 SendDataRestService sendDataRestService;
50 MockitoAnnotations.initMocks(this);
53 @Test (expected = DeviceServiceError.DeviceNotFoundException.class)
54 public void testSendData() throws Exception {
55 when(deviceService.findOne(anyString())).thenReturn(null);
56 when(reportService.save(any())).thenReturn(new Report("data", new ReportType("name", "descr"), new Device()));
57 when(reportTypeService.save(any())).thenReturn(new ReportType("name", "descr"));
58 when(reportTypeService.findOne(anyString())).thenReturn(null);
60 ResponseEntity<Void> result = sendDataRestService.sendData("duid", new Data.DataLogs());
61 Assert.assertEquals(null, result);
64 @Test (expected = DeviceServiceError.DeviceNotFoundException.class)
65 public void testSendDataConfirm() throws Exception {
66 when(deviceService.findOne(anyString())).thenReturn(null);
68 ResponseEntity<Void> result = sendDataRestService.sendDataConfirm("duid", "uuid");
69 Assert.assertEquals(null, result);