use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.
the class BaseOtaPackageServiceTest method testSaveFirmwareWithInvalidTenant.
@Test
public void testSaveFirmwareWithInvalidTenant() {
OtaPackage firmware = new OtaPackage();
firmware.setTenantId(TenantId.fromUUID(Uuids.timeBased()));
firmware.setDeviceProfileId(deviceProfileId);
firmware.setType(FIRMWARE);
firmware.setTitle(TITLE);
firmware.setVersion(VERSION);
firmware.setFileName(FILE_NAME);
firmware.setContentType(CONTENT_TYPE);
firmware.setChecksumAlgorithm(CHECKSUM_ALGORITHM);
firmware.setChecksum(CHECKSUM);
firmware.setData(DATA);
thrown.expect(DataValidationException.class);
thrown.expectMessage("OtaPackage is referencing to non-existent tenant!");
otaPackageService.saveOtaPackage(firmware);
}
use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.
the class BaseOtaPackageServiceTest method testDeleteFirmware.
@Test
public void testDeleteFirmware() {
OtaPackage savedFirmware = createFirmware(tenantId, VERSION);
OtaPackage foundFirmware = otaPackageService.findOtaPackageById(tenantId, savedFirmware.getId());
Assert.assertNotNull(foundFirmware);
otaPackageService.deleteOtaPackage(tenantId, savedFirmware.getId());
foundFirmware = otaPackageService.findOtaPackageById(tenantId, savedFirmware.getId());
Assert.assertNull(foundFirmware);
}
use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.
the class BaseOtaPackageServiceTest method testSaveFirmwareWithEmptyContentType.
@Test
public void testSaveFirmwareWithEmptyContentType() {
OtaPackage firmware = new OtaPackage();
firmware.setTenantId(tenantId);
firmware.setDeviceProfileId(deviceProfileId);
firmware.setType(FIRMWARE);
firmware.setTitle(TITLE);
firmware.setVersion(VERSION);
firmware.setFileName(FILE_NAME);
firmware.setChecksumAlgorithm(CHECKSUM_ALGORITHM);
firmware.setChecksum(CHECKSUM);
firmware.setData(DATA);
thrown.expect(DataValidationException.class);
thrown.expectMessage("OtaPackage content type should be specified!");
otaPackageService.saveOtaPackage(firmware);
}
use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.
the class BaseOtaPackageServiceTest method testDeleteFirmwareWithReferenceByDeviceProfile.
@Test
public void testDeleteFirmwareWithReferenceByDeviceProfile() {
DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Test Device Profile");
DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile);
OtaPackage firmware = new OtaPackage();
firmware.setTenantId(tenantId);
firmware.setDeviceProfileId(savedDeviceProfile.getId());
firmware.setType(FIRMWARE);
firmware.setTitle(TITLE);
firmware.setVersion(VERSION);
firmware.setFileName(FILE_NAME);
firmware.setContentType(CONTENT_TYPE);
firmware.setChecksumAlgorithm(CHECKSUM_ALGORITHM);
firmware.setChecksum(CHECKSUM);
firmware.setData(DATA);
firmware.setDataSize(DATA_SIZE);
OtaPackage savedFirmware = otaPackageService.saveOtaPackage(firmware);
savedDeviceProfile.setFirmwareId(savedFirmware.getId());
deviceProfileService.saveDeviceProfile(savedDeviceProfile);
try {
thrown.expect(DataValidationException.class);
thrown.expectMessage("The otaPackage referenced by the device profile cannot be deleted!");
otaPackageService.deleteOtaPackage(tenantId, savedFirmware.getId());
} finally {
deviceProfileService.deleteDeviceProfile(tenantId, savedDeviceProfile.getId());
otaPackageService.deleteOtaPackage(tenantId, savedFirmware.getId());
}
}
use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.
the class BaseOtaPackageServiceTest method testSaveFirmwareWithEmptyTitle.
@Test
public void testSaveFirmwareWithEmptyTitle() {
OtaPackage firmware = new OtaPackage();
firmware.setTenantId(tenantId);
firmware.setDeviceProfileId(deviceProfileId);
firmware.setType(FIRMWARE);
firmware.setVersion(VERSION);
firmware.setFileName(FILE_NAME);
firmware.setContentType(CONTENT_TYPE);
firmware.setChecksumAlgorithm(CHECKSUM_ALGORITHM);
firmware.setChecksum(CHECKSUM);
firmware.setData(DATA);
thrown.expect(DataValidationException.class);
thrown.expectMessage("OtaPackage title should be specified!");
otaPackageService.saveOtaPackage(firmware);
}
Aggregations