Search in sources :

Example 6 with FormListEntry

use of com.walmartlabs.concord.client.FormListEntry in project concord by walmartlabs.

the class FormIT method testFormOnCancel.

/**
 * Start a process with a form and a sleep task. Cancel the process while sleeping
 * and check the onCancel process for variables. We expect the submitted values
 * to be available in the onCancel flow.
 */
@Test
public void testFormOnCancel() throws Exception {
    Payload payload = new Payload().archive(resource("formOnCancel"));
    // ---
    ConcordProcess proc = concord.processes().start(payload);
    expectStatus(proc, ProcessEntry.StatusEnum.SUSPENDED);
    List<FormListEntry> forms = proc.forms();
    assertEquals(1, forms.size());
    FormListEntry myForm = forms.get(0);
    String firstName = "john_" + randomString();
    int age = ThreadLocalRandom.current().nextInt(100);
    Map<String, Object> data = new HashMap<>();
    data.put("firstName", firstName);
    data.put("age", age);
    FormSubmitResponse fsr = proc.submitForm(myForm.getName(), data);
    assertTrue(fsr.isOk());
    // ---
    expectStatus(proc, ProcessEntry.StatusEnum.RUNNING);
    proc.kill();
    expectStatus(proc, ProcessEntry.StatusEnum.CANCELLED);
    ConcordProcess child = concord.processes().get(proc.waitForChildStatus(ProcessEntry.StatusEnum.FINISHED).getInstanceId());
    child.assertLog(".*myForm.firstName: " + firstName + ".*");
    child.assertLog(".*myForm.age: " + age + ".*");
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) FormListEntry(com.walmartlabs.concord.client.FormListEntry) FormSubmitResponse(com.walmartlabs.concord.client.FormSubmitResponse) Payload(ca.ibodrov.concord.testcontainers.Payload) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) Test(org.junit.jupiter.api.Test)

Example 7 with FormListEntry

use of com.walmartlabs.concord.client.FormListEntry in project concord by walmartlabs.

the class FormIT method test.

/**
 * A straightforward single form process.
 */
@Test
public void test() 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());
    // ---
    FormListEntry myForm = forms.get(0);
    assertFalse(myForm.isCustom());
    String formName = myForm.getName();
    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);
    FormSubmitResponse fsr = proc.submitForm(formName, data);
    assertTrue(fsr.isOk());
    assertTrue(fsr.getErrors() == null || fsr.getErrors().isEmpty());
    assertEquals(0, proc.forms().size());
    expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
    // ---
    proc.assertLog(".*firstName=" + firstName + ".*");
    proc.assertLog(".*lastName=" + lastName + ".*");
    proc.assertLog(".*age=" + age + ".*");
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) FormListEntry(com.walmartlabs.concord.client.FormListEntry) FormSubmitResponse(com.walmartlabs.concord.client.FormSubmitResponse) Payload(ca.ibodrov.concord.testcontainers.Payload) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) Test(org.junit.jupiter.api.Test)

Aggregations

ConcordProcess (ca.ibodrov.concord.testcontainers.ConcordProcess)7 Payload (ca.ibodrov.concord.testcontainers.Payload)7 FormListEntry (com.walmartlabs.concord.client.FormListEntry)7 Test (org.junit.jupiter.api.Test)7 FormSubmitResponse (com.walmartlabs.concord.client.FormSubmitResponse)6 ITUtils.randomString (com.walmartlabs.concord.it.common.ITUtils.randomString)6 ProcessEntry (com.walmartlabs.concord.client.ProcessEntry)2 HashMap (java.util.HashMap)2 ProcessApi (com.walmartlabs.concord.client.ProcessApi)1 Utils.resourceToString (com.walmartlabs.concord.it.runtime.v2.Utils.resourceToString)1