use of com.walmartlabs.concord.client.ProcessApi in project concord by walmartlabs.
the class FormIT method testSubmitInInvalidProcessState.
@Test
public void testSubmitInInvalidProcessState() throws Exception {
Payload payload = new Payload().archive(resource("form"));
// ---
ConcordProcess proc = concord.processes().start(payload);
expectStatus(proc, ProcessEntry.StatusEnum.SUSPENDED);
// ---
List<FormListEntry> forms = proc.forms();
assertEquals(1, forms.size());
// change process status to emulate resuming from another form
ProcessApi api = new ProcessApi(concord.apiClient());
api.updateStatus(proc.instanceId(), UUID.randomUUID().toString(), ProcessEntry.StatusEnum.RESUMING.getValue());
// form data
String firstName = "john_" + randomString();
String lastName = "smith_" + randomString();
int age = ThreadLocalRandom.current().nextInt(100);
Map<String, Object> data = new HashMap<>();
data.put("lastName", lastName);
data.put("firstName", firstName);
data.put("age", age);
try {
proc.submitForm(forms.get(0).getName(), data);
fail("exception expected");
} catch (Exception e) {
// ignore
}
// change process status back to emulate another form submitted
api.updateStatus(proc.instanceId(), UUID.randomUUID().toString(), ProcessEntry.StatusEnum.SUSPENDED.getValue());
forms = proc.forms();
assertEquals(1, forms.size());
FormListEntry myForm = forms.get(0);
assertFalse(myForm.isCustom());
String formName = myForm.getName();
assertEquals("myForm", formName);
FormSubmitResponse fsr = proc.submitForm(formName, data);
assertTrue(fsr.isOk());
assertTrue(fsr.getErrors() == null || fsr.getErrors().isEmpty());
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
// ---
proc.assertLog(".*firstName=" + firstName + ".*");
proc.assertLog(".*lastName=" + lastName + ".*");
proc.assertLog(".*age=" + age + ".*");
}
use of com.walmartlabs.concord.client.ProcessApi in project concord by walmartlabs.
the class FormsIT method testDateTimeField.
@Test
public void testDateTimeField() throws Exception {
ApiClient apiClient = serverRule.getClient();
// ---
byte[] payload = archive(FormsIT.class.getResource("dateTimeField").toURI());
Map<String, Object> input = new HashMap<>();
input.put("archive", payload);
ProcessApi processApi = new ProcessApi(apiClient);
StartProcessResponse spr = serverRule.start(input);
assertNotNull(spr.getInstanceId());
ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
// ---
consoleRule.login(Concord.ADMIN_API_KEY);
String url = "/#/process/" + pir.getInstanceId();
consoleRule.navigateToRelative(url);
WebElement wizardButton = consoleRule.waitFor(By.id("formWizardButton"));
wizardButton.click();
WebElement dateField = consoleRule.waitFor(By.name("dateField"));
dateField.sendKeys("2019-09-04");
WebElement dateTimeField = consoleRule.waitFor(By.name("dateTimeField"));
dateTimeField.sendKeys("2019-09-04T01:05:00.000-04:00");
// close the popup
consoleRule.waitFor(By.id("root")).click();
Thread.sleep(1000);
WebElement submitButton = consoleRule.waitFor(By.id("formSubmitButton"));
submitButton.click();
// ---
pir = waitForCompletion(processApi, pir.getInstanceId());
byte[] ab = serverRule.getLog(pir.getLogFileName());
assertLog(".*dateField=2019-09-04.*", ab);
assertLog(".*dateTimeField=2019-09-04T05:05:00.000Z.*", ab);
}
use of com.walmartlabs.concord.client.ProcessApi in project concord by walmartlabs.
the class DependenciesIT method testUploadAndRun.
@Test
public void testUploadAndRun() throws Exception {
String dep = "file:///" + ITConstants.DEPENDENCIES_DIR + "/example.jar";
String request = "{ \"entryPoint\": \"main\", \"dependencies\": [ \"" + dep + "\" ] }";
Path tmpDir = createTempDir();
Path requestFile = tmpDir.resolve(Constants.Files.CONFIGURATION_FILE_NAME);
Files.write(requestFile, Collections.singletonList(request));
Path src = Paths.get(DependenciesIT.class.getResource("deps").toURI());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ZipArchiveOutputStream zip = new ZipArchiveOutputStream(baos)) {
IOUtils.zip(zip, src);
IOUtils.zip(zip, tmpDir);
}
byte[] payload = baos.toByteArray();
// ---
ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
assertNotNull(spr.getInstanceId());
ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, psr.getStatus());
// ---
byte[] ab = getLog(psr.getLogFileName());
assertLog(".*Hello!.*", ab);
}
use of com.walmartlabs.concord.client.ProcessApi in project concord by walmartlabs.
the class DependencyManagerIT method test.
@Test
public void test() throws Exception {
byte[] payload = archive(DependencyManagerIT.class.getResource("dependencyManager").toURI());
Map<String, Object> input = new HashMap<>();
input.put("archive", payload);
Map<String, Object> cfg = new HashMap<>();
cfg.put("dependencies", new String[] { "mvn://com.walmartlabs.concord.it.tasks:dependency-manager-test:" + ITConstants.PROJECT_VERSION });
String url = "http://" + env("IT_DOCKER_HOST_ADDR", "localhost") + ":" + rule.getPort() + "/item.txt";
cfg.put("arguments", Collections.singletonMap("url", url));
input.put("request", cfg);
StartProcessResponse spr = start(input);
// ---
ProcessApi processApi = new ProcessApi(getApiClient());
ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
byte[] ab = getLog(pir.getLogFileName());
assertLog(".*downloading.*", ab);
assertLog(".*using a cached copy.*", ab);
assertLog(".*Got: Hello!.*", ab);
}
use of com.walmartlabs.concord.client.ProcessApi in project concord by walmartlabs.
the class DockerAnsibleIT method test.
@Test
public void test() throws Exception {
byte[] payload = archive(DockerIT.class.getResource("dockerAnsible").toURI(), ITConstants.DEPENDENCIES_DIR);
Map<String, Object> input = new HashMap<>();
input.put("archive", payload);
input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE);
StartProcessResponse spr = start(input);
// --
ProcessApi processApi = new ProcessApi(getApiClient());
ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
assertNotNull(pir.getLogFileName());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
byte[] ab = getLog(pir.getLogFileName());
assertLog(".*\"msg\": \"Hello from Docker!\".*", ab);
// --
File resp = processApi.downloadAttachment(pir.getInstanceId(), "ansible_stats.json");
assertNotNull(resp);
}
Aggregations