Search in sources :

Example 1 with ProcessEntry

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

the class ProcessIT method testTags.

@Test
public void testTags() throws Exception {
    byte[] archive = archive(ProcessIT.class.getResource("example").toURI());
    ConcordProcess parent = concord.processes().start(new Payload().archive(archive));
    // ---
    parent.expectStatus(StatusEnum.FINISHED);
    // ---
    archive = archive(ProcessIT.class.getResource("tags").toURI());
    Payload payload = new Payload().archive(archive).parent(parent.instanceId());
    ConcordProcess child = concord.processes().start(payload);
    // ---
    child.expectStatus(StatusEnum.FINISHED);
    // ---
    List<ProcessEntry> l = parent.subprocesses("abc");
    assertTrue(l.isEmpty());
    l = parent.subprocesses("test");
    assertEquals(1, l.size());
    ProcessEntry e = l.get(0);
    assertEquals(child.instanceId(), e.getInstanceId());
    // ---
    l = concord.processes().list(ProcessListQuery.builder().addTags("xyz").build());
    assertTrue(l.isEmpty());
    l = concord.processes().list(ProcessListQuery.builder().addTags("IT").build());
    assertEquals(1, l.size());
    e = l.get(0);
    assertEquals(child.instanceId(), e.getInstanceId());
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) Payload(ca.ibodrov.concord.testcontainers.Payload) Test(org.junit.jupiter.api.Test)

Example 2 with ProcessEntry

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

the class FormIT method testFormValues.

@Test
public void testFormValues() throws Exception {
    Payload payload = new Payload().archive(resource("customFormValues"));
    // ---
    ConcordProcess proc = concord.processes().start(payload);
    ProcessEntry pe = expectStatus(proc, ProcessEntry.StatusEnum.SUSPENDED);
    // ---
    List<FormListEntry> forms = proc.forms();
    assertEquals(1, forms.size());
    // ---
    String formName = forms.get(0).getName();
    assertEquals("myForm", formName);
    // start session
    startCustomFormSession(concord, pe.getInstanceId(), formName);
    // get data.js
    Map<String, Object> dataJs = getDataJs(concord, pe.getInstanceId(), formName);
    Map<String, Object> values = MapUtils.get(dataJs, "values", Collections.emptyMap());
    assertEquals(4, values.size());
    assertEquals("Moo", values.get("firstName"));
    assertEquals("Xaa", values.get("lastName"));
    assertEquals(3, values.get("sum"));
    assertEquals(ImmutableMap.of("city", "Toronto", "province", "Ontario"), values.get("address"));
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) FormListEntry(com.walmartlabs.concord.client.FormListEntry) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) Payload(ca.ibodrov.concord.testcontainers.Payload) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessEntry

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

the class ProcessIT method testForkCheckpoints.

@Test
public void testForkCheckpoints() throws Exception {
    String forkTag = "fork_" + randomString();
    Payload payload = new Payload().arg("forkTag", forkTag).archive(resource("forkCheckpoints"));
    ConcordProcess parent = concord.processes().start(payload);
    expectStatus(parent, ProcessEntry.StatusEnum.FINISHED);
    parent.assertLog(".*#1.*");
    parent.assertLog(".*#2.*");
    // ---
    List<ProcessEntry> children = concord.processes().list(ProcessListQuery.builder().parentInstanceId(parent.instanceId()).limit(10).build());
    assertEquals(1, children.size());
    ProcessEntry fork = children.get(0);
    assertEquals(fork.getTags().get(0), forkTag);
    // ---
    List<ProcessCheckpointEntry> checkpoints = parent.checkpoints();
    assertEquals(1, checkpoints.size());
    parent.restoreCheckpoint(checkpoints.get(0).getId());
    expectStatus(parent, ProcessEntry.StatusEnum.FINISHED);
    // ---
    children = concord.processes().list(ProcessListQuery.builder().parentInstanceId(parent.instanceId()).limit(10).build());
    assertEquals(2, children.size());
    for (ProcessEntry child : children) {
        ConcordProcess proc = concord.processes().get(child.getInstanceId());
        proc.assertNoLog(".*#1.*");
        proc.assertNoLog(".*#2.*");
        proc.assertLog(".*#3.*");
    }
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) Payload(ca.ibodrov.concord.testcontainers.Payload) Utils.resourceToString(com.walmartlabs.concord.it.runtime.v2.Utils.resourceToString) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) ProcessCheckpointEntry(com.walmartlabs.concord.client.ProcessCheckpointEntry) Test(org.junit.jupiter.api.Test)

