PublishedEventRpcHandlerUtil implements Serializable { public static Object getTemplateItem(Component template, JsonObject argValue, Type convertedType) { final Optional<UI> ui = template.getUI(); if (ui.isPresent()) { StateNode node = ui.get().getInternals().getStateTree() .getNodeById((int) argValue.getNumber("nodeId")); ModelType propertyType = ((PolymerTemplate<?>) template) .getModelType(convertedType); return propertyType.modelToApplication(node); } throw new IllegalArgumentException( "Event sent for a non attached template component"); }  static boolean isTemplateModelValue(Component instance,
            JsonValue argValue, Class<?> convertedType); static Object getTemplateItem(Component template,
                JsonObject argValue, Type convertedType);  }
@Test(expected = IllegalArgumentException.class) public void templateNotConnectedToUI_throws() throws NoSuchMethodException { TestModule instance = new TestModule(); JsonObject json = Json.createObject(); json.put("nodeId", 0); json.put("message", "bar"); final Type messageType = ModelClass.class .getMethod("setMessage", String.class) .getGenericParameterTypes()[0]; PublishedEventRpcHandlerUtil .getTemplateItem(instance, json, messageType); }