[SECARSP-149] *server side unit tests
authorm.dalakov <m.dalakov@samsung.com>
Tue, 13 Mar 2018 15:12:04 +0000 (17:12 +0200)
committerDmytro Lomtiev <d.lomtev@samsung.com>
Fri, 16 Mar 2018 14:19:17 +0000 (16:19 +0200)
Change-Id: I32baa198509464ebc6d1fe0e8483a0f2e2133e49

24 files changed:
server/samserver/src/main/java/com/samsung/samserver/web/rest/controller/IRestDashboard.java
server/samserver/src/main/java/com/samsung/samserver/web/rest/controller/IRestDevice.java
server/samserver/src/main/java/com/samsung/samserver/web/rest/controller/impl/RestDashboard.java
server/samserver/src/main/java/com/samsung/samserver/web/rest/controller/impl/RestDevice.java
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/AccountService.java
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/UserJWTService.java
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/device/GetUpdatesRestService.java [moved from server/samserver/src/main/java/com/samsung/samserver/web/rest/service/GetUpdatesRestService.java with 80% similarity]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/device/RegisterDeviceRestService.java [moved from server/samserver/src/main/java/com/samsung/samserver/web/rest/service/RegisterDeviceRestService.java with 82% similarity]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/device/SendDataRestService.java [moved from server/samserver/src/main/java/com/samsung/samserver/web/rest/service/SendDataRestService.java with 81% similarity]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/ui/GetDevicesRestService.java
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/ui/UpdateDevicesRestService.java
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/DInfo.java [new file with mode: 0644]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/Data.java [new file with mode: 0644]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIDevice.java [new file with mode: 0644]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIDeviceUpdate.java [new file with mode: 0644]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UILogin.java [new file with mode: 0644]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIRegistration.java [new file with mode: 0644]
server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UInfo.java [new file with mode: 0644]
server/samserver/src/test/java/com/samsung/samserver/web/rest/controller/RestDashboardTest.java
server/samserver/src/test/java/com/samsung/samserver/web/rest/service/UserJWTServiceTest.java
server/samserver/src/test/java/com/samsung/samserver/web/rest/service/ui/GetDevicesRestServiceTest.java [new file with mode: 0644]
server/samserver/src/test/java/com/samsung/samserver/web/rest/service/ui/UpdateDevicesRestServiceTest.java [new file with mode: 0644]
server/samserver/src/test/java/com/samsung/samserver/web/rest/service/vm/UIDeviceTest.java [new file with mode: 0644]
server/samserver/src/test/java/com/samsung/samserver/web/rest/service/vm/UIDeviceUpdateTest.java [new file with mode: 0644]

index 7293f85..03f7d1a 100644 (file)
@@ -7,8 +7,10 @@ package com.samsung.samserver.web.rest.controller;
 
 import com.samsung.samserver.web.rest.service.*;
 import com.samsung.samserver.web.rest.errors.UserServiceError;
-import com.samsung.samserver.web.rest.service.ui.GetDevicesRestService;
-import com.samsung.samserver.web.rest.service.ui.UpdateDevicesRestService;
+import com.samsung.samserver.web.rest.service.vm.UIDevice;
+import com.samsung.samserver.web.rest.service.vm.UIDeviceUpdate;
+import com.samsung.samserver.web.rest.service.vm.UILogin;
+import com.samsung.samserver.web.rest.service.vm.UIRegistration;
 import org.springframework.data.domain.Pageable;
 import org.springframework.http.*;
 import org.springframework.web.bind.annotation.*;
@@ -38,7 +40,7 @@ public interface IRestDashboard {
     })
     @RequestMapping(value ="/devices", method = RequestMethod.GET)
     @ResponseStatus(HttpStatus.OK)
-    public ResponseEntity<List<GetDevicesRestService.UIDevice>> getAllDevices(Pageable pageable);
+    public ResponseEntity<List<UIDevice>> getAllDevices(Pageable pageable);
 
 
     /**
@@ -55,7 +57,7 @@ public interface IRestDashboard {
     @RequestMapping(value ="/auth/login", method = RequestMethod.POST)
     @ResponseStatus(HttpStatus.OK)
     public ResponseEntity<UserJWTService.JWTToken> login(
-            @Valid @ApiParam(value = "Login Data", required = true) @RequestBody UserJWTService.UILogin uiLogin);
+            @Valid @ApiParam(value = "Login Data", required = true) @RequestBody UILogin uiLogin);
 
 
     /**
@@ -75,7 +77,7 @@ public interface IRestDashboard {
     @RequestMapping(value ="/auth/register", method = RequestMethod.POST)
     @ResponseStatus(HttpStatus.CREATED)
     public void registerAccount(
-            @Valid @ApiParam(value = "Managed User", required = true) @RequestBody AccountService.UIRegistration uiRegistration);
+            @Valid @ApiParam(value = "Managed User", required = true) @RequestBody UIRegistration uiRegistration);
 
 
     /**
@@ -110,6 +112,6 @@ public interface IRestDashboard {
             @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
     })
     @RequestMapping(value ="/devices/update", method = RequestMethod.PUT)
-    public ResponseEntity<List<GetDevicesRestService.UIDevice>> updateDevice(@Valid @RequestBody UpdateDevicesRestService.UIDeviceUpdate uiDeviceUpdate);
+    public ResponseEntity<List<UIDevice>> updateDevice(@Valid @RequestBody UIDeviceUpdate uiDeviceUpdate);
 
 }
index c073867..2d18d7b 100644 (file)
@@ -5,7 +5,9 @@
  */
 package com.samsung.samserver.web.rest.controller;
 
-import com.samsung.samserver.web.rest.service.*;
+import com.samsung.samserver.web.rest.service.vm.Data;
+import com.samsung.samserver.web.rest.service.vm.DInfo;
+import com.samsung.samserver.web.rest.service.vm.UInfo;
 import org.springframework.http.*;
 import org.springframework.web.bind.annotation.*;
 import io.swagger.annotations.*;
