Commit ce4ecedc29a159e215d7ce22b7cd1d920aedd00e

Authored by Andrii Shvaika
1 parent 73a1a798

No more device type

... ... @@ -186,9 +186,8 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest {
186 186 public void testSaveDeviceWithEmptyType() throws Exception {
187 187 Device device = new Device();
188 188 device.setName("My device");
189   - doPost("/api/device", device)
190   - .andExpect(status().isBadRequest())
191   - .andExpect(statusReason(containsString("Device type should be specified")));
  189 + Device savedDevice = doPost("/api/device", device, Device.class);
  190 + Assert.assertEquals("default", savedDevice.getType());
192 191 }
193 192
194 193 @Test
... ...
... ... @@ -121,7 +121,7 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
121 121 Assert.assertNotNull(foundDefaultDeviceProfileInfo.getName());
122 122 Assert.assertNotNull(foundDefaultDeviceProfileInfo.getType());
123 123 Assert.assertEquals(DeviceProfileType.DEFAULT, foundDefaultDeviceProfileInfo.getType());
124   - Assert.assertEquals("Default", foundDefaultDeviceProfileInfo.getName());
  124 + Assert.assertEquals("default", foundDefaultDeviceProfileInfo.getName());
125 125 }
126 126
127 127 @Test
... ...
... ... @@ -55,6 +55,6 @@ public interface DeviceProfileRepository extends PagingAndSortingRepository<Devi
55 55 "WHERE d.tenantId = :tenantId AND d.isDefault = true")
56 56 DeviceProfileInfo findDefaultDeviceProfileInfo(@Param("tenantId") UUID tenantId);
57 57
58   - DeviceProfile findByTenantIdAndName(UUID id, String profileName);
  58 + DeviceProfileEntity findByTenantIdAndName(UUID id, String profileName);
59 59
60 60 }
... ...
... ... @@ -82,6 +82,6 @@ public class JpaDeviceProfileDao extends JpaAbstractSearchTextDao<DeviceProfileE
82 82
83 83 @Override
84 84 public DeviceProfile findByName(TenantId tenantId, String profileName) {
85   - return deviceProfileRepository.findByTenantIdAndName(tenantId.getId(), profileName);
  85 + return DaoUtil.getData(deviceProfileRepository.findByTenantIdAndName(tenantId.getId(), profileName));
86 86 }
87 87 }
... ...
... ... @@ -270,7 +270,7 @@ public abstract class BaseDeviceServiceTest extends AbstractServiceTest {
270 270 name = i % 2 == 0 ? name.toLowerCase() : name.toUpperCase();
271 271 device.setName(name);
272 272 device.setType("default");
273   - devicesTitle1.add(new DeviceInfo(deviceService.saveDevice(device), null, false, "Default"));
  273 + devicesTitle1.add(new DeviceInfo(deviceService.saveDevice(device), null, false, "default"));
274 274 }
275 275 String title2 = "Device title 2";
276 276 List<DeviceInfo> devicesTitle2 = new ArrayList<>();
... ... @@ -282,7 +282,7 @@ public abstract class BaseDeviceServiceTest extends AbstractServiceTest {
282 282 name = i % 2 == 0 ? name.toLowerCase() : name.toUpperCase();
283 283 device.setName(name);
284 284 device.setType("default");
285   - devicesTitle2.add(new DeviceInfo(deviceService.saveDevice(device), null, false, "Default"));
  285 + devicesTitle2.add(new DeviceInfo(deviceService.saveDevice(device), null, false, "default"));
286 286 }
287 287
288 288 List<DeviceInfo> loadedDevicesTitle1 = new ArrayList<>();
... ... @@ -435,7 +435,7 @@ public abstract class BaseDeviceServiceTest extends AbstractServiceTest {
435 435 device.setName("Device"+i);
436 436 device.setType("default");
437 437 device = deviceService.saveDevice(device);
438   - devices.add(new DeviceInfo(deviceService.assignDeviceToCustomer(tenantId, device.getId(), customerId), customer.getTitle(), customer.isPublic(), "Default"));
  438 + devices.add(new DeviceInfo(deviceService.assignDeviceToCustomer(tenantId, device.getId(), customerId), customer.getTitle(), customer.isPublic(), "default"));
439 439 }
440 440
441 441 List<DeviceInfo> loadedDevices = new ArrayList<>();
... ...