|
|
|
@ -163,7 +163,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
firmware.setVersion(VERSION); |
|
|
|
firmware.setUrl(URL); |
|
|
|
firmware.setDataSize(0L); |
|
|
|
OtaPackageInfo savedFirmware = otaPackageService.saveOtaPackageInfo(firmware); |
|
|
|
OtaPackageInfo savedFirmware = otaPackageService.saveOtaPackageInfo(firmware, true); |
|
|
|
|
|
|
|
Assert.assertNotNull(savedFirmware); |
|
|
|
Assert.assertNotNull(savedFirmware.getId()); |
|
|
|
@ -174,7 +174,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
Assert.assertEquals(firmware.getContentType(), savedFirmware.getContentType()); |
|
|
|
|
|
|
|
savedFirmware.setAdditionalInfo(JacksonUtil.newObjectNode()); |
|
|
|
otaPackageService.saveOtaPackageInfo(savedFirmware); |
|
|
|
otaPackageService.saveOtaPackageInfo(savedFirmware, true); |
|
|
|
|
|
|
|
OtaPackage foundFirmware = otaPackageService.findOtaPackageById(tenantId, savedFirmware.getId()); |
|
|
|
Assert.assertEquals(foundFirmware.getTitle(), savedFirmware.getTitle()); |
|
|
|
@ -190,7 +190,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
firmwareInfo.setType(FIRMWARE); |
|
|
|
firmwareInfo.setTitle(TITLE); |
|
|
|
firmwareInfo.setVersion(VERSION); |
|
|
|
OtaPackageInfo savedFirmwareInfo = otaPackageService.saveOtaPackageInfo(firmwareInfo); |
|
|
|
OtaPackageInfo savedFirmwareInfo = otaPackageService.saveOtaPackageInfo(firmwareInfo, false); |
|
|
|
|
|
|
|
Assert.assertNotNull(savedFirmwareInfo); |
|
|
|
Assert.assertNotNull(savedFirmwareInfo.getId()); |
|
|
|
@ -216,7 +216,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
|
|
|
|
savedFirmwareInfo = otaPackageService.findOtaPackageInfoById(tenantId, savedFirmwareInfo.getId()); |
|
|
|
savedFirmwareInfo.setAdditionalInfo(JacksonUtil.newObjectNode()); |
|
|
|
otaPackageService.saveOtaPackageInfo(savedFirmwareInfo); |
|
|
|
otaPackageService.saveOtaPackageInfo(savedFirmwareInfo, false); |
|
|
|
|
|
|
|
OtaPackage foundFirmware = otaPackageService.findOtaPackageById(tenantId, firmware.getId()); |
|
|
|
firmware.setAdditionalInfo(JacksonUtil.newObjectNode()); |
|
|
|
@ -399,7 +399,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
firmwareInfo.setType(FIRMWARE); |
|
|
|
firmwareInfo.setTitle(TITLE); |
|
|
|
firmwareInfo.setVersion(VERSION); |
|
|
|
otaPackageService.saveOtaPackageInfo(firmwareInfo); |
|
|
|
otaPackageService.saveOtaPackageInfo(firmwareInfo, false); |
|
|
|
|
|
|
|
OtaPackageInfo newFirmwareInfo = new OtaPackageInfo(); |
|
|
|
newFirmwareInfo.setTenantId(tenantId); |
|
|
|
@ -410,7 +410,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
|
|
|
|
thrown.expect(DataValidationException.class); |
|
|
|
thrown.expectMessage("OtaPackage with such title and version already exists!"); |
|
|
|
otaPackageService.saveOtaPackageInfo(newFirmwareInfo); |
|
|
|
otaPackageService.saveOtaPackageInfo(newFirmwareInfo, false); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@ -506,7 +506,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
firmware.setType(FIRMWARE); |
|
|
|
firmware.setTitle(TITLE); |
|
|
|
firmware.setVersion(VERSION); |
|
|
|
OtaPackageInfo savedFirmware = otaPackageService.saveOtaPackageInfo(firmware); |
|
|
|
OtaPackageInfo savedFirmware = otaPackageService.saveOtaPackageInfo(firmware, false); |
|
|
|
|
|
|
|
OtaPackageInfo foundFirmware = otaPackageService.findOtaPackageInfoById(tenantId, savedFirmware.getId()); |
|
|
|
Assert.assertNotNull(foundFirmware); |
|
|
|
@ -543,7 +543,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
firmwareWithUrl.setUrl(URL); |
|
|
|
firmwareWithUrl.setDataSize(0L); |
|
|
|
|
|
|
|
OtaPackageInfo savedFwWithUrl = otaPackageService.saveOtaPackageInfo(firmwareWithUrl); |
|
|
|
OtaPackageInfo savedFwWithUrl = otaPackageService.saveOtaPackageInfo(firmwareWithUrl, true); |
|
|
|
savedFwWithUrl.setHasData(true); |
|
|
|
|
|
|
|
firmwares.add(savedFwWithUrl); |
|
|
|
@ -588,7 +588,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
firmwareWithUrl.setUrl(URL); |
|
|
|
firmwareWithUrl.setDataSize(0L); |
|
|
|
|
|
|
|
OtaPackageInfo savedFwWithUrl = otaPackageService.saveOtaPackageInfo(firmwareWithUrl); |
|
|
|
OtaPackageInfo savedFwWithUrl = otaPackageService.saveOtaPackageInfo(firmwareWithUrl, true); |
|
|
|
savedFwWithUrl.setHasData(true); |
|
|
|
|
|
|
|
firmwares.add(savedFwWithUrl); |
|
|
|
@ -627,6 +627,40 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { |
|
|
|
Assert.assertTrue(pageData.getData().isEmpty()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testSaveOtaPackageInfoWithBlankAndEmptyUrl() { |
|
|
|
OtaPackageInfo firmwareInfo = new OtaPackageInfo(); |
|
|
|
firmwareInfo.setDeviceProfileId(deviceProfileId); |
|
|
|
firmwareInfo.setType(FIRMWARE); |
|
|
|
firmwareInfo.setTitle(TITLE); |
|
|
|
firmwareInfo.setVersion(VERSION); |
|
|
|
firmwareInfo.setUrl(" "); |
|
|
|
thrown.expect(DataValidationException.class); |
|
|
|
thrown.expectMessage("Ota package URL should be specified!"); |
|
|
|
otaPackageService.saveOtaPackageInfo(firmwareInfo, true); |
|
|
|
firmwareInfo.setUrl(""); |
|
|
|
otaPackageService.saveOtaPackageInfo(firmwareInfo, true); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testSaveOtaPackageUrlCantBeUpdated() { |
|
|
|
OtaPackageInfo firmwareInfo = new OtaPackageInfo(); |
|
|
|
firmwareInfo.setDeviceProfileId(deviceProfileId); |
|
|
|
firmwareInfo.setType(FIRMWARE); |
|
|
|
firmwareInfo.setTitle(TITLE); |
|
|
|
firmwareInfo.setVersion(VERSION); |
|
|
|
firmwareInfo.setUrl(URL); |
|
|
|
firmwareInfo.setTenantId(tenantId); |
|
|
|
|
|
|
|
OtaPackageInfo savedFirmwareInfo = otaPackageService.saveOtaPackageInfo(firmwareInfo, true); |
|
|
|
|
|
|
|
thrown.expect(DataValidationException.class); |
|
|
|
thrown.expectMessage("Updating otaPackage URL is prohibited!"); |
|
|
|
|
|
|
|
savedFirmwareInfo.setUrl("https://newurl.com"); |
|
|
|
otaPackageService.saveOtaPackageInfo(savedFirmwareInfo, true); |
|
|
|
} |
|
|
|
|
|
|
|
private OtaPackage createFirmware(TenantId tenantId, String version) { |
|
|
|
OtaPackage firmware = new OtaPackage(); |
|
|
|
firmware.setTenantId(tenantId); |
|
|
|
|