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.*;
})
@RequestMapping(value ="/devices", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
- public ResponseEntity<List<GetDevicesRestService.UIDevice>> getAllDevices(Pageable pageable);
+ public ResponseEntity<List<UIDevice>> getAllDevices(Pageable pageable);
/**
@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);
/**
@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);
/**
@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);
}
*/
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.*;
@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);
/*
@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);
@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);
/*
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.*;
* @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);
}
* @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);
}
* @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);
}
* 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);
}
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.*;
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);
}
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.*;
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
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;
}
}
- /**
- * 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;
- }
- }
-
}
* 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.
.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;
- }
- }
-
}
* 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;
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.
.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;
- }
-
}
* 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.
}
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);
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;
- }
-
}
*/
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.
@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());
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);
}
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
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.
@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());
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);
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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/**
+ * 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;
+ }
+}
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;
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")
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);
@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")
@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");
//@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");
//@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");
@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");
@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");
.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");
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;
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);
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);
@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);
--- /dev/null
+/*
+ * 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());
+ }
+}
--- /dev/null
+/*
+ * 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());
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+
+}
--- /dev/null
+/*
+ * 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);
+ }
+
+}