use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project thingsboard by thingsboard.
the class DefaultGatewayNotificationsService method onDeviceDeleted.
@Override
public void onDeviceDeleted(Device device) {
Optional<DeviceId> gatewayDeviceId = getGatewayDeviceIdFromAdditionalInfoInDevice(device);
if (gatewayDeviceId.isPresent()) {
TextNode deletedDeviceNode = new TextNode(device.getName());
ToDeviceRpcRequest rpcRequest = formDeviceToGatewayRPCRequest(device.getTenantId(), gatewayDeviceId.get(), deletedDeviceNode, DEVICE_DELETED_METHOD_NAME);
deviceRpcService.processRestApiRpcRequest(rpcRequest, fromDeviceRpcResponse -> {
log.trace("Device deleted RPC with id: [{}] processed to gateway device with id: [{}], deleted device name: [{}]", rpcRequest.getId(), gatewayDeviceId, device.getName());
}, null);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project template-compiler by Squarespace.
the class ExprTest method testNumberFormatting.
@Test
public void testNumberFormatting() {
Context c = ctx();
// large magnitude
assertEquals(reduce("str(1e20)", c), new TextNode("100000000000000000000"));
assertEquals(reduce("str(1e21)", c), new TextNode("1e+21"));
assertEquals(reduce("str(1e300)", c), new TextNode("1e+300"));
// small magnitude
assertEquals(reduce("str(1e-5)", c), new TextNode("0.00001"));
assertEquals(reduce("str(1e-6)", c), new TextNode("0.000001"));
assertEquals(reduce("str(1e-7)", c), new TextNode("1e-7"));
assertEquals(reduce("str(1e-20)", c), new TextNode("1e-20"));
assertEquals(reduce("str(1e-21)", c), new TextNode("1e-21"));
assertEquals(reduce("str(1e-300)", c), new TextNode("1e-300"));
// negative large magnitude
assertEquals(reduce("str(-1e20)", c), new TextNode("-100000000000000000000"));
assertEquals(reduce("str(-1e21)", c), new TextNode("-1e+21"));
assertEquals(reduce("str(-1e300)", c), new TextNode("-1e+300"));
// negative small magnitude
assertEquals(reduce("str(-1e-5)", c), new TextNode("-0.00001"));
assertEquals(reduce("str(-1e-6)", c), new TextNode("-0.000001"));
assertEquals(reduce("str(-1e-7)", c), new TextNode("-1e-7"));
assertEquals(reduce("str(-1e-20)", c), new TextNode("-1e-20"));
assertEquals(reduce("str(-1e-21)", c), new TextNode("-1e-21"));
assertEquals(reduce("str(-1e-300)", c), new TextNode("-1e-300"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project template-compiler by Squarespace.
the class ExprTest method testTypeConversions.
@Test
public void testTypeConversions() {
Context c = ctx("{\"a\":{\"b\":3.75,\"c\":\"3.1415\",\"flag\":true,\"nil\":null,\"s\":\"foo\"}," + "\"n0\":\"-0x1234\",\"n1\":\"-1.2e21\",\"n2\":\"--1.2\",\"n3\":\"--0x1234\"}");
assertEquals(reduce("str()", c), null);
assertEquals(reduce("str(\"\")", c), new TextNode(""));
assertEquals(reduce("str(\"foobar\")", c), new TextNode("foobar"));
assertEquals(reduce("str(zzz)", c), new TextNode("null"));
assertEquals(reduce("str(a.b)", c), new TextNode("3.75"));
assertEquals(reduce("str(true)", c), new TextNode("true"));
assertEquals(reduce("str(false)", c), new TextNode("false"));
assertEquals(reduce("str(null)", c), new TextNode("null"));
assertEquals(reduce("str(a.flag)", c), new TextNode("true"));
assertEquals(reduce("str(a.nil)", c), new TextNode("null"));
assertEquals(reduce("str(a.s)", c), new TextNode("foo"));
assertEquals(reduce("str(-Infinity)", c), new TextNode("-Infinity"));
assertEquals(reduce("str(Infinity)", c), new TextNode("Infinity"));
assertEquals(reduce("str(NaN)", c), new TextNode("NaN"));
assertEquals(reduce("str(12e20)", c), new TextNode("1.2e+21"));
assertEquals(reduce("num()", c), null);
assertEquals(reduce("num(zzz)", c), new DoubleNode(0));
assertEquals(reduce("num(a.c)", c), new DoubleNode(3.1415));
assertEquals(reduce("num(\"0xcafe\")", c), new DoubleNode(0xcafe));
assertEquals(reduce("num(\"0Xcafe\")", c), new DoubleNode(0xcafe));
assertEquals(reduce("num(\"000123\")", c), new DoubleNode(123));
assertEquals(reduce("num(\"0x\")", c), new DoubleNode(Double.NaN));
assertEquals(reduce("num(\"0xfoo\")", c), new DoubleNode(Double.NaN));
assertEquals(reduce("num(\"123foo\")", c), new DoubleNode(Double.NaN));
assertEquals(reduce("num(\"-123\")", c), new DoubleNode(-123));
assertEquals(reduce("num(\"-\")", c), new DoubleNode(Double.NaN));
assertEquals(reduce("num(\"--123\")", c), new DoubleNode(Double.NaN));
assertEquals(reduce("num(n0)", c), new DoubleNode(-0x1234));
assertEquals(reduce("num(n1)", c), new DoubleNode(-1.2e21));
assertEquals(reduce("num(n2)", c), new DoubleNode(Double.NaN));
assertEquals(reduce("num(n3)", c), new DoubleNode(Double.NaN));
assertEquals(reduce("bool()", c), null);
assertEquals(reduce("bool(zzz)", c), BooleanNode.FALSE);
assertEquals(reduce("bool(a.b)", c), BooleanNode.TRUE);
assertEquals(reduce("bool(\"foo\")", c), BooleanNode.TRUE);
assertEquals(reduce("str(num(bool(true)))", c), new TextNode("1"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project template-compiler by Squarespace.
the class ExprTest method testConcatenate.
@Test
public void testConcatenate() {
Context c = new Context(JsonUtils.decode("{}"));
assertEquals(reduce("\"foo\" + 1", c), new TextNode("foo1"));
assertEquals(reduce("\"foo\" + null", c), new TextNode("foonull"));
assertEquals(reduce("\"foo\" + true", c), new TextNode("footrue"));
assertEquals(reduce("\"foo\" + false", c), new TextNode("foofalse"));
assertEquals(reduce("\"\" + false", c), new TextNode("false"));
assertEquals(reduce("1 + \"foo\"", c), new TextNode("1foo"));
assertEquals(reduce("null + \"bar\"", c), new TextNode("nullbar"));
assertEquals(reduce("true + \"bar\"", c), new TextNode("truebar"));
assertEquals(reduce("false + \"bar\"", c), new TextNode("falsebar"));
assertEquals(reduce("false + \"\"", c), new TextNode("false"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project template-compiler by Squarespace.
the class MessageFormatsTest method testDecimal.
@Test
public void testDecimal() {
String actual;
CLDR cldr = CLDR.get("en");
MessageFormats formats = new MessageFormats(cldr);
formats.setTimeZone("America/New_York");
String message = "{0 decimal style:short}";
actual = formats.formatter().format(message, args().add(new TextNode("12345.789")));
assertEquals(actual, "12K");
}
Aggregations