Exemplo n.º 1
0
  public static void checkDataSetDescrPartial(DataSetDescr ds) {
    assertEquals("Description", "Empty DataSet", ds.getDescr());
    assertEquals("Enabled", false, ds.isEnabled());
    assertEquals("Major Version", 1, ds.getVerMax());
    assertEquals("Minor Version", 0, ds.getVerMin());

    assertNull(ds.getLangMap());
    assertNull(ds.getExColumns());
    assertNull(ds.getFilter());
    assertNull(ds.getSortByGrp());
  }
Exemplo n.º 2
0
  @Test
  public void testStaticStr1() throws JAXBException, IOException {
    JAXBElement<?> jaxb =
        (JAXBElement<?>)
            _ds.unmarshal(
                JarTestResourceUtils.readDemoFileAsStream("test/static_test_str1.xml", _ds_cfg));

    DataSetDescr dsd = (DataSetDescr) jaxb.getValue();

    SortGroup sg = dsd.getSortByGrp();
    assertNotNull(sg);
    assertEquals(1, sg.getSortBy().size());
  }
Exemplo n.º 3
0
  public static void checkDataSetDescrFull(DataSetDescr ds) {
    assertEquals("Description", "Test DataSet", ds.getDescr());
    assertEquals("Enabled", true, ds.isEnabled());

    LangMap lmap = ds.getLangMap();
    assertNotNull("lang_map tag check", lmap);
    List<LangColumn> lc = lmap.getColumn();
    assertNotNull("lang_map->column(s) tag check", lc);
    assertEquals("Lang Map Size", 2, lc.size());
    assertEquals("COL1 Lang Column not found", "COL1", lc.get(0).getName());
    assertEquals("COL2 Lang Column not found", "COL2", lc.get(1).getName());

    ExColumns ec = ds.getExColumns();
    assertNotNull("ex_columns tag check", ec);

    AutoIncColumns lai = ec.getAutoInc();
    assertNotNull("ex_columns->auto_inc tag check", lai);
    List<AutoIncColumn> ai = lai.getColumn();
    assertNotNull("ex_columns->auto_inc->column(s) tag check", ai);
    assertEquals("Auto Inc Column Size", 2, ai.size());
    assertEquals("Auto Inc Column #1 Name", "A11", ai.get(0).getName());
    assertEquals("Auto Inc Column #2 Name", "B22", ai.get(1).getName());

    CalcColumns lcc = ec.getCalc();
    assertNotNull("ex_columns->calc tag check", lcc);
    List<CalcColumn> cc = lcc.getColumn();
    assertNotNull("ex_columns->calc->column(s) tag check", lc);
    assertEquals("Calculated Column Size", 2, cc.size());
    assertEquals("Calculated Column #1 Name", "CALC1", cc.get(0).getName());
    assertEquals("Calculated Column #1 Formula", "A + B", cc.get(0).getValue());
    assertEquals("Calculated Column #2 Name", "CALC2", cc.get(1).getName());
    assertEquals("Calculated Column #2 Formula", "C + D", cc.get(1).getValue());

    SortGroup fs = ds.getSortByGrp();
    ConditionFilter cf = ds.getFilter();
    assertEquals("Condition", "A < B", cf.getValue());

    List<SortCond> sff = fs.getSortBy();
    checkFilter(sff.get(0), 1, "COL1", SortTypes.ASC, false);
    checkFilter(sff.get(1), 2, "COL2", SortTypes.DESC, false);

    assertNull("Non-existing static_ds", ds.getStaticData());
    // Check recursion
    GroupData dsg = ds.getGroupData();

    assertNotNull("group_ds tag check", dsg);
    List<DataSetExt> ldsd1 = dsg.getDsList().getGroupDsOrStaticDsOrCsvDs();
    assertEquals("DsGroup #1 size", 2, ldsd1.size());

    // Check nested group
    DataSetExt dse = ldsd1.get(0);
    assertEquals(dse.getClass(), GroupDataSetDescr.class);
    List<DataSetExt> ldsd2 =
        ((GroupDataSetDescr) dse).getGroupData().getDsList().getGroupDsOrStaticDsOrCsvDs();
    assertEquals("DsGroup #2 size", 4, ldsd2.size());

    // Check just class of each element
    assertEquals(ldsd2.get(0).getClass(), GroupDataSetDescr.class);
    assertEquals(ldsd2.get(1).getClass(), StaticDataSetDescr.class);
    assertEquals(ldsd2.get(2).getClass(), CsvDataSetDescr.class);
    assertEquals(ldsd2.get(3).getClass(), SqlDataSetDescr.class);

    dse = ldsd1.get(1);
    assertEquals(dse.getClass(), StaticDataSetDescr.class);
    StaticDataSetDescr dsd = (StaticDataSetDescr) dse;

    StaticDataSetDescr sds = dsd;
    assertNotNull("group_ds->static_ds tag check", sds);
    StaticData sdf = sds.getStaticData();
    assertNotNull("static_ds->static_set tag check", sdf);
    Columns cs = sdf.getColumns();
    assertNotNull("static_ds->columns tag check", cs);
    List<ColumnHeader> ch = cs.getColumn();
    assertNotNull("columns->column tag check", ch);
    assertEquals(2, ch.size());
    checkColumnHeader(ch.get(0), "COL1", "java.lang.String", "ERROR GRP 2 !!!");
    checkColumnHeader(ch.get(1), "COL2", "java.lang.String", "ERROR GRP 2 !!!");

    StaticRecords sr = sdf.getStaticRows();
    assertNotNull("static_ds->static tag check", dsg);
    List<RowDef> lrd = sr.getRow();
    assertNotNull("static tag->row(s) check", dsg);
    assertEquals("Static Rows size", 2, lrd.size());

    RowDef srd = lrd.get(0);
    List<RowCell> lcd = srd.getCell();
    assertNotNull("row#1>column(s) check", lcd);
    assertEquals("Static Columns size", 2, lcd.size());

    checkRowColumn(lcd.get(0), 1, 1, "COL1", "bBb");
    checkRowColumn(lcd.get(1), 1, 2, "COL2", "УуУ");

    srd = lrd.get(1);
    lcd = srd.getCell();
    assertNotNull("row#2>column(s) check", lcd);
    checkRowColumn(lcd.get(0), 2, 1, "COL1", "AaA");
    checkRowColumn(lcd.get(1), 2, 2, "COL2", "пПп");
  }