PublishedEventRpcHandlerUtil implements Serializable { public static boolean isTemplateModelValue(Component instance, JsonValue argValue, Class<?> convertedType) { return instance instanceof PolymerTemplate && argValue instanceof JsonObject && ((PolymerTemplate<?>) instance) .isSupportedClass(convertedType) && ((JsonObject) argValue) .hasKey("nodeId"); }  static boolean isTemplateModelValue(Component instance,
            JsonValue argValue, Class<?> convertedType); static Object getTemplateItem(Component template,
                JsonObject argValue, Type convertedType);  }
@Test public void templateWithModel_payloadAsExpected_returnsTrue() { TestModule instance = new TestModule(); JsonObject json = Json.createObject(); json.put("nodeId", 0); json.put("message", "bar"); boolean isModelValue = PublishedEventRpcHandlerUtil .isTemplateModelValue(instance, json, String.class); Assert.assertTrue(isModelValue); }
@Test public void templateWithModel_payloadMissingNodeId_returnsFalse() { TestModule instance = new TestModule(); JsonObject json = Json.createObject(); json.put("message", "bar"); boolean isModelValue = PublishedEventRpcHandlerUtil .isTemplateModelValue(instance, json, String.class); Assert.assertFalse(isModelValue); }
@Test public void templateWithModel_unsupportedType_returnsFalse() { TestModule instance = new TestModule(); JsonObject json = Json.createObject(); json.put("message", "bar"); boolean isModelValue = PublishedEventRpcHandlerUtil .isTemplateModelValue(instance, json, Boolean.class); Assert.assertFalse(isModelValue); }
@Test public void templateWithModel_faultyPayloadAsNoJsonObject_returnsFalse() { TestModule instance = new TestModule(); boolean isModelValue = PublishedEventRpcHandlerUtil .isTemplateModelValue(instance, Json.createArray(), String.class); Assert.assertFalse(isModelValue); }
@Test public void normalComponent_returnsFalse() { TestComponent instance = new TestComponent(); JsonObject json = Json.createObject(); json.put("nodeId", 0); json.put("message", "bar"); boolean isModelValue = PublishedEventRpcHandlerUtil .isTemplateModelValue(instance, json, String.class); Assert.assertFalse(isModelValue); }