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 lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class DynamicValue<T> {
|
||||
|
||||
@JsonIgnore
|
||||
@ -31,12 +33,6 @@ public class DynamicValue<T> {
|
||||
this.inherit = false;
|
||||
}
|
||||
|
||||
public DynamicValue(DynamicValueSourceType sourceType, String sourceAttribute, boolean inherit) {
|
||||
this.sourceAttribute = sourceAttribute;
|
||||
this.sourceType = sourceType;
|
||||
this.inherit = inherit;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private final DynamicValueSourceType sourceType;
|
||||
@Getter
|
||||
|
||||
@ -388,15 +388,6 @@ class AlarmRuleState {
|
||||
EntityKeyValue ekv = null;
|
||||
if (value.getDynamicValue() != null) {
|
||||
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:
|
||||
ekv = data.getValue(new EntityKey(EntityKeyType.ATTRIBUTE, value.getDynamicValue().getSourceAttribute()));
|
||||
if (ekv == null) {
|
||||
@ -408,14 +399,18 @@ class AlarmRuleState {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ekv == null && value.getDynamicValue().isInherit()) {
|
||||
if(ekv != null || !value.getDynamicValue().isInherit()) {
|
||||
break;
|
||||
}
|
||||
case CURRENT_CUSTOMER:
|
||||
ekv = dynamicPredicateValueCtx.getCustomerValue(value.getDynamicValue().getSourceAttribute());
|
||||
if(ekv == null) {
|
||||
if(ekv != null || !value.getDynamicValue().isInherit()) {
|
||||
break;
|
||||
}
|
||||
case CURRENT_TENANT:
|
||||
ekv = dynamicPredicateValueCtx.getTenantValue(value.getDynamicValue().getSourceAttribute());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ekv;
|
||||
}
|
||||
|
||||
|
||||
@ -453,8 +453,6 @@ public class TbDeviceProfileNodeTest {
|
||||
AttributeKvEntry entry = attributeKvEntity.toData();
|
||||
ListenableFuture<List<AttributeKvEntry>> listListenableFutureWithLess =
|
||||
Futures.immediateFuture(Collections.singletonList(entry));
|
||||
ListenableFuture<Optional<AttributeKvEntry>> optionalListenableFutureWithLess =
|
||||
Futures.immediateFuture(Optional.of(entry));
|
||||
|
||||
KeyFilter lowTempFilter = new KeyFilter();
|
||||
lowTempFilter.setKey(new EntityKey(EntityKeyType.TIME_SERIES, "temperature"));
|
||||
@ -490,8 +488,6 @@ public class TbDeviceProfileNodeTest {
|
||||
Mockito.when(ctx.getAttributesService()).thenReturn(attributesService);
|
||||
Mockito.when(attributesService.find(eq(tenantId), eq(deviceId), Mockito.anyString(), Mockito.anySet()))
|
||||
.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(), "");
|
||||
Mockito.when(ctx.newMsg(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyString()))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user