@@ -39,7 +41,7 @@ public interface IRestDevice {
     @RequestMapping(value ="/register-device", method = RequestMethod.POST)
     @ResponseStatus(HttpStatus.OK)
     public ResponseEntity<String> registerDevice(
-        @ApiParam(value = "Device info", required = true) @Valid @RequestBody RegisterDeviceRestService.DInfo dInfo, HttpServletRequest request);
+            @ApiParam(value = "Device info", required = true) @Valid @RequestBody DInfo dInfo, HttpServletRequest request);
 
 
     /*
@@ -58,7 +60,7 @@ public interface IRestDevice {
     @RequestMapping(value ="/get-updates", method = RequestMethod.GET, produces = {
         MediaType.APPLICATION_JSON_VALUE })
     @ResponseStatus(HttpStatus.OK)
-    public ResponseEntity<List<GetUpdatesRestService.UInfo>> getUpdates(
+    public ResponseEntity<List<UInfo>> getUpdates(
         @ApiParam(value = "Device identity", required = true) @RequestParam(value = "duid") String duid);
 
 
@@ -78,7 +80,7 @@ public interface IRestDevice {
     @ResponseStatus(HttpStatus.OK)
     public ResponseEntity<Void> sendData(
         @ApiParam(value = "Device identity", required = true) @RequestParam(value = "duid") String duid,
-        @Valid @ApiParam(value = "Device Data", required = true) @RequestBody SendDataRestService.Data data);
+        @Valid @ApiParam(value = "Device Data", required = true) @RequestBody Data data);
 
 
     /*
index d6d610b..bb81475 100644 (file)
@@ -8,6 +8,10 @@ package com.samsung.samserver.web.rest.controller.impl;
 import com.samsung.samserver.web.rest.controller.IRestDashboard;
 import com.samsung.samserver.web.rest.service.*;
 import com.samsung.samserver.web.rest.service.ui.*;
+import com.samsung.samserver.web.rest.service.vm.UIDevice;
+import com.samsung.samserver.web.rest.service.vm.UIDeviceUpdate;
+import com.samsung.samserver.web.rest.service.vm.UILogin;
+import com.samsung.samserver.web.rest.service.vm.UIRegistration;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Pageable;
 import org.springframework.http.*;
@@ -42,7 +46,7 @@ public class RestDashboard  implements IRestDashboard {
      * @return the ResponseEntity with status 200 (OK) and the list of devices in body
      */
     @Override
