Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.Record


    source.addColumn(c);
    source.addColumn(new Column("F3", null, null, null));

    RecordIterator it = read("F1,F2,F3\na,b;;e,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("c", r.getValue("F3"));

    Collection<String> values = r.getValues("F2");
    assertEquals(2, values.size());
    assertTrue(values.contains("b"));
    assertTrue(values.contains("e"));
  }
View Full Code Here


    source.addColumn(new Column("F2", null, null, null));
    source.addColumn(new Column("F3", null, null, null));

    RecordIterator it = read("F1;F2;F3\na;b;c", ';');

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

      init();

    // is there a previous version of this record? if so, remove it
    String id = getId(record);
    if (!overwrite && file != null) {
      Record old = findRecordById(id);
      if (old != null) {
        for (KeyFunction keyfunc : functions) {
          NavigableMap<String, Block> blocks = getBlocks(keyfunc);
          String key = keyfunc.makeKey(old);
          Block block = blocks.get(key);
View Full Code Here

    assertTrue(!it.hasNext());
  }

  @Test
  public void testSingleRecord() throws IOException {
    Record r = source.getRecordsFromString("{\"F1\":\"a\",\"F2\" : \"b\", \"F3\" : \"c\", \"F4\" : \"d\"}").next();

    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

    assertEquals("c", r.getValue("F3"));
  }

  @Test
  public void testArrayField() {
    Record r = source.getRecordsFromString("{\"F1\":[\"a\",\"b\",\"c\"]}").next();
    assertEquals(3, r.getValues("F1").size());
  }
View Full Code Here

    assertEquals(3, r.getValues("F1").size());
  }

  @Test
  public void testNestRecords() {
    Record r = source.getRecordsFromString("{\"F1\":\"a\",\"FF2\" : {\"F2\" : \"b\"}, \"FFF3\" : {\"FF3\" : {\"F3\" : \"c\",\"F4\" : \"d\"}}}").next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

  }
 
  @Test
  public void multipleRecords() {
    RecordIterator it = source.getRecordsFromString("{\"F1\":\"a\",\"F2\" : \"b\", \"F3\" : \"c\"}{\"F1\":\"a2\",\"F2\" : \"b2\", \"F3\" : \"c2\"}");
    Record r1 = it.next();
    assertEquals("a", r1.getValue("F1"));
    assertEquals("b", r1.getValue("F2"));
    assertEquals("c", r1.getValue("F3"));
    Record r2 =  it.next();
    assertEquals("a2", r2.getValue("F1"));
    assertEquals("b2", r2.getValue("F2"));
    assertEquals("c2", r2.getValue("F3"));
  }
View Full Code Here

    source.addColumn(new Column("NAME", null, null, null));
       
    RecordIterator it = source.getRecords();
    assertTrue(it.hasNext());

    Record r = it.next();
    assertEquals("1", r.getValue("ID"));
    assertEquals("foo", r.getValue("NAME"));

    assertFalse(it.hasNext());
  }
View Full Code Here

    source.addColumn(new Column("ID", null, null, null));
       
    RecordIterator it = source.getRecords();
    assertTrue(it.hasNext());

    Record r = it.next();
    assertEquals("1", r.getValue("ID"));
    assertEquals(null, r.getValue("NAME"));

    assertFalse(it.hasNext());
  }
View Full Code Here

    source.addColumn(new Column("NAME", "FAMILYNAME", null, familycleaner));
       
    RecordIterator it = source.getRecords();
    assertTrue(it.hasNext());

    Record r = it.next();
    assertEquals("1", r.getValue("ID"));
    assertEquals("john", r.getValue("GIVENNAME"));
    assertEquals("smith", r.getValue("FAMILYNAME"));

    assertFalse(it.hasNext());
  }
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.Record

Copyright © 2018 www.massapicom. 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.