Search in sources :

Example 6 with OtaPackage

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);
}
Also used : OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Example 7 with OtaPackage

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);
}
Also used : OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Example 8 with OtaPackage

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);
}
Also used : OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Example 9 with OtaPackage

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());
    }
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Example 10 with OtaPackage

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);
}
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