-    public ResponseEntity<List<GetDevicesRestService.UIDevice>> getAllDevices(Pageable pageable) {
+    public ResponseEntity<List<UIDevice>> getAllDevices(Pageable pageable) {
         return getDevicesRestService.getAllDevices(pageable);
     }
 
@@ -52,7 +56,7 @@ public class RestDashboard  implements IRestDashboard {
      * @return the ResponseEntity with status 200 (OK) and JWT
      */
     @Override
-    public ResponseEntity<UserJWTService.JWTToken> login(@Valid @RequestBody UserJWTService.UILogin uiLogin) {
+    public ResponseEntity<UserJWTService.JWTToken> login(@Valid @RequestBody UILogin uiLogin) {
         return userJWTService.authorize(uiLogin);
     }
 
@@ -62,7 +66,7 @@ public class RestDashboard  implements IRestDashboard {
      * @param uiRegistration the managed user View Model
      */
     @Override
-    public void registerAccount(@Valid @RequestBody AccountService.UIRegistration uiRegistration){
+    public void registerAccount(@Valid @RequestBody UIRegistration uiRegistration){
         accountService.registerAccount(uiRegistration);
     }
 
@@ -84,7 +88,7 @@ public class RestDashboard  implements IRestDashboard {
      * or with status 400 (Bad Request) if the uiDeviceUpdate is not valid
      */
     @Override
-    public ResponseEntity<List<GetDevicesRestService.UIDevice>> updateDevice(@Valid @RequestBody UpdateDevicesRestService.UIDeviceUpdate uiDeviceUpdate) {
+    public ResponseEntity<List<UIDevice>> updateDevice(@Valid @RequestBody UIDeviceUpdate uiDeviceUpdate) {
         return updateDevicesRestService.updateDevice(uiDeviceUpdate);
     }
 
index fadc48d..b0646cb 100644 (file)
@@ -6,7 +6,12 @@
 package com.samsung.samserver.web.rest.controller.impl;
 
 import com.samsung.samserver.web.rest.controller.IRestDevice;
-import com.samsung.samserver.web.rest.service.*;
+import com.samsung.samserver.web.rest.service.vm.Data;
+import com.samsung.samserver.web.rest.service.device.GetUpdatesRestService;
+import com.samsung.samserver.web.rest.service.device.RegisterDeviceRestService;
+import com.samsung.samserver.web.rest.service.device.SendDataRestService;
+import com.samsung.samserver.web.rest.service.vm.DInfo;
+import com.samsung.samserver.web.rest.service.vm.UInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
@@ -34,18 +39,18 @@ public class RestDevice implements IRestDevice {
     private SendDataRestService sendDataRestService;
 
     @Override
-    public ResponseEntity<String> registerDevice(@Valid @RequestBody RegisterDeviceRestService.DInfo dInfo, HttpServletRequest request) {
+    public ResponseEntity<String> registerDevice(@Valid @RequestBody DInfo dInfo, HttpServletRequest request) {
         return registerDeviceRestService.registerDevice(dInfo, request);
     }
 
     @Override
-    public ResponseEntity<List<GetUpdatesRestService.UInfo>> getUpdates(@RequestParam(value = "duid") String duid){
+    public ResponseEntity<List<UInfo>> getUpdates(@RequestParam(value = "duid") String duid){
         return getUpdatesRestService.getUpdates(duid);
     }
 
     @Override
     public ResponseEntity<Void> sendData(@RequestParam(value = "duid") String duid,
-                                         @Valid @RequestBody SendDataRestService.Data data) {
+                                         @Valid @RequestBody Data data) {
         return sendDataRestService.sendData(duid, data);
     }
 
index 18dbdb3..02e72bb 100644 (file)
@@ -11,9 +11,8 @@ import com.samsung.samserver.security.SecurityUtils;
 import com.samsung.samserver.service.impl.*;
 import com.samsung.samserver.service.dto.UserDTO;
 import com.samsung.samserver.web.rest.errors.*;
+import com.samsung.samserver.web.rest.service.vm.UIRegistration;
 import org.apache.commons.lang3.StringUtils;
-import org.hibernate.validator.constraints.Email;
-import org.hibernate.validator.constraints.NotBlank;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.*;
 import org.slf4j.*;
@@ -203,23 +202,4 @@ public class AccountService {
         private String password;
     }
 
-    /**
-     * View Model for UI registration .
-     */
-    @Getter @Setter @ToString
-    public static class UIRegistration {
-
-        @NotBlank
-        private String fullName;
-
-        @NotBlank
-        @Email
-        private String email;
-
-        @NotBlank
-        private String password;
-
-        private String confirmPassword;
-    }
-
 }
\ No newline at end of file
index 2d03855..a409a43 100644 (file)
@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 import com.samsung.samserver.security.jwt.*;
 import com.samsung.samserver.service.impl.UserService;
 import com.samsung.samserver.web.rest.errors.InternalServerErrorException;
-import org.hibernate.validator.constraints.NotBlank;
+import com.samsung.samserver.web.rest.service.vm.UILogin;
 import org.springframework.http.*;
 import org.springframework.security.authentication.*;
 import org.springframework.security.core.Authentication;
@@ -100,29 +100,4 @@ public class UserJWTService {
         }
     }
 
-     /**
-     * View Model for UI login.
-     */
-    @Getter @Setter @ToString
-    public static class UILogin {
-
-        @NotBlank
-        private String email;
-
-        @NotBlank
-        private String password;
-
-        @Getter(AccessLevel.NONE)
-        @Setter(AccessLevel.NONE)
-        private boolean rememberMe;
-
-        public Boolean getRememberMe() {
-             return rememberMe;
-         }
-
-        public void setRememberMe(Boolean rememberMe) {
-             this.rememberMe = rememberMe;
-         }
-    }
-
 }
@@ -3,18 +3,18 @@
  * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
  */
-package com.samsung.samserver.web.rest.service;
+package com.samsung.samserver.web.rest.service.device;
 
 import com.samsung.samserver.domain.*;
 import com.samsung.samserver.service.*;
 import com.samsung.samserver.web.rest.errors.DeviceServiceError;
+import com.samsung.samserver.web.rest.service.vm.UInfo;
 import org.slf4j.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.*;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestParam;
 import java.util.*;
-import lombok.*;
 
 /**
  * REST service implementation for get updates.
@@ -72,28 +72,4 @@ public class GetUpdatesRestService {
                 .body(updates.get().getData());
     }
 
-    /**
-     * View Model for Update Info for device.
-     */
-    @Getter @Setter @ToString
-    public static class UInfo {
-
-        private String type;
-        private String uri;
-        private String curi;
-        private String rDate;
-        private String descr;
-
-        public UInfo() {
-        }
-
-        UInfo(String type, String uri, String curi, String rDate, String descr) {
-            this.type = type;
-            this.uri = uri;
-            this.curi = curi;
-            this.rDate = rDate;
-            this.descr = descr;
-        }
-    }
-
 }
@@ -3,8 +3,9 @@
  * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
  */
-package com.samsung.samserver.web.rest.service;
+package com.samsung.samserver.web.rest.service.device;
 
+import com.samsung.samserver.web.rest.service.vm.DInfo;
 import org.slf4j.*;
 import org.springframework.http.*;
 import org.springframework.stereotype.Service;
@@ -14,10 +15,8 @@ import com.samsung.samserver.service.*;
 import com.samsung.samserver.web.rest.errors.DeviceServiceError;
 import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
 import java.time.Instant;
 import java.util.Optional;
-import lombok.*;
 
 /**
  * REST service implementation for register device.
@@ -66,28 +65,4 @@ public class RegisterDeviceRestService {
             .body(result.getDuid());
     }
 
-    /**
-     * View Model for Device Info to registration.
-     */
-    @Getter @Setter @ToString
-    public static class DInfo {
-
-        @NotNull
-        private String type;
-
-        @NotNull
-        private String model;
-
-        @NotNull
-        private String sn;
-
-        private String sw;
-
-        @NotNull
-        private String osname;
-
-        @NotNull
-        private String osver;
-    }
-
 }
@@ -3,21 +3,19 @@
  * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
  */
-package com.samsung.samserver.web.rest.service;
+package com.samsung.samserver.web.rest.service.device;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
 import com.samsung.samserver.domain.*;
 import com.samsung.samserver.service.*;
 import com.samsung.samserver.web.rest.errors.DeviceServiceError;
+import com.samsung.samserver.web.rest.service.vm.Data;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.*;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.*;
 import org.slf4j.*;
 import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
 import java.util.*;
-import lombok.*;
 
 /**
  *  REST service implementation for send data.
@@ -54,7 +52,7 @@ public class SendDataRestService {
         }
 
         if (data.getType().equals("report")) {
-            for (Logs l: data.getLogs()) {
+            for (Data.Logs l: data.getLogs()) {
                 String reportTypeName = l.getModule();
                 Device device = d.get();
                 Optional<ReportType> reportType =  reportTypeService.findOne(reportTypeName);
@@ -85,29 +83,4 @@ public class SendDataRestService {
         return ResponseEntity.ok().headers(new HttpHeaders()).build();
     }
 
-    /**
-     * View Model for Device to send reports.
-     */
-    @Getter @Setter @ToString
-    public static class Data {
-
-        @NotNull
-        private String type;
-
-        private String ctime;
-
-        @Valid
-        @NotNull
-        @JsonProperty("data")
-        private List<Logs> logs;
-    }
-
-    @Getter @Setter @ToString
-    static class Logs {
-        @NotNull
-        private String module;
-        @NotNull
-        private String log;
-    }
-
 }
index 45011f2..cfc2ef9 100644 (file)
@@ -5,21 +5,17 @@
  */
 package com.samsung.samserver.web.rest.service.ui;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
 import com.samsung.samserver.domain.Device;
 import com.samsung.samserver.service.DeviceService;
 import com.samsung.samserver.service.impl.GeoIPService;
+import com.samsung.samserver.web.rest.service.vm.UIDevice;
 import com.samsung.samserver.web.rest.util.PaginationUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
 import org.springframework.stereotype.Service;
 import org.springframework.http.*;
 import org.slf4j.*;
-import java.time.Instant;
 import java.util.*;
-import lombok.*;
-
-import static com.samsung.samserver.service.impl.GeoIPService.GeoIP;
 
 /**
  * REST service implementation for get updates.
@@ -38,10 +34,10 @@ public class GetDevicesRestService {
     @Autowired
     private GeoIPService geoIPService;
 
-    public ResponseEntity<List<GetDevicesRestService.UIDevice>> getAllDevices(Pageable pageable) {
+    public ResponseEntity<List<UIDevice>> getAllDevices(Pageable pageable) {
         log.debug("UI request to get all devices"); //NOSONAR
         Page<Device> devices = deviceService.findAll(pageable);
-        List<GetDevicesRestService.UIDevice> uiDevices = new ArrayList<>();
+        List<UIDevice> uiDevices = new ArrayList<>();
         for (Device device: devices) {
             UIDevice uiDevice = new UIDevice();
             uiDevice.setId(device.getId());
@@ -52,8 +48,8 @@ public class GetDevicesRestService {
             uiDevice.setSn(device.getSn());
             uiDevice.setDescr(device.getDescr());
             uiDevice.setLocked(device.getLocked()!=null && !device.getLocked().equals("0") ? 1:0);
-            uiDevice.setUiDeviceOS(new UIDeviceOS(device.getSw(), device.getOsname(), device.getOsver()));
-            uiDevice.setUiDeviceType(new UIDeviceType (device.getDtype().getName(), device.getDtype().getDescr()));
+            uiDevice.setUiDeviceOS(new UIDevice.UIDeviceOS(device.getSw(), device.getOsname(), device.getOsver()));
+            uiDevice.setUiDeviceType(new UIDevice.UIDeviceType(device.getDtype().getName(), device.getDtype().getDescr()));
             uiDevice.setGeoIP(geoIPService.getGeo(device.getIpaddr()));
             uiDevices.add(uiDevice);
         }
@@ -62,57 +58,4 @@ public class GetDevicesRestService {
         return new ResponseEntity<>(page.getContent() , headers, HttpStatus.OK);
     }
 
-    /**
-     * View Model for UI Device.
-     */
-    @Getter @Setter @ToString
-    public static class UIDevice {
-
-        private Long id;
-        private String duid;
-        private Instant ctime;
-        private String model;
-        private String ipaddr;
-        private String sn;
-        private String descr;
-        private Integer locked;
-
-        @JsonProperty("type")
-        private UIDeviceType uiDeviceType;
-
-        @JsonProperty("os")
-        private UIDeviceOS uiDeviceOS;
-
-        @JsonProperty("geo")
-        private GeoIP geoIP;
-    }
-
-    @Getter @Setter @ToString
-    static class UIDeviceType {
-        private String name;
-        private String descr;
-        UIDeviceType(String name, String descr) {
-            this.name = name;
-            this.descr = descr;
-        }
-    }
-
-    @Getter @Setter @ToString
-    static class UIDeviceOS {
-
-        private String sw;
-
-        @JsonProperty("name")
-        private String osname;
-
-        @JsonProperty("version")
-        private String osver;
-
-        UIDeviceOS(String sw, String osname, String osver) {
-            this.sw = sw;
-            this.osname = osname;
-            this.osver = osver;
-        }
-    }
-
 }
\ No newline at end of file
index c5507b7..5efc8a9 100644 (file)
@@ -6,18 +6,16 @@
 package com.samsung.samserver.web.rest.service.ui;
 
 import com.samsung.samserver.domain.Device;
-import com.samsung.samserver.service.DeviceService;
-import com.samsung.samserver.service.LockService;
+import com.samsung.samserver.service.*;
 import com.samsung.samserver.service.impl.GeoIPService;
+import com.samsung.samserver.web.rest.service.vm.*;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.*;
 import org.slf4j.*;
 import javax.validation.Valid;
-import javax.validation.constraints.*;
 import java.util.*;
-import lombok.*;
 
 /**
  * REST service implementation for get updates.
@@ -39,17 +37,17 @@ public class UpdateDevicesRestService {
     @Autowired
     private LockService lockService;
 
-    public ResponseEntity<List<GetDevicesRestService.UIDevice>> updateDevice(@Valid @RequestBody UpdateDevicesRestService.UIDeviceUpdate uiDeviceUpdate) {
+    public ResponseEntity<List<UIDevice>> updateDevice(@Valid @RequestBody UIDeviceUpdate uiDeviceUpdate) {
         log.debug("UI request to update devices : {}", uiDeviceUpdate);
         int c = 0;
-        ArrayList<GetDevicesRestService.UIDevice> uiDevices = new ArrayList<>();
-        List<UIDeviceUpdateOne> updates = uiDeviceUpdate.getUpdates();
-        for (UIDeviceUpdateOne update: updates) {
+        ArrayList<UIDevice> uiDevices = new ArrayList<>();
+        List<UIDeviceUpdate.UIDeviceUpdateOne> updates = uiDeviceUpdate.getUpdates();
+        for (UIDeviceUpdate.UIDeviceUpdateOne update: updates) {
             Device device =  deviceService.findOne(update.getId());
             if (device!=null) {
                 device.setLocked(update.getLocked().toString());
                 deviceService.save(device);
-                GetDevicesRestService.UIDevice uiDevice = new GetDevicesRestService.UIDevice();
+                UIDevice uiDevice = new UIDevice();
                 uiDevice.setId(device.getId());
                 uiDevice.setDuid(device.getDuid());
                 uiDevice.setCtime(device.getCtime());
@@ -58,8 +56,8 @@ public class UpdateDevicesRestService {
                 uiDevice.setSn(device.getSn());
                 uiDevice.setDescr(device.getDescr());
                 uiDevice.setLocked(device.getLocked()!=null && !device.getLocked().equals("0") ? 1:0);
-                uiDevice.setUiDeviceOS(new GetDevicesRestService.UIDeviceOS(device.getSw(), device.getOsname(), device.getOsver()));
-                uiDevice.setUiDeviceType(new GetDevicesRestService.UIDeviceType(device.getDtype().getName(), device.getDtype().getDescr()));
+                uiDevice.setUiDeviceOS(new UIDevice.UIDeviceOS(device.getSw(), device.getOsname(), device.getOsver()));
+                uiDevice.setUiDeviceType(new UIDevice.UIDeviceType(device.getDtype().getName(), device.getDtype().getDescr()));
                 uiDevice.setGeoIP(geoIPService.getGeo(device.getIpaddr()));
                 uiDevices.add(uiDevice);
                 lockService.update(device);
@@ -72,23 +70,4 @@ public class UpdateDevicesRestService {
         return new ResponseEntity<>(uiDevices , httpHeaders, hs);
     }
 
-    /**
-     * View Model for UI Device update.
-     */
-    @Getter @Setter @ToString
-    public static class UIDeviceUpdate {
-        @Valid
-        @NotNull
-        private List<UIDeviceUpdateOne> updates;
-    }
-
-    @Getter @Setter @ToString
-    static class UIDeviceUpdateOne {
-        @NotNull
-        private Long id;
-        @NotNull
-        @Max(1) @Min(0)
-        private Integer locked;
-    }
-
 }
\ No newline at end of file
diff --git a/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/DInfo.java b/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/DInfo.java
new file mode 100644 (file)
index 0000000..167367b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import lombok.*;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * View Model for Device Info to registration.
+ *
+ * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
+ * @version 1.0
+ */
+@Getter
+@Setter
+@ToString
+public class DInfo {
+
+    @NotNull
+    private String type;
+
+    @NotNull
+    private String model;
+
+    @NotNull
+    private String sn;
+
+    private String sw;
+
+    @NotNull
+    private String osname;
+
+    @NotNull
+    private String osver;
+}
\ No newline at end of file
diff --git a/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/Data.java b/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/Data.java
new file mode 100644 (file)
index 0000000..6dd9ec5
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+import lombok.*;
+
+/**
+ * View Model for Device to send reports.
+ *
+ * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
+ * @version 1.0
+ */
+@Getter
+@Setter
+@ToString
+public class Data {
+
+    @NotNull
+    private String type;
+
+    private String ctime;
+
+    @Valid
+    @NotNull
+    @JsonProperty("data")
+    private List<Logs> logs;
+
+    @Getter @Setter @ToString
+    public static class Logs {
+        @NotNull
+        private String module;
+        @NotNull
+        private String log;
+    }
+}
diff --git a/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIDevice.java b/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIDevice.java
new file mode 100644 (file)
index 0000000..ad54de7
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.samsung.samserver.service.impl.GeoIPService;
+import java.time.Instant;
+import lombok.*;
+
+/**
+ * View Model for UI Device.
+ *
+ * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
+ * @version 1.0
+ */
+@Getter
+@Setter
+@ToString
+public class UIDevice {
+
+    private Long id;
+    private String duid;
+    private Instant ctime;
+    private String model;
+    private String ipaddr;
+    private String sn;
+    private String descr;
+    private Integer locked;
+
+    @JsonProperty("type")
+    private UIDeviceType uiDeviceType;
+
+    @JsonProperty("os")
+    private UIDeviceOS uiDeviceOS;
+
+    @JsonProperty("geo")
+    private GeoIPService.GeoIP geoIP;
+
+    @Getter @Setter @ToString
+    public static class UIDeviceType {
+        private String name;
+        private String descr;
+        public UIDeviceType(String name, String descr) {
+            this.name = name;
+            this.descr = descr;
+        }
+    }
+
+    @Getter @Setter @ToString
+    public static class UIDeviceOS {
+
+        private String sw;
+
+        @JsonProperty("name")
+        private String osname;
+
+        @JsonProperty("version")
+        private String osver;
+
+        public UIDeviceOS(String sw, String osname, String osver) {
+            this.sw = sw;
+            this.osname = osname;
+            this.osver = osver;
+        }
+    }
+}
diff --git a/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIDeviceUpdate.java b/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIDeviceUpdate.java
new file mode 100644 (file)
index 0000000..0cfcf01
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import javax.validation.constraints.*;
+import javax.validation.Valid;
+import java.util.List;
+import lombok.*;
+
+/**
+ * View Model for UI Device update.
+ *
+ * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
+ * @version 1.0
+ */
+@Getter
+@Setter
+@ToString
+public class UIDeviceUpdate {
+    @Valid
+    @NotNull
+    private List<UIDeviceUpdateOne> updates;
+
+    @Getter @Setter @ToString
+    public static class UIDeviceUpdateOne {
+        @NotNull
+        private Long id;
+        @NotNull
+        @Max(1) @Min(0)
+        private Integer locked;
+    }
+}
diff --git a/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UILogin.java b/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UILogin.java
new file mode 100644 (file)
index 0000000..0b6612f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import org.hibernate.validator.constraints.NotBlank;
+import lombok.*;
+
+/**
+ * View Model for UI login.
+ *
+ * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
+ * @version 1.0
+ */
+@Getter
+@Setter
+@ToString
+public class UILogin {
+
+   @NotBlank
+   private String email;
+
+   @NotBlank
+   private String password;
+
+   @Getter(AccessLevel.NONE)
+   @Setter(AccessLevel.NONE)
+   private boolean rememberMe;
+
+   public Boolean getRememberMe() {
+        return rememberMe;
+    }
+
+   public void setRememberMe(Boolean rememberMe) {
+        this.rememberMe = rememberMe;
+    }
+}
diff --git a/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIRegistration.java b/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UIRegistration.java
new file mode 100644 (file)
index 0000000..ab91114
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import org.hibernate.validator.constraints.*;
+import lombok.*;
+
+/**
+ * View Model for UI registration .
+ *
+ * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
+ * @version 1.0
+ */
+@Getter
+@Setter
+@ToString
+public class UIRegistration {
+
+    @NotBlank
+    private String fullName;
+
+    @NotBlank
+    @Email
+    private String email;
+
+    @NotBlank
+    private String password;
+
+    private String confirmPassword;
+}
diff --git a/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UInfo.java b/server/samserver/src/main/java/com/samsung/samserver/web/rest/service/vm/UInfo.java
new file mode 100644 (file)
index 0000000..ee9cbb2
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import lombok.*;
+
+/**
+ * View Model for get updates for device.
+ *
+ * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
+ * @version 1.0
+ */
+@Getter
+@Setter
+@ToString
+public class UInfo {
+
+    private String type;
+    private String uri;
+    private String curi;
+    private String rDate;
+    private String descr;
+
+    public UInfo() {
+    }
+
+    public UInfo(String type, String uri, String curi, String rDate, String descr) {
+        this.type = type;
+        this.uri = uri;
+        this.curi = curi;
+        this.rDate = rDate;
+        this.descr = descr;
+    }
+}
index be82107..83e0909 100644 (file)
@@ -14,8 +14,8 @@ import com.samsung.samserver.service.dto.UserDTO;
 import com.samsung.samserver.web.rest.TestUtil;
 import com.samsung.samserver.web.rest.controller.impl.RestDashboard;
 import com.samsung.samserver.web.rest.errors.ExceptionTranslator;
-import com.samsung.samserver.web.rest.service.AccountService;
-import com.samsung.samserver.web.rest.service.UserJWTService;
+import com.samsung.samserver.web.rest.service.vm.UILogin;
+import com.samsung.samserver.web.rest.service.vm.UIRegistration;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.junit.Before;
 import org.junit.Test;
@@ -80,7 +80,7 @@ public class RestDashboardTest {
 
         userRepository.saveAndFlush(user);
 
-        UserJWTService.UILogin login = new UserJWTService.UILogin();
+        UILogin login = new UILogin();
         login.setEmail("dashboard-user@example.com");
         login.setPassword("test");
         mockMvc.perform(post("/dashboard/auth/login")
@@ -104,7 +104,7 @@ public class RestDashboardTest {
 
         userRepository.saveAndFlush(user);
 
-        UserJWTService.UILogin login = new UserJWTService.UILogin();
+        UILogin login = new UILogin();
         login.setEmail("dashboard-user-remember-me@example.com");
         login.setPassword("test");
         login.setRememberMe(true);
@@ -121,7 +121,7 @@ public class RestDashboardTest {
     @Test
     @Transactional
     public void testAuthorizeFails() throws Exception {
-        UserJWTService.UILogin login = new UserJWTService.UILogin();
+        UILogin login = new UILogin();
         login.setEmail("wrong-user@example.com");
         login.setPassword("wrong password");
         mockMvc.perform(post("/dashboard/auth/login")
@@ -135,7 +135,7 @@ public class RestDashboardTest {
     @Test
     @Transactional
     public void testRegisterValid() throws Exception {
-        AccountService.UIRegistration uiRegistration = new AccountService.UIRegistration();
+        UIRegistration uiRegistration = new UIRegistration();
         uiRegistration.setEmail("dashboard-user@example.com");
         uiRegistration.setPassword(passwordEncoder.encode("test"));
         uiRegistration.setFullName("dashboard-user-fullName");
@@ -154,7 +154,7 @@ public class RestDashboardTest {
     //@Test
     @Transactional
     public void testRegisterInvalidLogin() throws Exception {
-        AccountService.UIRegistration uiRegistration = new AccountService.UIRegistration();
+        UIRegistration uiRegistration = new UIRegistration();
         uiRegistration.setEmail("funky-log!n@example.com");
         uiRegistration.setPassword(passwordEncoder.encode("test"));
         uiRegistration.setFullName("Funky-fullName");
@@ -172,7 +172,7 @@ public class RestDashboardTest {
     //@Test
     @Transactional
     public void testRegisterInvalidPassword() throws Exception {
-        AccountService.UIRegistration uiRegistration = new AccountService.UIRegistration();
+        UIRegistration uiRegistration = new UIRegistration();
         uiRegistration.setEmail("dashboard-user@example.com");
         uiRegistration.setPassword(passwordEncoder.encode("123"));
         uiRegistration.setFullName("dashboard-user-fullName");
@@ -190,7 +190,7 @@ public class RestDashboardTest {
     @Test
     @Transactional
     public void testRegisterNullPassword() throws Exception {
-        AccountService.UIRegistration uiRegistration = new AccountService.UIRegistration();
+        UIRegistration uiRegistration = new UIRegistration();
         uiRegistration.setEmail("dashboard-user@example.com");
         uiRegistration.setPassword(null);// invalid null password
         uiRegistration.setFullName("dashboard-user-fullName");
@@ -209,13 +209,13 @@ public class RestDashboardTest {
     @Transactional
     public void testRegisterDuplicateEmail() throws Exception {
         // Good
-        AccountService.UIRegistration uiRegistration = new AccountService.UIRegistration();
+        UIRegistration uiRegistration = new UIRegistration();
         uiRegistration.setEmail("dashboard-user@example.com");
         uiRegistration.setPassword(passwordEncoder.encode("test"));
         uiRegistration.setFullName("dashboard-user-fullName");
 
         // Duplicate email
-        AccountService.UIRegistration duplicatedRegistration = new AccountService.UIRegistration();
+        UIRegistration duplicatedRegistration = new UIRegistration();
         duplicatedRegistration.setEmail("dashboard-user@example.com");
         duplicatedRegistration.setPassword(passwordEncoder.encode("test"));
         duplicatedRegistration.setFullName("dashboard-user-fullName");
@@ -235,7 +235,7 @@ public class RestDashboardTest {
                 .andExpect(status().is4xxClientError());
 
         // Duplicate email - with uppercase email address
-        AccountService.UIRegistration duplicatedWithUpperCaseEmailRegistration = new AccountService.UIRegistration();
+        UIRegistration duplicatedWithUpperCaseEmailRegistration = new UIRegistration();
         duplicatedWithUpperCaseEmailRegistration.setEmail(uiRegistration.getEmail().toUpperCase());
         duplicatedWithUpperCaseEmailRegistration.setPassword(passwordEncoder.encode("test"));
         duplicatedWithUpperCaseEmailRegistration.setFullName("dashboard-user-fullName");
index ebd40ef..2a15153 100644 (file)
@@ -10,6 +10,7 @@ import com.samsung.samserver.repository.UserRepository;
 import com.samsung.samserver.security.jwt.TokenProvider;
 import com.samsung.samserver.service.impl.UserService;
 import com.samsung.samserver.SamserverApp;
+import com.samsung.samserver.web.rest.service.vm.UILogin;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -66,7 +67,7 @@ public class UserJWTServiceTest {
 
         userRepository.saveAndFlush(user);
 
-        UserJWTService.UILogin login = new UserJWTService.UILogin();
+        UILogin login = new UILogin();
         login.setEmail("user-jwt-service@example.com");
         login.setPassword("test");
         ResponseEntity<UserJWTService.JWTToken> responseEntity = userJWTService.authorize(login);
@@ -86,7 +87,7 @@ public class UserJWTServiceTest {
 
         userRepository.saveAndFlush(user);
 
-        UserJWTService.UILogin login = new UserJWTService.UILogin();
+        UILogin login = new UILogin();
         login.setEmail("user-jwt-service-remember-me@example.com");
         login.setPassword("test");
         login.setRememberMe(true);
@@ -99,7 +100,7 @@ public class UserJWTServiceTest {
     @Test(expected = BadCredentialsException.class)
     @Transactional
     public void testAuthorizeFails() throws Exception {
-        UserJWTService.UILogin login = new UserJWTService.UILogin();
+        UILogin login = new UILogin();
         login.setEmail("wrong-user@example.com");
         login.setPassword("wrong password");
         ResponseEntity<UserJWTService.JWTToken> responseEntity = userJWTService.authorize(login);
diff --git a/server/samserver/src/test/java/com/samsung/samserver/web/rest/service/ui/GetDevicesRestServiceTest.java b/server/samserver/src/test/java/com/samsung/samserver/web/rest/service/ui/GetDevicesRestServiceTest.java
new file mode 100644 (file)
index 0000000..209a1c0
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.ui;
+
+import com.samsung.samserver.service.DeviceService;
+import com.samsung.samserver.service.impl.GeoIPService;
+import com.samsung.samserver.web.rest.service.vm.UIDevice;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.*;
+import org.junit.*;
+import org.mockito.*;
+import org.slf4j.Logger;
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * Test class for the GetDevicesRestService.
+ *
+ * @see GetDevicesRestService
+ */
+public class GetDevicesRestServiceTest {
+    @Mock
+    Logger log;
+    @Mock
+    DeviceService deviceService;
+    @Mock
+    GeoIPService geoIPService;
+    @InjectMocks
+    GetDevicesRestService getDevicesRestService;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void testGetAllDevices() throws Exception {
+        when(deviceService.findAll(any())).thenReturn(null);
+        when(geoIPService.getGeo(any())).thenReturn(null);
+
+        //ResponseEntity<List<UIDevice>> result = getDevicesRestService.getAllDevices(new PageRequest(0,1));
+        //Assert.assertEquals(HttpStatus.OK, result.getStatusCode());
+    }
+}
diff --git a/server/samserver/src/test/java/com/samsung/samserver/web/rest/service/ui/UpdateDevicesRestServiceTest.java b/server/samserver/src/test/java/com/samsung/samserver/web/rest/service/ui/UpdateDevicesRestServiceTest.java
new file mode 100644 (file)
index 0000000..14a24d9
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.ui;
+
+import com.samsung.samserver.domain.Device;
+import com.samsung.samserver.service.*;
+import com.samsung.samserver.service.impl.GeoIPService;
+import com.samsung.samserver.web.rest.service.vm.*;
+import org.springframework.http.*;
+import org.junit.*;
+import org.mockito.*;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * Test class for the UpdateDevicesRestService.
+ *
+ * @see UpdateDevicesRestService
+ */
+public class UpdateDevicesRestServiceTest {
+    @Mock
+    Logger log;
+    @Mock
+    DeviceService deviceService;
+    @Mock
+    GeoIPService geoIPService;
+    @Mock
+    LockService lockService;
+    @InjectMocks
+    UpdateDevicesRestService updateDevicesRestService;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void testUpdateDevice() throws Exception {
+        when(deviceService.save(any())).thenReturn(new Device());
+        when(deviceService.findOne(anyLong())).thenReturn(new Device());
+        when(geoIPService.getGeo(any())).thenReturn(null);
+
+        UIDeviceUpdate uiDeviceUpdate = new UIDeviceUpdate();
+        uiDeviceUpdate.setUpdates(new ArrayList<>());
+        ResponseEntity<List<UIDevice>> result = updateDevicesRestService.updateDevice(uiDeviceUpdate);
+
+        Assert.assertEquals(HttpStatus.OK, result.getStatusCode());
+    }
+}
diff --git a/server/samserver/src/test/java/com/samsung/samserver/web/rest/service/vm/UIDeviceTest.java b/server/samserver/src/test/java/com/samsung/samserver/web/rest/service/vm/UIDeviceTest.java
new file mode 100644 (file)
index 0000000..796ca14
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import com.samsung.samserver.service.impl.GeoIPService;
+import org.junit.*;
+import org.mockito.*;
+
+/**
+ * Test class for the UIDevice.
+ *
+ * @see UIDevice
+ */
+public class UIDeviceTest {
+    //Field ctime of type Instant - was not mocked since Mockito doesn't mock a Final class when 'mock-maker-inline' option is not set
+    @Mock
+    UIDevice.UIDeviceType uiDeviceType;
+    @Mock
+    UIDevice.UIDeviceOS uiDeviceOS;
+    @Mock
+    GeoIPService.GeoIP geoIP;
+    @InjectMocks
+    UIDevice uIDevice;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void testSetId() throws Exception {
+        uIDevice.setId(Long.valueOf(1));
+    }
+
+    @Test
+    public void testSetDuid() throws Exception {
+        uIDevice.setDuid("duid");
+    }
+
+    @Test
+    public void testSetCtime() throws Exception {
+        uIDevice.setCtime(null);
+    }
+
+    @Test
+    public void testSetModel() throws Exception {
+        uIDevice.setModel("model");
+    }
+
+    @Test
+    public void testSetIpaddr() throws Exception {
+        uIDevice.setIpaddr("ipaddr");
+    }
+
+    @Test
+    public void testSetSn() throws Exception {
+        uIDevice.setSn("sn");
+    }
+
+    @Test
+    public void testSetDescr() throws Exception {
+        uIDevice.setDescr("descr");
+    }
+
+    @Test
+    public void testSetLocked() throws Exception {
+        uIDevice.setLocked(Integer.valueOf(0));
+    }
+
+    @Test
+    public void testSetUiDeviceType() throws Exception {
+        uIDevice.setUiDeviceType(new UIDevice.UIDeviceType("name", "descr"));
+    }
+
+    @Test
+    public void testSetUiDeviceOS() throws Exception {
+        uIDevice.setUiDeviceOS(new UIDevice.UIDeviceOS("sw", "osname", "osver"));
+    }
+
+    @Test
+    public void testSetGeoIP() throws Exception {
+        uIDevice.setGeoIP(null);
+    }
+
+    @Test
+    public void testToString() throws Exception {
+        String result = uIDevice.toString();
+        Assert.assertEquals("UIDevice(id=null, duid=null, ctime=null, model=null, ipaddr=null, sn=null, descr=null, locked=null, uiDeviceType=uiDeviceType, uiDeviceOS=uiDeviceOS, geoIP=geoIP)", result);
+    }
+
+
+    UIDevice.UIDeviceOS uIDeviceOS = new UIDevice.UIDeviceOS("sw", "osname", "osver");
+
+    @Test
+    public void uIDeviceOSTestSetSw() throws Exception {
+        uIDeviceOS.setSw("sw");
+    }
+
+    @Test
+    public void uIDeviceOSTestSetOsname() throws Exception {
+        uIDeviceOS.setOsname("osname");
+    }
+
+    @Test
+    public void uIDeviceOSTestSetOsver() throws Exception {
+        uIDeviceOS.setOsver("osver");
+    }
+
+    @Test
+    public void uIDeviceOSTestToString() throws Exception {
+        String result = uIDeviceOS.toString();
+        Assert.assertEquals("UIDevice.UIDeviceOS(sw=sw, osname=osname, osver=osver)", result);
+    }
+
+
+    UIDevice.UIDeviceType uIDeviceType = new UIDevice.UIDeviceType("name", "descr");
+
+    @Test
+    public void uIDeviceTypeTestSetName() throws Exception {
+        uIDeviceType.setName("name");
+    }
+
+    @Test
+    public void uIDeviceTypeTestSetDescr() throws Exception {
+        uIDeviceType.setDescr("descr");
+    }
+
+    @Test
+    public void uIDeviceTypeTestToString() throws Exception {
+        String result = uIDeviceType.toString();
+        Assert.assertEquals("UIDevice.UIDeviceType(name=name, descr=descr)", result);
+    }
+
+}
diff --git a/server/samserver/src/test/java/com/samsung/samserver/web/rest/service/vm/UIDeviceUpdateTest.java b/server/samserver/src/test/java/com/samsung/samserver/web/rest/service/vm/UIDeviceUpdateTest.java
new file mode 100644 (file)
index 0000000..92a0290
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ */
+package com.samsung.samserver.web.rest.service.vm;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Test class for the UIDeviceUpdate.
+ *
+ * @see UIDeviceUpdate
+ */
+public class UIDeviceUpdateTest {
+    @Mock
+    List<UIDeviceUpdate.UIDeviceUpdateOne> updates;
+    @InjectMocks
+    UIDeviceUpdate uIDeviceUpdate;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void testSetUpdates() throws Exception {
+        uIDeviceUpdate.setUpdates(Arrays.<UIDeviceUpdate.UIDeviceUpdateOne>asList(new UIDeviceUpdate.UIDeviceUpdateOne()));
+    }
+
+    @Test
+    public void testToString() throws Exception {
+        String result = uIDeviceUpdate.toString();
+        Assert.assertEquals("UIDeviceUpdate(updates=updates)", result);
+    }
+
+
+    UIDeviceUpdate.UIDeviceUpdateOne uIDeviceUpdateOne = new UIDeviceUpdate.UIDeviceUpdateOne();
+
+    @Test
+    public void uIDeviceUpdateOneTestSetId() throws Exception {
+        uIDeviceUpdateOne.setId(Long.valueOf(1));
+    }
+
+    @Test
+    public void uIDeviceUpdateOneTestSetLocked() throws Exception {
+        uIDeviceUpdateOne.setLocked(Integer.valueOf(0));
+    }
+
+    @Test
+    public void uIDeviceUpdateOneTestToString() throws Exception {
+        String result = uIDeviceUpdateOne.toString();
+        Assert.assertEquals("UIDeviceUpdate.UIDeviceUpdateOne(id=null, locked=null)", result);
+    }
+
+}