Example 4 with ProcessEntry

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

the class ProcessIT method testMetaUpdate.

/**
 * Test the process metadata.
 */
@Test
public void testMetaUpdate() throws Exception {
    Payload payload = new Payload().archive(resource("meta")).arg("name", "Concord");
    ConcordProcess proc = concord.processes().start(payload);
    ProcessEntry pe = expectStatus(proc, ProcessEntry.StatusEnum.SUSPENDED);
    // ---
    proc.assertLog(".*Runtime: concord-v2.*");
    proc.assertLog(".*Hello, Concord!.*");
    assertNotNull(pe.getMeta());
    // 2 + plus system meta + entryPoint
    assertEquals(4, pe.getMeta().size());
    assertEquals("init-value", pe.getMeta().get("test"));
    assertEquals("xxx", pe.getMeta().get("myForm.action"));
    assertEquals("default", pe.getMeta().get("entryPoint"));
    // ---
    List<FormListEntry> forms = proc.forms();
    assertEquals(1, forms.size());
    Map<String, Object> data = new HashMap<>();
    data.put("action", "Reject");
    FormSubmitResponse fsr = proc.submitForm(forms.get(0).getName(), data);
    assertTrue(fsr.isOk());
    pe = expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
    // ---
    proc.assertLog(".*Action: Reject.*");
    assertNotNull(pe.getMeta());
    // 2 + plus system meta + entryPoint
    assertEquals(4, pe.getMeta().size());
    assertEquals("init-value", pe.getMeta().get("test"));
    assertEquals("Reject", pe.getMeta().get("myForm.action"));
    assertEquals("default", pe.getMeta().get("entryPoint"));
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) FormListEntry(com.walmartlabs.concord.client.FormListEntry) HashMap(java.util.HashMap) FormSubmitResponse(com.walmartlabs.concord.client.FormSubmitResponse) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) Payload(ca.ibodrov.concord.testcontainers.Payload) Utils.resourceToString(com.walmartlabs.concord.it.runtime.v2.Utils.resourceToString) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) Test(org.junit.jupiter.api.Test)

Example 5 with ProcessEntry

use of com.walmartlabs.concord.client.ProcessEntry 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);
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) HashMap(java.util.HashMap) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) ApiClient(com.walmartlabs.concord.ApiClient) WebElement(org.openqa.selenium.WebElement) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessEntry (com.walmartlabs.concord.client.ProcessEntry)70 Test (org.junit.jupiter.api.Test)68 ProcessApi (com.walmartlabs.concord.client.ProcessApi)55 StartProcessResponse (com.walmartlabs.concord.client.StartProcessResponse)54 HashMap (java.util.HashMap)35 URI (java.net.URI)23 ConcordProcess (ca.ibodrov.concord.testcontainers.ConcordProcess)15 Payload (ca.ibodrov.concord.testcontainers.Payload)15 Path (java.nio.file.Path)4 ITUtils.randomString (com.walmartlabs.concord.it.common.ITUtils.randomString)3 Utils.resourceToString (com.walmartlabs.concord.it.runtime.v2.Utils.resourceToString)3 File (java.io.File)3 FormListEntry (com.walmartlabs.concord.client.FormListEntry)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 UUID (java.util.UUID)2 ZipArchiveOutputStream (org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream)2 ApiClient (com.walmartlabs.concord.ApiClient)1 FormSubmitResponse (com.walmartlabs.concord.client.FormSubmitResponse)1 HostEntry (com.walmartlabs.concord.client.HostEntry)1 NodeRosterHostsApi (com.walmartlabs.concord.client.NodeRosterHostsApi)1