use of com.walmartlabs.concord.sdk.Task in project concord by walmartlabs.
the class YamlParserTest method test074.
@Test
public void test074() throws Exception {
deploy("074.yml");
register("__withItemsUtils", new StepConverter.WithItemsUtilsTask());
register("__retryUtils", new YamlTaskStepConverter.RetryUtilsTask());
MyLogger task = spy(new MyLogger());
register("log", task);
TestErrorTask http = spy(new TestErrorTask());
register("http", http);
// ---
String key = UUID.randomUUID().toString();
start(key, "default");
// ---
ArgumentCaptor<ExecutionContext> captor = ArgumentCaptor.forClass(ExecutionContext.class);
verify(http, times(12)).execute(captor.capture());
List<String> urls = captor.getAllValues().stream().map(e -> (String) e.getVariable("url")).collect(Collectors.toList());
assertContains("https://nonexistant.example.com/test/a", urls, 4);
assertContains("https://nonexistant.example.com/test/b", urls, 4);
assertContains("https://nonexistant.example.com/test/c", urls, 4);
assertTrue(urls.isEmpty());
verifyNoMoreInteractions(http);
}
use of com.walmartlabs.concord.sdk.Task in project concord-plugins by walmartlabs.
the class S3TaskTest method test.
@Test
@SuppressWarnings("unchecked")
public void test() throws Exception {
String data = "Hello!";
Path p = Files.createTempFile("test", ".txt");
Files.write(p, data.getBytes());
Map<String, Object> auth = new HashMap<>();
auth.put("accessKey", System.getenv("AWS_ACCESS_KEY"));
auth.put("secretKey", System.getenv("AWS_SECRET_KEY"));
Map<String, Object> args = new HashMap<>();
args.put(com.walmartlabs.concord.sdk.Constants.Context.WORK_DIR_KEY, p.getParent().toAbsolutePath().toString());
args.put(ACTION_KEY, TaskParams.Action.PUTOBJECT.name());
args.put(PutObjectParams.BUCKET_NAME_KEY, "ibodrov-test");
args.put(PutObjectParams.OBJECT_KEY, "xyz");
args.put(PutObjectParams.SRC_KEY, p.getFileName().toString());
args.put(PutObjectParams.ENDPOINT_KEY, System.getenv("AWS_ENDPOINT"));
args.put(PutObjectParams.REGION_KEY, System.getenv("AWS_REGION"));
args.put(PutObjectParams.PATH_STYLE_ACCESS_KEY, true);
args.put(PutObjectParams.AUTH_KEY, Collections.singletonMap("basic", auth));
MockContext ctx = new MockContext(args);
Task t = new S3Task();
t.execute(ctx);
Map<String, Object> r = (Map<String, Object>) ctx.getVariable(Constants.RESULT_KEY);
assertTrue((Boolean) r.get("ok"));
// ---
args.put(Constants.ACTION_KEY, TaskParams.Action.GETOBJECT.name());
ctx = new MockContext(args);
t.execute(ctx);
r = (Map<String, Object>) ctx.getVariable(Constants.RESULT_KEY);
assertTrue((Boolean) r.get("ok"));
String storedObject = (String) r.get("path");
String s = new String(Files.readAllBytes(p.getParent().resolve(storedObject)));
assertEquals(data, s);
}
Aggregations