### Question:
JiraTask implements Task { @Override public void execute(Context ctx) { Map<String, Object> result = delegate(ctx).execute(TaskParams.of(new ContextVariables(ctx), defaults)); result.forEach(ctx::setVariable); } @Inject  JiraTask(SecretService secretService); @Override void execute(Context ctx); String getStatus(@InjectVariable("context") Context ctx, String issueKey);  }### Answer:
@Test public void testCreateIssueWithBasicAuth() throws Exception { Map<String, Object> auth = new HashMap<>(); Map<String, Object> basic = new HashMap<>(); basic.put("username", "user"); basic.put("password", "pass"); auth.put("basic", basic); String url = rule.baseUrl() + "/"; initCxtForRequest(mockContext, "CREATEISSUE", url, "projKey", "summary", "description", "requestorUid", "bug", auth); task.execute(mockContext); }
@Test public void testCreateIssueWithSecret() throws Exception { Map<String, Object> auth = new HashMap<>(); Map<String, Object> secret = new HashMap<>(); secret.put("name", "secret"); secret.put("org", "organization"); auth.put("secret", secret); String url = rule.baseUrl() + "/"; initCxtForRequest(mockContext, "CREATEISSUE", url, "projKey", "summary", "description", "requestorUid", "bug", auth); task.execute(mockContext); }
@Test public void testAddAttachment() { when(mockContext.getVariable("apiUrl")).thenReturn(rule.baseUrl() + "/"); when(mockContext.getVariable("action")).thenReturn("addAttachment"); when(mockContext.getVariable("issueKey")).thenReturn("issueId"); when(mockContext.getVariable("userId")).thenReturn("userId"); when(mockContext.getVariable("password")).thenReturn("password"); when(mockContext.getVariable("filePath")).thenReturn("src/test/resources/sample.txt"); task.execute(mockContext); }
@Test public void testCurrentStatus() { when(mockContext.getVariable("action")).thenReturn("currentStatus"); when(mockContext.getVariable("apiUrl")).thenReturn(rule.baseUrl() + "/"); when(mockContext.getVariable("issueKey")).thenReturn("issueId"); when(mockContext.getVariable("userId")).thenReturn("userId"); when(mockContext.getVariable("password")).thenReturn("password"); doAnswer((Answer<Void>) invocation -> { response = (String) invocation.getArguments()[1]; return null; }).when(mockContext).setVariable(ArgumentMatchers.anyString(), ArgumentMatchers.any()); task.execute(mockContext); Assert.assertNotNull(response); Assert.assertEquals("Open", response); }