Refactoring DAO continue
This commit is contained in:
parent
d6965e9469
commit
9fbd7e5bc8
@ -15,14 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.common.data.rule;
|
package org.thingsboard.server.common.data.rule;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
|
||||||
import org.thingsboard.server.common.data.SearchTextBased;
|
import org.thingsboard.server.common.data.SearchTextBased;
|
||||||
import org.thingsboard.server.common.data.id.CustomerId;
|
|
||||||
import org.thingsboard.server.common.data.id.RuleId;
|
import org.thingsboard.server.common.data.id.RuleId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import org.thingsboard.server.common.data.plugin.ComponentLifecycleState;
|
import org.thingsboard.server.common.data.plugin.ComponentLifecycleState;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@ -27,8 +27,10 @@ import com.google.common.base.Function;
|
|||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.thingsboard.server.common.data.SearchTextBased;
|
||||||
import org.thingsboard.server.dao.model.BaseEntity;
|
import org.thingsboard.server.dao.model.BaseEntity;
|
||||||
import org.thingsboard.server.dao.model.ModelConstants;
|
import org.thingsboard.server.dao.model.ModelConstants;
|
||||||
|
import org.thingsboard.server.dao.model.SearchTextEntity;
|
||||||
import org.thingsboard.server.dao.model.wrapper.EntityResultSet;
|
import org.thingsboard.server.dao.model.wrapper.EntityResultSet;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -46,6 +48,10 @@ public abstract class CassandraAbstractModelDao<E extends BaseEntity<D>, D> exte
|
|||||||
|
|
||||||
protected abstract String getColumnFamilyName();
|
protected abstract String getColumnFamilyName();
|
||||||
|
|
||||||
|
protected boolean isSearchTextDao() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected Mapper<E> getMapper() {
|
protected Mapper<E> getMapper() {
|
||||||
return cluster.getMapper(getColumnFamilyClass());
|
return cluster.getMapper(getColumnFamilyClass());
|
||||||
}
|
}
|
||||||
@ -144,6 +150,9 @@ public abstract class CassandraAbstractModelDao<E extends BaseEntity<D>, D> exte
|
|||||||
log.error("Can't create entity for domain object {}", domain, e);
|
log.error("Can't create entity for domain object {}", domain, e);
|
||||||
throw new IllegalArgumentException("Can't create entity for domain object {" + domain + "}", e);
|
throw new IllegalArgumentException("Can't create entity for domain object {" + domain + "}", e);
|
||||||
}
|
}
|
||||||
|
if (isSearchTextDao()) {
|
||||||
|
((SearchTextEntity) entity).setSearchText(((SearchTextEntity) entity).getSearchTextSource().toLowerCase());
|
||||||
|
}
|
||||||
log.debug("Saving entity {}", entity);
|
log.debug("Saving entity {}", entity);
|
||||||
entity = saveWithResult(entity).getEntity();
|
entity = saveWithResult(entity).getEntity();
|
||||||
return DaoUtil.getData(entity);
|
return DaoUtil.getData(entity);
|
||||||
|
|||||||
@ -33,11 +33,9 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class CassandraAbstractSearchTextDao<E extends SearchTextEntity<D>, D> extends CassandraAbstractModelDao<E, D> {
|
public abstract class CassandraAbstractSearchTextDao<E extends SearchTextEntity<D>, D> extends CassandraAbstractModelDao<E, D> {
|
||||||
|
|
||||||
public D save(D domain) {
|
@Override
|
||||||
|
protected boolean isSearchTextDao() {
|
||||||
entity.setSearchText(entity.getSearchTextSource().toLowerCase());
|
return true;
|
||||||
|
|
||||||
return super.save(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<E> findPageWithTextSearch(String searchView, List<Clause> clauses, TextPageLink pageLink) {
|
protected List<E> findPageWithTextSearch(String searchView, List<Clause> clauses, TextPageLink pageLink) {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
|
import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
|
||||||
|
|
||||||
public abstract class AbstractSearchTimeDao<E extends BaseEntity<D>, D> extends CassandraAbstractModelDao<E, D> {
|
public abstract class CassandraAbstractSearchTimeDao<E extends BaseEntity<D>, D> extends CassandraAbstractModelDao<E, D> {
|
||||||
|
|
||||||
|
|
||||||
protected List<E> findPageWithTimeSearch(String searchView, List<Clause> clauses, TimePageLink pageLink) {
|
protected List<E> findPageWithTimeSearch(String searchView, List<Clause> clauses, TimePageLink pageLink) {
|
||||||
@ -45,7 +45,7 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BaseComponentDescriptorDao extends CassandraAbstractSearchTextDao<ComponentDescriptorEntity, ComponentDescriptor> implements ComponentDescriptorDao {
|
public class CassandraBaseComponentDescriptorDao extends CassandraAbstractSearchTextDao<ComponentDescriptorEntity, ComponentDescriptor> implements ComponentDescriptorDao {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<ComponentDescriptorEntity> getColumnFamilyClass() {
|
protected Class<ComponentDescriptorEntity> getColumnFamilyClass() {
|
||||||
@ -23,7 +23,9 @@ import org.apache.commons.lang3.RandomStringUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.thingsboard.server.common.data.Customer;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
|
import org.thingsboard.server.common.data.Tenant;
|
||||||
import org.thingsboard.server.common.data.id.CustomerId;
|
import org.thingsboard.server.common.data.id.CustomerId;
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
@ -33,9 +35,7 @@ import org.thingsboard.server.common.data.security.DeviceCredentials;
|
|||||||
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
|
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
|
||||||
import org.thingsboard.server.dao.customer.CustomerDao;
|
import org.thingsboard.server.dao.customer.CustomerDao;
|
||||||
import org.thingsboard.server.dao.exception.DataValidationException;
|
import org.thingsboard.server.dao.exception.DataValidationException;
|
||||||
import org.thingsboard.server.dao.model.CustomerEntity;
|
|
||||||
import org.thingsboard.server.dao.model.DeviceEntity;
|
import org.thingsboard.server.dao.model.DeviceEntity;
|
||||||
import org.thingsboard.server.dao.model.TenantEntity;
|
|
||||||
import org.thingsboard.server.dao.service.DataValidator;
|
import org.thingsboard.server.dao.service.DataValidator;
|
||||||
import org.thingsboard.server.dao.service.PaginatedRemover;
|
import org.thingsboard.server.dao.service.PaginatedRemover;
|
||||||
import org.thingsboard.server.dao.tenant.TenantDao;
|
import org.thingsboard.server.dao.tenant.TenantDao;
|
||||||
@ -43,9 +43,13 @@ import org.thingsboard.server.dao.tenant.TenantDao;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static org.thingsboard.server.dao.DaoUtil.*;
|
import static org.thingsboard.server.dao.DaoUtil.convertDataList;
|
||||||
|
import static org.thingsboard.server.dao.DaoUtil.getData;
|
||||||
|
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
|
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
|
||||||
import static org.thingsboard.server.dao.service.Validator.*;
|
import static org.thingsboard.server.dao.service.Validator.validateId;
|
||||||
|
import static org.thingsboard.server.dao.service.Validator.validateIds;
|
||||||
|
import static org.thingsboard.server.dao.service.Validator.validatePageLink;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -74,17 +78,16 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
public ListenableFuture<Device> findDeviceByIdAsync(DeviceId deviceId) {
|
public ListenableFuture<Device> findDeviceByIdAsync(DeviceId deviceId) {
|
||||||
log.trace("Executing findDeviceById [{}]", deviceId);
|
log.trace("Executing findDeviceById [{}]", deviceId);
|
||||||
validateId(deviceId, "Incorrect deviceId " + deviceId);
|
validateId(deviceId, "Incorrect deviceId " + deviceId);
|
||||||
ListenableFuture<Device> deviceEntity = deviceDao.findByIdAsync(deviceId.getId());
|
return deviceDao.findByIdAsync(deviceId.getId());
|
||||||
return Futures.transform(deviceEntity, (Function<? super DeviceEntity, ? extends Device>) input -> getData(input));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Device> findDeviceByTenantIdAndName(TenantId tenantId, String name) {
|
public Optional<Device> findDeviceByTenantIdAndName(TenantId tenantId, String name) {
|
||||||
log.trace("Executing findDeviceByTenantIdAndName [{}][{}]", tenantId, name);
|
log.trace("Executing findDeviceByTenantIdAndName [{}][{}]", tenantId, name);
|
||||||
validateId(tenantId, "Incorrect tenantId " + tenantId);
|
validateId(tenantId, "Incorrect tenantId " + tenantId);
|
||||||
Optional<Device> deviceEntityOpt = deviceDao.findDevicesByTenantIdAndName(tenantId.getId(), name);
|
Optional<Device> deviceOpt = deviceDao.findDevicesByTenantIdAndName(tenantId.getId(), name);
|
||||||
if (deviceEntityOpt.isPresent()) {
|
if (deviceOpt.isPresent()) {
|
||||||
return Optional.of(deviceEntityOpt.get());
|
return Optional.of(deviceOpt.get());
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@ -136,7 +139,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
validateId(tenantId, "Incorrect tenantId " + tenantId);
|
validateId(tenantId, "Incorrect tenantId " + tenantId);
|
||||||
validatePageLink(pageLink, "Incorrect page link " + pageLink);
|
validatePageLink(pageLink, "Incorrect page link " + pageLink);
|
||||||
List<Device> devices = deviceDao.findDevicesByTenantId(tenantId.getId(), pageLink);
|
List<Device> devices = deviceDao.findDevicesByTenantId(tenantId.getId(), pageLink);
|
||||||
return new TextPageData<Device>(devices, pageLink);
|
return new TextPageData<>(devices, pageLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -144,8 +147,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
log.trace("Executing findDevicesByTenantIdAndIdsAsync, tenantId [{}], deviceIds [{}]", tenantId, deviceIds);
|
log.trace("Executing findDevicesByTenantIdAndIdsAsync, tenantId [{}], deviceIds [{}]", tenantId, deviceIds);
|
||||||
validateId(tenantId, "Incorrect tenantId " + tenantId);
|
validateId(tenantId, "Incorrect tenantId " + tenantId);
|
||||||
validateIds(deviceIds, "Incorrect deviceIds " + deviceIds);
|
validateIds(deviceIds, "Incorrect deviceIds " + deviceIds);
|
||||||
ListenableFuture<List<Device>> devices = deviceDao.findDevicesByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(deviceIds));
|
return deviceDao.findDevicesByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(deviceIds));
|
||||||
return Futures.transform(deviceEntities, (Function<List<DeviceEntity>, List<Device>>) input -> convertDataList(input));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,7 +165,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
validateId(customerId, "Incorrect customerId " + customerId);
|
validateId(customerId, "Incorrect customerId " + customerId);
|
||||||
validatePageLink(pageLink, "Incorrect page link " + pageLink);
|
validatePageLink(pageLink, "Incorrect page link " + pageLink);
|
||||||
List<Device> devices = deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink);
|
List<Device> devices = deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink);
|
||||||
return new TextPageData<Device>(devices, pageLink);
|
return new TextPageData<>(devices, pageLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -172,9 +174,8 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
validateId(tenantId, "Incorrect tenantId " + tenantId);
|
validateId(tenantId, "Incorrect tenantId " + tenantId);
|
||||||
validateId(customerId, "Incorrect customerId " + customerId);
|
validateId(customerId, "Incorrect customerId " + customerId);
|
||||||
validateIds(deviceIds, "Incorrect deviceIds " + deviceIds);
|
validateIds(deviceIds, "Incorrect deviceIds " + deviceIds);
|
||||||
ListenableFuture<List<DeviceEntity>> deviceEntities = deviceDao.findDevicesByTenantIdCustomerIdAndIdsAsync(tenantId.getId(),
|
return deviceDao.findDevicesByTenantIdCustomerIdAndIdsAsync(tenantId.getId(),
|
||||||
customerId.getId(), toUUIDs(deviceIds));
|
customerId.getId(), toUUIDs(deviceIds));
|
||||||
return Futures.transform(deviceEntities, (Function<List<DeviceEntity>, List<Device>>) input -> convertDataList(input));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -201,7 +202,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
protected void validateUpdate(Device device) {
|
protected void validateUpdate(Device device) {
|
||||||
deviceDao.findDevicesByTenantIdAndName(device.getTenantId().getId(), device.getName()).ifPresent(
|
deviceDao.findDevicesByTenantIdAndName(device.getTenantId().getId(), device.getName()).ifPresent(
|
||||||
d -> {
|
d -> {
|
||||||
if (!d.getId().equals(device.getUuidId())) {
|
if (!d.getUuidId().equals(device.getUuidId())) {
|
||||||
throw new DataValidationException("Device with such name already exists!");
|
throw new DataValidationException("Device with such name already exists!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +217,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
if (device.getTenantId() == null) {
|
if (device.getTenantId() == null) {
|
||||||
throw new DataValidationException("Device should be assigned to tenant!");
|
throw new DataValidationException("Device should be assigned to tenant!");
|
||||||
} else {
|
} else {
|
||||||
TenantEntity tenant = tenantDao.findById(device.getTenantId().getId());
|
Tenant tenant = tenantDao.findById(device.getTenantId().getId());
|
||||||
if (tenant == null) {
|
if (tenant == null) {
|
||||||
throw new DataValidationException("Device is referencing to non-existent tenant!");
|
throw new DataValidationException("Device is referencing to non-existent tenant!");
|
||||||
}
|
}
|
||||||
@ -224,32 +225,32 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
if (device.getCustomerId() == null) {
|
if (device.getCustomerId() == null) {
|
||||||
device.setCustomerId(new CustomerId(NULL_UUID));
|
device.setCustomerId(new CustomerId(NULL_UUID));
|
||||||
} else if (!device.getCustomerId().getId().equals(NULL_UUID)) {
|
} else if (!device.getCustomerId().getId().equals(NULL_UUID)) {
|
||||||
CustomerEntity customer = customerDao.findById(device.getCustomerId().getId());
|
Customer customer = customerDao.findById(device.getCustomerId().getId());
|
||||||
if (customer == null) {
|
if (customer == null) {
|
||||||
throw new DataValidationException("Can't assign device to non-existent customer!");
|
throw new DataValidationException("Can't assign device to non-existent customer!");
|
||||||
}
|
}
|
||||||
if (!customer.getTenantId().equals(device.getTenantId().getId())) {
|
if (!customer.getTenantId().getId().equals(device.getTenantId().getId())) {
|
||||||
throw new DataValidationException("Can't assign device to customer from different tenant!");
|
throw new DataValidationException("Can't assign device to customer from different tenant!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private PaginatedRemover<TenantId, DeviceEntity> tenantDevicesRemover =
|
private PaginatedRemover<TenantId, Device> tenantDevicesRemover =
|
||||||
new PaginatedRemover<TenantId, DeviceEntity>() {
|
new PaginatedRemover<TenantId, Device>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<DeviceEntity> findEntities(TenantId id, TextPageLink pageLink) {
|
protected List<Device> findEntities(TenantId id, TextPageLink pageLink) {
|
||||||
return deviceDao.findDevicesByTenantId(id.getId(), pageLink);
|
return deviceDao.findDevicesByTenantId(id.getId(), pageLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removeEntity(DeviceEntity entity) {
|
protected void removeEntity(Device entity) {
|
||||||
deleteDevice(new DeviceId(entity.getId()));
|
deleteDevice(new DeviceId(entity.getUuidId()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomerDevicesUnassigner extends PaginatedRemover<CustomerId, DeviceEntity> {
|
private class CustomerDevicesUnassigner extends PaginatedRemover<CustomerId, Device> {
|
||||||
|
|
||||||
private TenantId tenantId;
|
private TenantId tenantId;
|
||||||
|
|
||||||
@ -258,13 +259,13 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<DeviceEntity> findEntities(CustomerId id, TextPageLink pageLink) {
|
protected List<Device> findEntities(CustomerId id, TextPageLink pageLink) {
|
||||||
return deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), id.getId(), pageLink);
|
return deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), id.getId(), pageLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removeEntity(DeviceEntity entity) {
|
protected void removeEntity(Device entity) {
|
||||||
unassignDeviceFromCustomer(new DeviceId(entity.getId()));
|
unassignDeviceFromCustomer(new DeviceId(entity.getUuidId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.thingsboard.server.common.data.Event;
|
import org.thingsboard.server.common.data.Event;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.page.TimePageLink;
|
import org.thingsboard.server.common.data.page.TimePageLink;
|
||||||
import org.thingsboard.server.dao.AbstractSearchTimeDao;
|
import org.thingsboard.server.dao.CassandraAbstractSearchTimeDao;
|
||||||
import org.thingsboard.server.dao.DaoUtil;
|
import org.thingsboard.server.dao.DaoUtil;
|
||||||
import org.thingsboard.server.dao.model.EventEntity;
|
import org.thingsboard.server.dao.model.EventEntity;
|
||||||
import org.thingsboard.server.dao.model.ModelConstants;
|
import org.thingsboard.server.dao.model.ModelConstants;
|
||||||
@ -41,7 +41,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.*;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CassandraBaseEventDao extends AbstractSearchTimeDao<EventEntity, Event> implements EventDao {
|
public class CassandraBaseEventDao extends CassandraAbstractSearchTimeDao<EventEntity, Event> implements EventDao {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<EventEntity> getColumnFamilyClass() {
|
protected Class<EventEntity> getColumnFamilyClass() {
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright © 2016-2017 The Thingsboard Authors
|
* Copyright © 2016-2017 The Thingsboard Authors
|
||||||
* <p>
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* <p>
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* <p>
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|||||||
@ -36,11 +36,13 @@ import org.thingsboard.server.common.data.security.DeviceCredentialsType;
|
|||||||
import org.thingsboard.server.dao.device.DeviceCredentialsDao;
|
import org.thingsboard.server.dao.device.DeviceCredentialsDao;
|
||||||
import org.thingsboard.server.dao.device.DeviceCredentialsService;
|
import org.thingsboard.server.dao.device.DeviceCredentialsService;
|
||||||
import org.thingsboard.server.dao.device.DeviceService;
|
import org.thingsboard.server.dao.device.DeviceService;
|
||||||
import org.thingsboard.server.dao.model.DeviceCredentialsEntity;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@TestPropertySource(properties = {"cache.enabled = true"})
|
@TestPropertySource(properties = {"cache.enabled = true"})
|
||||||
public class DeviceCredentialsCacheTest extends AbstractServiceTest {
|
public class DeviceCredentialsCacheTest extends AbstractServiceTest {
|
||||||
@ -140,9 +142,8 @@ public class DeviceCredentialsCacheTest extends AbstractServiceTest {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DeviceCredentialsEntity createDummyDeviceCredentialsEntity(String deviceCredentialsId) {
|
private DeviceCredentials createDummyDeviceCredentialsEntity(String deviceCredentialsId) {
|
||||||
DeviceCredentialsEntity result = new DeviceCredentialsEntity();
|
DeviceCredentials result = new DeviceCredentials(new DeviceCredentialsId(UUIDs.timeBased()));
|
||||||
result.setId(UUIDs.timeBased());
|
|
||||||
result.setCredentialsId(deviceCredentialsId);
|
result.setCredentialsId(deviceCredentialsId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user