Search in sources :

Example 1 with FieldValue

use of org.activityinfo.test.driver.FieldValue in project activityinfo by bedatadriven.

the class InstanceTableUiTest method background.

private void background() throws Exception {
    driver.login();
    ApiApplicationDriver api = (ApiApplicationDriver) driver.setup();
    api.createDatabase(property("name", DATABASE));
    api.addPartner("NRC", DATABASE);
    api.createForm(name(FORM_NAME), property("database", DATABASE));
    api.createField(property("form", FORM_NAME), property("name", "quantity"), property("type", "quantity"), property("code", "1"));
    api.createField(property("form", FORM_NAME), property("name", "enum"), property("type", "enum"), property("items", Lists.newArrayList("item1", "item2", "item3")), property("code", "2"));
    api.createField(property("form", FORM_NAME), property("name", "text"), property("type", "text"), property("code", "3"));
    api.createField(property("form", FORM_NAME), property("name", "multi-line"), property("type", "NARRATIVE"), property("code", "4"));
    api.createField(property("form", FORM_NAME), property("name", "barcode"), property("type", "BARCODE"), property("code", "5"));
    // submit with null values
    api.submitForm(FORM_NAME, Arrays.asList(new FieldValue("Partner", "NRC"), new FieldValue("quantity", -1)));
    for (int j = 0; j < 5; j++) {
        // chunk on 5 batch commands to avoid SQL timeout
        api.startBatch();
        for (int i = 0; i < 100; i++) {
            api.submitForm(FORM_NAME, Arrays.asList(new FieldValue("Partner", "NRC"), new FieldValue("quantity", i), new FieldValue("enum", i % 2 == 0 ? "item1" : "item1, item2").setType(Optional.of(EnumType.TYPE_CLASS)), new FieldValue("text", "text" + i), new FieldValue("multi-line", "line1\nline2"), new FieldValue("barcode", "barcode")), Arrays.asList("Partner", "quantity", "enum", "text", "multi-line", "barcode"));
        }
        api.submitBatch();
    }
}
Also used : ApiApplicationDriver(org.activityinfo.test.driver.ApiApplicationDriver) FieldValue(org.activityinfo.test.driver.FieldValue)

Example 2 with FieldValue

use of org.activityinfo.test.driver.FieldValue in project activityinfo by bedatadriven.

the class DateFormUiTest method dataEntry.

@Test
public void dataEntry() throws Exception {
    driver.login();
    driver.setup().createDatabase(name(DATABASE));
    driver.setup().addPartner("NRC", DATABASE);
    driver.setup().createForm(name("Form"), property("database", DATABASE), property("classicView", false));
    LocalDate date = new LocalDate(2015, 8, 6);
    List<FieldValue> fieldValues = new ArrayList<>();
    fieldValues.add(new FieldValue("partner", "NRC"));
    fieldValues.add(new FieldValue("Start Date", date.toString("YYYY-MM-dd")));
    fieldValues.add(new FieldValue("End Date", date.toString("YYYY-MM-dd")));
    driver.submitForm("Form", fieldValues);
    // Verify that dates are correctly recorded
    File exportedFile = driver.exportForm("Form");
    DataTable dataTable = TableDataParser.exportedDataTable(exportedFile);
    List<String> headers = dataTable.getGherkinRows().get(0).getCells();
    List<String> values = dataTable.getGherkinRows().get(1).getCells();
    assertThat(values.get(headers.indexOf(I18N.CONSTANTS.startDate())), equalTo(date.toString("M/d/YY")));
    assertThat(values.get(headers.indexOf(I18N.CONSTANTS.endDate())), equalTo(date.toString("M/d/YY")));
}
Also used : DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) FieldValue(org.activityinfo.test.driver.FieldValue) LocalDate(org.joda.time.LocalDate) File(java.io.File) Test(org.junit.Test)

Example 3 with FieldValue

use of org.activityinfo.test.driver.FieldValue in project activityinfo by bedatadriven.

the class TargetsUiTest method treeEditorStateOnSelectionChange.

@Test
public void treeEditorStateOnSelectionChange() throws Exception {
    background();
    driver.setTargetValues("Target1", Lists.newArrayList(new FieldValue("nb. kits", "1000")));
    TargetsPage targetPage = driver.targetsPage();
    targetPage.select(driver.alias("Target2"));
    // switch back and check whether value is in tree
    targetPage.select(driver.alias("Target1"));
    // value must be present in tree
    assertNotNull(targetPage.valueGrid().findCell("1000"));
}
Also used : TargetsPage(org.activityinfo.test.pageobject.web.design.TargetsPage) FieldValue(org.activityinfo.test.driver.FieldValue) Test(org.junit.Test)

Aggregations

FieldValue (org.activityinfo.test.driver.FieldValue)3 Test (org.junit.Test)2 DataTable (cucumber.api.DataTable)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ApiApplicationDriver (org.activityinfo.test.driver.ApiApplicationDriver)1 TargetsPage (org.activityinfo.test.pageobject.web.design.TargetsPage)1 LocalDate (org.joda.time.LocalDate)1