Search in sources :

Example 21 with OtaPackage

use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.

the class BaseOtaPackageServiceTest method testSaveFirmwareWithEmptyData.

@Test
public void testSaveFirmwareWithEmptyData() {
    OtaPackage firmware = new OtaPackage();
    firmware.setTenantId(tenantId);
    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);
    thrown.expect(DataValidationException.class);
    thrown.expectMessage("OtaPackage data should be specified!");
    otaPackageService.saveOtaPackage(firmware);
}
Also used : OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Example 22 with OtaPackage

use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.

the class BaseOtaPackageServiceTest method createFirmware.

private OtaPackage createFirmware(TenantId tenantId, String version) {
    OtaPackage firmware = new OtaPackage();
    firmware.setTenantId(tenantId);
    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);
    firmware.setDataSize(DATA_SIZE);
    return otaPackageService.saveOtaPackage(firmware);
}
Also used : OtaPackage(org.thingsboard.server.common.data.OtaPackage)

Example 23 with OtaPackage

use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.

the class BaseOtaPackageServiceTest method testSaveFirmwareWithEmptyChecksum.

@Test
public void testSaveFirmwareWithEmptyChecksum() {
    OtaPackage firmware = new OtaPackage();
    firmware.setTenantId(tenantId);
    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.setData(DATA);
    thrown.expect(DataValidationException.class);
    thrown.expectMessage("OtaPackage checksum should be specified!");
    otaPackageService.saveOtaPackage(firmware);
}
Also used : OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Example 24 with OtaPackage

use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.

the class BaseOtaPackageServiceTest method testSaveFirmwareWithEmptyType.

@Test
public void testSaveFirmwareWithEmptyType() {
    OtaPackage firmware = new OtaPackage();
    firmware.setTenantId(tenantId);
    firmware.setDeviceProfileId(deviceProfileId);
    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("Type should be specified!");
    otaPackageService.saveOtaPackage(firmware);
}
Also used : OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Example 25 with OtaPackage

use of org.thingsboard.server.common.data.OtaPackage in project thingsboard by thingsboard.

the class BaseOtaPackageServiceTest method testFindFirmwareById.

@Test
public void testFindFirmwareById() {
    OtaPackage savedFirmware = createFirmware(tenantId, VERSION);
    OtaPackage foundFirmware = otaPackageService.findOtaPackageById(tenantId, savedFirmware.getId());
    Assert.assertNotNull(foundFirmware);
    Assert.assertEquals(savedFirmware, foundFirmware);
    otaPackageService.deleteOtaPackage(tenantId, savedFirmware.getId());
}
Also used : OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Aggregations

OtaPackage (org.thingsboard.server.common.data.OtaPackage)29 Test (org.junit.Test)21 DeviceProfile (org.thingsboard.server.common.data.DeviceProfile)5 OtaPackageInfo (org.thingsboard.server.common.data.OtaPackageInfo)5 Device (org.thingsboard.server.common.data.Device)4 OtaPackageId (org.thingsboard.server.common.data.id.OtaPackageId)4 ThingsboardException (org.thingsboard.server.common.data.exception.ThingsboardException)3 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)3 ApiOperation (io.swagger.annotations.ApiOperation)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 DeviceProfileId (org.thingsboard.server.common.data.id.DeviceProfileId)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 MessagingException (javax.mail.MessagingException)1 ByteArrayResource (org.springframework.core.io.ByteArrayResource)1 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)1 DashboardInfo (org.thingsboard.server.common.data.DashboardInfo)1