Search in sources :

Example 6 with SaveOtaPackageInfoRequest

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

the class BaseOtaPackageControllerTest method testFindFirmwareInfoById.

@Test
public void testFindFirmwareInfoById() throws Exception {
    SaveOtaPackageInfoRequest firmwareInfo = new SaveOtaPackageInfoRequest();
    firmwareInfo.setDeviceProfileId(deviceProfileId);
    firmwareInfo.setType(FIRMWARE);
    firmwareInfo.setTitle(TITLE);
    firmwareInfo.setVersion(VERSION);
    firmwareInfo.setUsesUrl(false);
    OtaPackageInfo savedFirmwareInfo = save(firmwareInfo);
    OtaPackageInfo foundFirmware = doGet("/api/otaPackage/info/" + savedFirmwareInfo.getId().getId().toString(), OtaPackageInfo.class);
    Assert.assertNotNull(foundFirmware);
    Assert.assertEquals(savedFirmwareInfo, foundFirmware);
}
Also used : OtaPackageInfo(org.thingsboard.server.common.data.OtaPackageInfo) SaveOtaPackageInfoRequest(org.thingsboard.server.common.data.SaveOtaPackageInfoRequest) Test(org.junit.Test)

Example 7 with SaveOtaPackageInfoRequest

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

the class BaseOtaPackageControllerTest method testDeleteFirmware.

@Test
public void testDeleteFirmware() throws Exception {
    SaveOtaPackageInfoRequest firmwareInfo = new SaveOtaPackageInfoRequest();
    firmwareInfo.setDeviceProfileId(deviceProfileId);
    firmwareInfo.setType(FIRMWARE);
    firmwareInfo.setTitle(TITLE);
    firmwareInfo.setVersion(VERSION);
    firmwareInfo.setUsesUrl(false);
    OtaPackageInfo savedFirmwareInfo = save(firmwareInfo);
    doDelete("/api/otaPackage/" + savedFirmwareInfo.getId().getId().toString()).andExpect(status().isOk());
    doGet("/api/otaPackage/info/" + savedFirmwareInfo.getId().getId().toString()).andExpect(status().isNotFound());
}
Also used : OtaPackageInfo(org.thingsboard.server.common.data.OtaPackageInfo) SaveOtaPackageInfoRequest(org.thingsboard.server.common.data.SaveOtaPackageInfoRequest) Test(org.junit.Test)

Example 8 with SaveOtaPackageInfoRequest

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

the class BaseOtaPackageControllerTest method testSaveFirmwareData.

@Test
public void testSaveFirmwareData() throws Exception {
    SaveOtaPackageInfoRequest firmwareInfo = new SaveOtaPackageInfoRequest();
    firmwareInfo.setDeviceProfileId(deviceProfileId);
    firmwareInfo.setType(FIRMWARE);
    firmwareInfo.setTitle(TITLE);
    firmwareInfo.setVersion(VERSION);
    firmwareInfo.setUsesUrl(false);
    OtaPackageInfo savedFirmwareInfo = save(firmwareInfo);
    Assert.assertNotNull(savedFirmwareInfo);
    Assert.assertNotNull(savedFirmwareInfo.getId());
    Assert.assertTrue(savedFirmwareInfo.getCreatedTime() > 0);
    Assert.assertEquals(savedTenant.getId(), savedFirmwareInfo.getTenantId());
    Assert.assertEquals(firmwareInfo.getTitle(), savedFirmwareInfo.getTitle());
    Assert.assertEquals(firmwareInfo.getVersion(), savedFirmwareInfo.getVersion());
    savedFirmwareInfo.setAdditionalInfo(JacksonUtil.newObjectNode());
    save(new SaveOtaPackageInfoRequest(savedFirmwareInfo, false));
    OtaPackageInfo foundFirmwareInfo = doGet("/api/otaPackage/info/" + savedFirmwareInfo.getId().getId().toString(), OtaPackageInfo.class);
    Assert.assertEquals(foundFirmwareInfo.getTitle(), savedFirmwareInfo.getTitle());
    MockMultipartFile testData = new MockMultipartFile("file", FILE_NAME, CONTENT_TYPE, DATA.array());
    OtaPackageInfo savedFirmware = savaData("/api/otaPackage/" + savedFirmwareInfo.getId().getId().toString() + "?checksum={checksum}&checksumAlgorithm={checksumAlgorithm}", testData, CHECKSUM, CHECKSUM_ALGORITHM);
    Assert.assertEquals(FILE_NAME, savedFirmware.getFileName());
    Assert.assertEquals(CONTENT_TYPE, savedFirmware.getContentType());
    Assert.assertEquals(CHECKSUM_ALGORITHM, savedFirmware.getChecksumAlgorithm().name());
    Assert.assertEquals(CHECKSUM, savedFirmware.getChecksum());
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) OtaPackageInfo(org.thingsboard.server.common.data.OtaPackageInfo) SaveOtaPackageInfoRequest(org.thingsboard.server.common.data.SaveOtaPackageInfoRequest) Test(org.junit.Test)

Example 9 with SaveOtaPackageInfoRequest

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

the class BaseOtaPackageControllerTest method testUpdateFirmwareFromDifferentTenant.

@Test
public void testUpdateFirmwareFromDifferentTenant() throws Exception {
    SaveOtaPackageInfoRequest firmwareInfo = new SaveOtaPackageInfoRequest();
    firmwareInfo.setDeviceProfileId(deviceProfileId);
    firmwareInfo.setType(FIRMWARE);
    firmwareInfo.setTitle(TITLE);
    firmwareInfo.setVersion(VERSION);
    firmwareInfo.setUsesUrl(false);
    OtaPackageInfo savedFirmwareInfo = save(firmwareInfo);
    loginDifferentTenant();
    doPost("/api/otaPackage", new SaveOtaPackageInfoRequest(savedFirmwareInfo, false), OtaPackageInfo.class, status().isForbidden());
    deleteDifferentTenant();
}
Also used : OtaPackageInfo(org.thingsboard.server.common.data.OtaPackageInfo) SaveOtaPackageInfoRequest(org.thingsboard.server.common.data.SaveOtaPackageInfoRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 SaveOtaPackageInfoRequest (org.thingsboard.server.common.data.SaveOtaPackageInfoRequest)9 OtaPackageInfo (org.thingsboard.server.common.data.OtaPackageInfo)8 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)4 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 ArrayList (java.util.ArrayList)2 PageLink (org.thingsboard.server.common.data.page.PageLink)2 OtaPackage (org.thingsboard.server.common.data.OtaPackage)1