Code cleaning and fix of tests
This commit is contained in:
parent
6bf2b322af
commit
e70df09b08
@ -18,8 +18,10 @@ package org.thingsboard.server.common.data.query;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class DynamicValue<T> {
|
public class DynamicValue<T> {
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ -31,12 +33,6 @@ public class DynamicValue<T> {
|
|||||||
this.inherit = false;
|
this.inherit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynamicValue(DynamicValueSourceType sourceType, String sourceAttribute, boolean inherit) {
|
|
||||||
this.sourceAttribute = sourceAttribute;
|
|
||||||
this.sourceType = sourceType;
|
|
||||||
this.inherit = inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final DynamicValueSourceType sourceType;
|
private final DynamicValueSourceType sourceType;
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@ -388,15 +388,6 @@ class AlarmRuleState {
|
|||||||
EntityKeyValue ekv = null;
|
EntityKeyValue ekv = null;
|
||||||
if (value.getDynamicValue() != null) {
|
if (value.getDynamicValue() != null) {
|
||||||
switch (value.getDynamicValue().getSourceType()) {
|
switch (value.getDynamicValue().getSourceType()) {
|
||||||
case CURRENT_TENANT:
|
|
||||||
ekv = dynamicPredicateValueCtx.getTenantValue(value.getDynamicValue().getSourceAttribute());
|
|
||||||
break;
|
|
||||||
case CURRENT_CUSTOMER:
|
|
||||||
ekv = dynamicPredicateValueCtx.getCustomerValue(value.getDynamicValue().getSourceAttribute());
|
|
||||||
if(ekv == null && value.getDynamicValue().isInherit()) {
|
|
||||||
ekv = dynamicPredicateValueCtx.getTenantValue(value.getDynamicValue().getSourceAttribute());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CURRENT_DEVICE:
|
case CURRENT_DEVICE:
|
||||||
ekv = data.getValue(new EntityKey(EntityKeyType.ATTRIBUTE, value.getDynamicValue().getSourceAttribute()));
|
ekv = data.getValue(new EntityKey(EntityKeyType.ATTRIBUTE, value.getDynamicValue().getSourceAttribute()));
|
||||||
if (ekv == null) {
|
if (ekv == null) {
|
||||||
@ -408,12 +399,16 @@ class AlarmRuleState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ekv == null && value.getDynamicValue().isInherit()) {
|
if(ekv != null || !value.getDynamicValue().isInherit()) {
|
||||||
ekv = dynamicPredicateValueCtx.getCustomerValue(value.getDynamicValue().getSourceAttribute());
|
break;
|
||||||
if(ekv == null) {
|
|
||||||
ekv = dynamicPredicateValueCtx.getTenantValue(value.getDynamicValue().getSourceAttribute());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case CURRENT_CUSTOMER:
|
||||||
|
ekv = dynamicPredicateValueCtx.getCustomerValue(value.getDynamicValue().getSourceAttribute());
|
||||||
|
if(ekv != null || !value.getDynamicValue().isInherit()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CURRENT_TENANT:
|
||||||
|
ekv = dynamicPredicateValueCtx.getTenantValue(value.getDynamicValue().getSourceAttribute());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ekv;
|
return ekv;
|
||||||
|
|||||||
@ -453,8 +453,6 @@ public class TbDeviceProfileNodeTest {
|
|||||||
AttributeKvEntry entry = attributeKvEntity.toData();
|
AttributeKvEntry entry = attributeKvEntity.toData();
|
||||||
ListenableFuture<List<AttributeKvEntry>> listListenableFutureWithLess =
|
ListenableFuture<List<AttributeKvEntry>> listListenableFutureWithLess =
|
||||||
Futures.immediateFuture(Collections.singletonList(entry));
|
Futures.immediateFuture(Collections.singletonList(entry));
|
||||||
ListenableFuture<Optional<AttributeKvEntry>> optionalListenableFutureWithLess =
|
|
||||||
Futures.immediateFuture(Optional.of(entry));
|
|
||||||
|
|
||||||
KeyFilter lowTempFilter = new KeyFilter();
|
KeyFilter lowTempFilter = new KeyFilter();
|
||||||
lowTempFilter.setKey(new EntityKey(EntityKeyType.TIME_SERIES, "temperature"));
|
lowTempFilter.setKey(new EntityKey(EntityKeyType.TIME_SERIES, "temperature"));
|
||||||
@ -490,8 +488,6 @@ public class TbDeviceProfileNodeTest {
|
|||||||
Mockito.when(ctx.getAttributesService()).thenReturn(attributesService);
|
Mockito.when(ctx.getAttributesService()).thenReturn(attributesService);
|
||||||
Mockito.when(attributesService.find(eq(tenantId), eq(deviceId), Mockito.anyString(), Mockito.anySet()))
|
Mockito.when(attributesService.find(eq(tenantId), eq(deviceId), Mockito.anyString(), Mockito.anySet()))
|
||||||
.thenReturn(listListenableFutureWithLess);
|
.thenReturn(listListenableFutureWithLess);
|
||||||
Mockito.when(attributesService.find(eq(tenantId), eq(tenantId), eq(DataConstants.SERVER_SCOPE), Mockito.anyString()))
|
|
||||||
.thenReturn(optionalListenableFutureWithLess);
|
|
||||||
|
|
||||||
TbMsg theMsg = TbMsg.newMsg("ALARM", deviceId, new TbMsgMetaData(), "");
|
TbMsg theMsg = TbMsg.newMsg("ALARM", deviceId, new TbMsgMetaData(), "");
|
||||||
Mockito.when(ctx.newMsg(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyString()))
|
Mockito.when(ctx.newMsg(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyString()))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user