Examples of TupleTable


Examples of com.hp.hpl.jena.tdb.index.TupleTable

    }
   
    @Test public void createFind3()
    {
        // test scan
        TupleTable table = create2() ;
        add(table, n1, n2, n3) ;
        add(table, n1, n2, n4) ;

        Tuple<NodeId> pat = Tuple.create(n1, null, n3) ;
        Iterator<Tuple<NodeId>> iter = table.find(pat) ;
        assertNotNull(iter) ;
        List<Tuple<NodeId>> x = Iter.toList(iter) ;
        int z = x.size() ;
        assertEquals(1, z) ;
       
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

    String query = "SELECT Name, Continent FROM Country";
    QueryRule queryRule = new QueryRule("Code", Operator.EQUALS, "NLD");
    when(db.sql(query, queryRule)).thenReturn(Arrays.asList(tuple0));
    when(db.sql("SELECT COUNT(*) FROM Country", queryRule)).thenReturn(Arrays.asList(tuple0));

    TupleTable jdbcTable = new JdbcTable(db, query, Arrays.asList(queryRule));
    try
    {
      // check columns
      Assert.assertEquals(jdbcTable.getColumns().get(0).getName(), "Name");
      Assert.assertEquals(jdbcTable.getColumns().get(1).getName(), "Continent");

      // check rows
      int i = 1;
      for (Tuple row : jdbcTable)
      {
        Assert.assertEquals(row.getString("Name"), "Netherlands");

        i = i + 1;
      }
    }
    finally
    {
      jdbcTable.close();
    }
  }
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

{

  @Test
  public void test1() throws TableException
  {
    TupleTable table = MemoryTableFactory.create(5, 5);

    // check columns
    Assert.assertEquals("col1", table.getColumns().get(0).getName());
    Assert.assertEquals("col2", table.getColumns().get(1).getName());

    // check rows
    Assert.assertEquals(5, table.getRows().size());

    // check iterator
    int i = 1;
    for (Tuple row : table)
    {
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

  }

  @Test
  public void testLimitOffset() throws TableException
  {
    TupleTable table = MemoryTableFactory.create(5, 5);

    table.setLimitOffset(2, 3);

    // limit == 2
    Assert.assertEquals(table.getRows().size(), 2);

    // offset = 3, so we skip first1-first3 and expect first4
    Assert.assertEquals(table.getRows().get(0).getString("col1"), "val1,4");

    // remove filters again
    table.setLimitOffset(0, 0);
  }
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

  }

  @Test
  public void testColLimitOffset() throws TableException
  {
    TupleTable table = MemoryTableFactory.create(5, 5);

    table.setColLimit(2);
    table.setColOffset(1);

    // limit == 1
    int i = 1;
    for (Tuple row : table.getRows())
    {
      Assert.assertEquals(row.getNrCols(), 2);
      Assert.assertEquals(row.get("col2"), "val2," + i);
      Assert.assertEquals(row.get("col3"), "val3," + i);
      ++i;
    }

    // remove filters again
    table.setColLimit(0);
    table.setColOffset(0);
  }
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

  }

  @Test
  public void export() throws TableException, IOException
  {
    TupleTable tableModel = mock(TupleTable.class);
    Field field1 = when(mock(Field.class).getName()).thenReturn("col1").getMock();
    Field field2 = when(mock(Field.class).getName()).thenReturn("col2").getMock();
    Field field3 = when(mock(Field.class).getName()).thenReturn("col3").getMock();
    when(tableModel.getColumns()).thenReturn(Arrays.asList(field1, field2, field3));
    WritableTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1.1");
    row1.set("col2", "val1.2");
    row1.set("col3", "val1.3");
    WritableTuple row2 = new KeyValueTuple();
    row2.set("col1", "val2.1");
    row2.set("col2", "val2.2");
    row2.set("col3", "val2.3");
    when(tableModel.iterator()).thenReturn(Arrays.<Tuple> asList(row1, row2).iterator());

    ExcelExporter excelExporter = new ExcelExporter(tableModel);
    File xlsFile = File.createTempFile("table", ".xls");
    try
    {
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

  }

  @Test
  public void export_offsetsLimits() throws TableException, IOException
  {
    TupleTable tableModel = mock(TupleTable.class);
    when(tableModel.getColOffset()).thenReturn(2);
    when(tableModel.getColLimit()).thenReturn(3);
    when(tableModel.getOffset()).thenReturn(1);
    when(tableModel.getLimit()).thenReturn(2);

    // verify that offsets and limits are ignored during export
    Field field1 = when(mock(Field.class).getName()).thenReturn("col1").getMock();
    Field field2 = when(mock(Field.class).getName()).thenReturn("col2").getMock();
    Field field3 = when(mock(Field.class).getName()).thenReturn("col3").getMock();
    when(tableModel.getColumns()).thenReturn(Arrays.asList(field1, field2, field3));
    WritableTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1.1");
    row1.set("col2", "val1.2");
    row1.set("col3", "val1.3");
    WritableTuple row2 = new KeyValueTuple();
    row2.set("col1", "val2.1");
    row2.set("col2", "val2.2");
    row2.set("col3", "val2.3");
    when(tableModel.iterator()).thenReturn(Arrays.<Tuple> asList(row1, row2).iterator());

    ExcelExporter excelExporter = new ExcelExporter(tableModel);
    File xlsFile = File.createTempFile("table", ".xls");
    try
    {
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

  }

  @Test
  public void testCsvTableString() throws Exception
  {
    TupleTable table = new CsvTable(csvString);
    testTable(table);
  }
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

    String csv = "firstName,lastName";
    csv += "\nlucky,luke";
    csv += "\ncalamity,jane";
    csv += "\njolly,jumper";

    TupleTable table = new CsvTable(csv);

    table.setLimitOffset(1, 1);

    assertEquals(table.getCount(), 3);

    assertEquals(table.getRows().size(), 1);

    assertEquals(table.getRows().get(0).getString("firstName"), "calamity");
  }
View Full Code Here

Examples of org.molgenis.framework.tupletable.TupleTable

      FileUtils.write(file, csvString, Charset.forName("UTF-8"));
      CsvTable csvTable = new CsvTable(file);
      testTable(csvTable);

      TupleTable table = new CsvTable(file);

      table.setLimitOffset(1, 1);

      assertEquals(table.getCount(), 3);

      assertEquals(table.getRows().size(), 1);

      assertEquals(table.getRows().get(0).getString("firstName"), "calamity");

    }
    finally
    {
      file.delete();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.