Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.Record


  }

  @Test
  public void testNormal() throws IOException {
    // First, index up the record
    Record r = TestUtils.makeRecord("ID", "abc", "NAME", "b");
    db.index(r);
    db.commit();

    // Then, retrieve it and verify that it's correct
    r = db.findRecordById("abc");
    assertEquals("abc", r.getValue("ID"));
    assertEquals("b", r.getValue("NAME"));
  }
View Full Code Here


    props.put("ID", Collections.singleton("abc"));
    Collection<String> list = new ArrayList();
    list.add("b");
    list.add("c");
    props.put("NAME", list);
    Record r = new RecordImpl(props);
    db.index(r);
    db.commit();

    // Then, retrieve it and verify that it's correct
    r = db.findRecordById("abc");
    assertEquals("abc", r.getValue("ID"));
    list = r.getValues("NAME");
    assertEquals(2, list.size());
    assertTrue(list.contains("b"));
    assertTrue(list.contains("c"));
  }
View Full Code Here

  }

  @Test
  public void testNonExistentField() throws IOException {
    // First, index up the record
    Record r = TestUtils.makeRecord("ID", "abc", "NAME", "b");
    db.index(r);
    db.commit();

    // Then, retrieve it and verify that it's correct
    r = db.findRecordById("abc");
    assertEquals(null, r.getValue("DIDGERIDOO"));
    assertEquals(0, r.getValues("DIDGERIDOO").size());
  }
View Full Code Here

  }

  @Test
  public void testEquality() throws IOException {
    // First, index up the record
    Record r = TestUtils.makeRecord("ID", "abc", "NAME", "b");
    db.index(r);
    db.commit();

    // Then, retrieve it and verify that it's correct
    r = db.findRecordById("abc");
    Record r2 = db.findRecordById("abc");

    assertTrue(r.hashCode() == r2.hashCode());
    assertTrue(r.equals(r2));
  }
View Full Code Here

  public void testPersistence() throws IOException {
    // can we index a record, close and reopen the database, and find
    // the same record again afterwards?
    assertTrue("database claims to be in-memory", !db.isInMemory());

    Record record = TestUtils.makeRecord("ID", "1", "NAME", "AND", "EMAIL", "BBBBB");
    db.index(record);
    db.commit();
    db.close();

    db = createDatabase(config);

    Record r = db.findRecordById("1");
    assertTrue("record not found after reopening", r != null);
    assertEquals("wrong ID", "1", r.getValue("ID"));
    assertEquals("wrong NAME", "AND", r.getValue("NAME"));
    assertEquals("wrong EMAIL", "BBBBB", r.getValue("EMAIL"));

    Collection<Record> recs = db.findCandidateMatches(record);
    assertEquals("wrong number of records found", 1, recs.size());
    r = recs.iterator().next();
    assertEquals("wrong ID", "1", r.getValue("ID"));
    assertEquals("wrong NAME", "AND", r.getValue("NAME"));
    assertEquals("wrong EMAIL", "BBBBB", r.getValue("EMAIL"));
  }
View Full Code Here

  public void testOverwrite() throws IOException {
    // can we index a record, close and reopen the database with overwrite
    // set, and not find it again?
    assertTrue("database claims to be in-memory", !db.isInMemory());

    Record record = TestUtils.makeRecord("ID", "1", "NAME", "AND", "EMAIL", "BBBBB");
    db.index(record);
    db.commit();
    db.close();

    db = createDatabase(config);
    db.setOverwrite(true);

    Record r = db.findRecordById("1");
    assertTrue("record found after reopening, despite overwrite", r == null);
  }
View Full Code Here

    // index a record, then close the db. reopen, then index a changed
    // version of the record. now the old version should no longer be
    // available.
    assertTrue("database claims to be in-memory", !db.isInMemory());

    Record record = TestUtils.makeRecord("ID", "1", "NAME", "AND", "EMAIL", "BBBBB");
    db.index(record);
    db.commit();
    db.close();

    db = createDatabase(config);

    // same id, different values
    Record record2 = TestUtils.makeRecord("ID", "1", "NAME", "LARS", "EMAIL", "BARS");
    db.index(record2);
    db.commit();

    Record r = db.findRecordById("1");
    assertTrue("record not found", r != null);
    assertEquals("wrong ID", "1", r.getValue("ID"));
    assertEquals("wrong NAME", "LARS", r.getValue("NAME"));
    assertEquals("wrong EMAIL", "BARS", r.getValue("EMAIL"));

    Collection<Record> recs = db.findCandidateMatches(record2);
    assertEquals("wrong number of records found", 1, recs.size());
    r = recs.iterator().next();
    assertEquals("wrong ID", "1", r.getValue("ID"));
    assertEquals("wrong NAME", "LARS", r.getValue("NAME"));
    assertEquals("wrong EMAIL", "BARS", r.getValue("EMAIL"));

    recs = db.findCandidateMatches(record);
    assertEquals("wrong number of records found", 0, recs.size());
  }
View Full Code Here

  public abstract Database createDatabase(Configuration config)
    throws IOException;
 
  @Test
  public void testTrivial() throws IOException {
    Record record = TestUtils.makeRecord("ID", "1", "NAME", "AND", "EMAIL", "BBBBB");
    db.index(record);
    db.commit();

    record = db.findRecordById("1");
    assertTrue("no record found", record != null);
    assertEquals("wrong ID", "1", record.getValue("ID"));
    assertEquals("wrong EMAIL", "BBBBB", record.getValue("EMAIL"));
  }
View Full Code Here

  }

  @Test
  public void testBackslash() throws IOException {
    String name = "\"Lastname, Firstname \\(external\\)\"";
    Record record = TestUtils.makeRecord("ID", "1",
                                         "NAME", name, "EMAIL", "BBBBB");
    db.index(record);
    db.commit();

    Record record2 = TestUtils.makeRecord("NAME", "\"lastname, firstname \\(external\\)\"");
    db.findCandidateMatches(record2);
  }
View Full Code Here

    db.findCandidateMatches(record2);
  }
 
  @Test
  public void testBNode() throws IOException {
    Record record = TestUtils.makeRecord("ID", "_:RHUKdfPM299", "NAME", "AND", "EMAIL", "BBBBB");
    db.index(record);
    db.commit();

    record = db.findRecordById("_:RHUKdfPM299");
    assertTrue("no record found", record != null);
    assertEquals("wrong ID", "_:RHUKdfPM299", record.getValue("ID"));
  }
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.