revert default behavior for no presense proto keys
This commit is contained in:
parent
cf2b1605f6
commit
60ccd7a0b0
@ -130,17 +130,12 @@ public abstract class AbstractCoapTimeseriesIntegrationTest extends AbstractCoap
|
||||
}
|
||||
assertNotNull(values);
|
||||
|
||||
if (withTs) {
|
||||
assertTs(values, expectedKeys, 10000, 0);
|
||||
}
|
||||
if (presenceFieldsTest) {
|
||||
if (withTs) {
|
||||
assertTsForExplicitProtoFieldValues(values, expectedKeys, 10000, 0);
|
||||
assertExplicitProtoFieldValuesWithTs(values);
|
||||
} else {
|
||||
assertExplicitProtoFieldValues(values);
|
||||
}
|
||||
assertExplicitProtoFieldValues(values);
|
||||
} else {
|
||||
if (withTs) {
|
||||
assertTs(values, expectedKeys, 10000, 0);
|
||||
}
|
||||
assertValues(values, 0);
|
||||
}
|
||||
}
|
||||
@ -208,14 +203,4 @@ public abstract class AbstractCoapTimeseriesIntegrationTest extends AbstractCoap
|
||||
}
|
||||
}
|
||||
|
||||
private void assertExplicitProtoFieldValuesWithTs(Map<String, List<Map<String, Object>>> deviceValues) {
|
||||
assertEquals(1, deviceValues.size());
|
||||
List<Map<String, Object>> tsKv = deviceValues.get("key5");
|
||||
assertEquals("{\"someArray\":[1,2,3],\"someNestedObject\":{\"key\":\"value\"}}", tsKv.get(0).get("value"));
|
||||
}
|
||||
|
||||
private void assertTsForExplicitProtoFieldValues(Map<String, List<Map<String, Object>>> deviceValues, List<String> expectedKeys, int ts, int arrayIndex) {
|
||||
assertEquals(ts, deviceValues.get(expectedKeys.get(0)).get(arrayIndex).get("ts"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -274,7 +274,6 @@ public abstract class AbstractCoapTimeseriesProtoIntegrationTest extends Abstrac
|
||||
assertNotNull(valuesDescriptor);
|
||||
|
||||
DynamicMessage valuesMsg = valuesBuilder
|
||||
.setField(valuesDescriptor.findFieldByName("key4"), 0)
|
||||
.setField(valuesDescriptor.findFieldByName("key5"), jsonObject)
|
||||
.build();
|
||||
|
||||
@ -286,7 +285,7 @@ public abstract class AbstractCoapTimeseriesProtoIntegrationTest extends Abstrac
|
||||
.setField(postTelemetryMsgDescriptor.findFieldByName("values"), valuesMsg)
|
||||
.build();
|
||||
|
||||
processTestPostTelemetry(postTelemetryMsg.toByteArray(), Collections.singletonList("key5"), true, true);
|
||||
processTestPostTelemetry(postTelemetryMsg.toByteArray(), Arrays.asList("key1", "key2", "key3", "key4", "key5"), true, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -161,17 +161,12 @@ public abstract class AbstractMqttTimeseriesIntegrationTest extends AbstractMqtt
|
||||
}
|
||||
assertNotNull(values);
|
||||
|
||||
if (withTs) {
|
||||
assertTs(values, expectedKeys, 10000, 0);
|
||||
}
|
||||
if (presenceFieldsTest) {
|
||||
if (withTs) {
|
||||
assertTsForExplicitProtoFieldValues(values, expectedKeys, 10000, 0);
|
||||
assertExplicitProtoFieldValuesWithTs(values);
|
||||
} else {
|
||||
assertExplicitProtoFieldValues(values);
|
||||
}
|
||||
assertExplicitProtoFieldValues(values);
|
||||
} else {
|
||||
if (withTs) {
|
||||
assertTs(values, expectedKeys, 10000, 0);
|
||||
}
|
||||
assertValues(values, 0);
|
||||
}
|
||||
}
|
||||
@ -292,16 +287,6 @@ public abstract class AbstractMqttTimeseriesIntegrationTest extends AbstractMqtt
|
||||
}
|
||||
}
|
||||
|
||||
private void assertExplicitProtoFieldValuesWithTs(Map<String, List<Map<String, Object>>> deviceValues) {
|
||||
assertEquals(1, deviceValues.size());
|
||||
List<Map<String, Object>> tsKv = deviceValues.get("key5");
|
||||
assertEquals("{\"someArray\":[1,2,3],\"someNestedObject\":{\"key\":\"value\"}}", tsKv.get(0).get("value"));
|
||||
}
|
||||
|
||||
private void assertTsForExplicitProtoFieldValues(Map<String, List<Map<String, Object>>> deviceValues, List<String> expectedKeys, int ts, int arrayIndex) {
|
||||
assertEquals(ts, deviceValues.get(expectedKeys.get(0)).get(arrayIndex).get("ts"));
|
||||
}
|
||||
|
||||
private void assertTs(Map<String, List<Map<String, Object>>> deviceValues, List<String> expectedKeys, int ts, int arrayIndex) {
|
||||
assertEquals(ts, deviceValues.get(expectedKeys.get(0)).get(arrayIndex).get("ts"));
|
||||
assertEquals(ts, deviceValues.get(expectedKeys.get(1)).get(arrayIndex).get("ts"));
|
||||
|
||||
@ -268,7 +268,6 @@ public abstract class AbstractMqttTimeseriesProtoIntegrationTest extends Abstrac
|
||||
assertNotNull(valuesDescriptor);
|
||||
|
||||
DynamicMessage valuesMsg = valuesBuilder
|
||||
.setField(valuesDescriptor.findFieldByName("key4"), 0)
|
||||
.setField(valuesDescriptor.findFieldByName("key5"), jsonObject)
|
||||
.build();
|
||||
|
||||
@ -280,7 +279,7 @@ public abstract class AbstractMqttTimeseriesProtoIntegrationTest extends Abstrac
|
||||
.setField(postTelemetryMsgDescriptor.findFieldByName("values"), valuesMsg)
|
||||
.build();
|
||||
|
||||
processTelemetryTest(POST_DATA_TELEMETRY_TOPIC, Collections.singletonList("key5"), postTelemetryMsg.toByteArray(), true, true);
|
||||
processTelemetryTest(POST_DATA_TELEMETRY_TOPIC, Arrays.asList("key1", "key2", "key3", "key4", "key5"), postTelemetryMsg.toByteArray(), true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -159,7 +159,7 @@ public class ProtoCoapAdaptor implements CoapTransportAdaptor {
|
||||
|
||||
private String dynamicMsgToJson(byte[] bytes, Descriptors.Descriptor descriptor) throws InvalidProtocolBufferException {
|
||||
DynamicMessage dynamicMessage = DynamicMessage.parseFrom(descriptor, bytes);
|
||||
return JsonFormat.printer().print(dynamicMessage);
|
||||
return JsonFormat.printer().includingDefaultValueFields().print(dynamicMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ public class ProtoMqttAdaptor implements MqttTransportAdaptor {
|
||||
|
||||
private String dynamicMsgToJson(byte[] bytes, Descriptors.Descriptor descriptor) throws InvalidProtocolBufferException {
|
||||
DynamicMessage dynamicMessage = DynamicMessage.parseFrom(descriptor, bytes);
|
||||
return JsonFormat.printer().print(dynamicMessage);
|
||||
return JsonFormat.printer().includingDefaultValueFields().print(dynamicMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user