Fix tenant profile Java serialization; add test
This commit is contained in:
parent
cbd0339205
commit
724300c076
@ -17,8 +17,13 @@ package org.thingsboard.server.common.data.queue;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ProcessingStrategy {
|
||||
public class ProcessingStrategy implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 293598327194813L;
|
||||
|
||||
private ProcessingStrategyType type;
|
||||
private int retries;
|
||||
private double failurePercentage;
|
||||
|
||||
@ -17,8 +17,13 @@ package org.thingsboard.server.common.data.queue;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SubmitStrategy {
|
||||
public class SubmitStrategy implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2938457983298400L;
|
||||
|
||||
private SubmitStrategyType type;
|
||||
private int batchSize;
|
||||
}
|
||||
@ -24,6 +24,7 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.thingsboard.server.common.data.DataConstants;
|
||||
import org.thingsboard.server.common.data.EntityInfo;
|
||||
import org.thingsboard.server.common.data.FSTUtils;
|
||||
import org.thingsboard.server.common.data.Tenant;
|
||||
import org.thingsboard.server.common.data.TenantProfile;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -45,6 +46,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
@DaoSqlTest
|
||||
public class TenantProfileServiceTest extends AbstractServiceTest {
|
||||
|
||||
@ -295,6 +299,29 @@ public class TenantProfileServiceTest extends AbstractServiceTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTenantProfileSerialization_fst() {
|
||||
TenantProfile tenantProfile = new TenantProfile();
|
||||
TenantProfileData profileData = new TenantProfileData();
|
||||
tenantProfile.setProfileData(profileData);
|
||||
profileData.setConfiguration(new DefaultTenantProfileConfiguration());
|
||||
addMainQueueConfig(tenantProfile);
|
||||
|
||||
byte[] serialized = assertDoesNotThrow(() -> {
|
||||
return FSTUtils.encode(tenantProfile);
|
||||
});
|
||||
assertDoesNotThrow(() -> {
|
||||
FSTUtils.encode(profileData);
|
||||
});
|
||||
|
||||
TenantProfile deserialized = assertDoesNotThrow(() -> {
|
||||
return FSTUtils.decode(serialized);
|
||||
});
|
||||
assertThat(deserialized).isEqualTo(tenantProfile);
|
||||
assertThat(deserialized.getProfileData()).isNotNull();
|
||||
assertThat(deserialized.getProfileData().getQueueConfiguration()).isNotEmpty();
|
||||
}
|
||||
|
||||
public static TenantProfile createTenantProfile(String name) {
|
||||
TenantProfile tenantProfile = new TenantProfile();
|
||||
tenantProfile.setName(name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user