Browse Source

lwm2m: fix bug test by ver Object, fix buf test: TbLwM2mStoreFactory.class "NetworkConfig must not be null"

pull/9903/head
nick 3 years ago
parent
commit
a74640a1d8
  1. 2
      application/src/test/java/org/thingsboard/server/controller/TbResourceControllerTest.java
  2. 5
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/store/TbLwM2mStoreFactory.java

2
application/src/test/java/org/thingsboard/server/controller/TbResourceControllerTest.java

@ -687,7 +687,7 @@ public class TbResourceControllerTest extends AbstractControllerTest {
List<TbResource> resources = loadLwm2mResources();
List<LwM2mObject> objects =
doGetTyped("/api/resource/lwm2m?sortProperty=id&sortOrder=ASC&objectIds=3_1.0,5_1.0,19_1.1", new TypeReference<>() {});
doGetTyped("/api/resource/lwm2m?sortProperty=id&sortOrder=ASC&objectIds=3_1.2,5_1.2,19_1.1", new TypeReference<>() {});
Assert.assertNotNull(objects);
Assert.assertEquals(3, objects.size());

5
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/store/TbLwM2mStoreFactory.java

@ -19,6 +19,7 @@ import lombok.RequiredArgsConstructor;
import org.eclipse.californium.core.network.RandomTokenGenerator;
import org.eclipse.leshan.server.registration.RegistrationStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.stereotype.Component;
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
@ -35,6 +36,7 @@ import java.util.Optional;
public class TbLwM2mStoreFactory {
private final Optional<TBRedisCacheConfiguration> redisConfiguration;
@Lazy
private final LwM2MTransportServerConfig config;
private final LwM2mCredentialsSecurityInfoValidator validator;
@ -43,7 +45,8 @@ public class TbLwM2mStoreFactory {
@Bean
private RegistrationStore registrationStore() {
return redisConfiguration.isPresent() ?
new TbLwM2mRedisRegistrationStore(new RandomTokenGenerator(config.getCoapConfig()), getConnectionFactory(), modelProvider) : new TbInMemoryRegistrationStore(new RandomTokenGenerator(config.getCoapConfig()), config.getCleanPeriodInSec(), modelProvider);
new TbLwM2mRedisRegistrationStore(new RandomTokenGenerator(config.getCoapConfig()), getConnectionFactory(), modelProvider) :
new TbInMemoryRegistrationStore(new RandomTokenGenerator(config.getCoapConfig()), config.getCleanPeriodInSec(), modelProvider);
}
@Bean

Loading…
Cancel
Save