### Question:
SmtpTaskV2 implements Task { @Override public TaskResult execute(Variables input) throws Exception { Map<String, Object> smtp = getCfg(ctx, input, Constants.SMTP_PARAMS_KEY, Constants.SMTP_KEY); Map<String, Object> mail = getCfg(ctx, input, Constants.MAIL_PARAMS_KEY, Constants.MAIL_KEY); Path baseDir = ctx.workingDirectory(); Object scope = getScope(ctx, mail); boolean debug = input.getBoolean(Constants.DEBUG_KEY, false); SmtpTaskUtils.send(smtp, mail, baseDir, scope, debug); return TaskResult.success(); } @Inject  SmtpTaskV2(Context ctx); @Override TaskResult execute(Variables input);  }### Answer:
@Test public void test() throws Exception { int port = mailServer.getSmtp().getPort(); Map<String, Object> smtpParams = new HashMap<>(); smtpParams.put("host", "localhost"); smtpParams.put("port", port); Map<String, Object> mail = new HashMap<>(); mail.put("from", "me@localhost"); mail.put("to", "you@localhost"); mail.put("message", "Hello!"); Context ctx = mock(Context.class); when(ctx.workingDirectory()).thenReturn(Paths.get(System.getProperty("user.dir"))); when(ctx.variables()).thenReturn(new MapBackedVariables(Collections.singletonMap("smtpParams", smtpParams))); SmtpTaskV2 t = new SmtpTaskV2(ctx); t.execute(new MapBackedVariables(Collections.singletonMap("mail", mail))); MimeMessage[] messages = mailServer.getReceivedMessages(); assertEquals(1, messages.length); assertEquals("Hello!\r\n", messages[0].getContent()); mailServer.reset(); }