### Question:
TbMsgToEmailNode implements TbNode { @Override public void onMsg(TbContext ctx, TbMsg msg) { try { EmailPojo email = convert(msg); TbMsg emailMsg = buildEmailMsg(ctx, msg, email); ctx.tellNext(emailMsg, SUCCESS); } catch (Exception ex) { log.warn("Can not convert message to email " + ex.getMessage()); ctx.tellFailure(msg, ex); } }  @Override void init(TbContext ctx, TbNodeConfiguration configuration); @Override void onMsg(TbContext ctx, TbMsg msg); @Override void destroy();  }### Answer:
@Test public void msgCanBeConverted() throws IOException { initWithScript(); metaData.putValue("username", "oreo"); metaData.putValue("userEmail", "user@email.io"); metaData.putValue("name", "temp"); metaData.putValue("passed", "5"); metaData.putValue("count", "100"); TbMsg msg = new TbMsg(UUIDs.timeBased(), "USER", originator, metaData, rawJson, ruleChainId, ruleNodeId, 0L); emailNode.onMsg(ctx, msg); ArgumentCaptor<TbMsg> msgCaptor = ArgumentCaptor.forClass(TbMsg.class); ArgumentCaptor<String> typeCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<EntityId> originatorCaptor = ArgumentCaptor.forClass(EntityId.class); ArgumentCaptor<TbMsgMetaData> metadataCaptor = ArgumentCaptor.forClass(TbMsgMetaData.class); ArgumentCaptor<String> dataCaptor = ArgumentCaptor.forClass(String.class); verify(ctx).transformMsg(msgCaptor.capture(), typeCaptor.capture(), originatorCaptor.capture(), metadataCaptor.capture(), dataCaptor.capture()); assertEquals("SEND_EMAIL", typeCaptor.getValue()); assertEquals(originator, originatorCaptor.getValue()); assertEquals("oreo", metadataCaptor.getValue().getValue("username")); assertNotSame(metaData, metadataCaptor.getValue()); EmailPojo actual = new ObjectMapper().readValue(dataCaptor.getValue().getBytes(), EmailPojo.class); EmailPojo expected = new EmailPojo.EmailPojoBuilder() .from("test@mail.org") .to("user@email.io") .subject("Hi oreo there") .body("temp is to high. Current 5 and 100") .build(); assertEquals(expected, actual); }