Java Code Examples for io.paperdb.Paper#get()

The following examples show how to use io.paperdb.Paper#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataTest.java    From Paper with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutGetList() {
    final List<Person> inserted = genPersonList(10000);
    Paper.put("persons", inserted);
    List<Person> persons = Paper.get("persons");
    assertThat(persons).isEqualTo(inserted);
}
 
Example 2
Source File: DataTest.java    From Paper with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutMap() {
    final Map<Integer, Person> inserted = genPersonMap(10000);
    Paper.put("persons", inserted);

    final Map<Integer, Person> personMap = Paper.get("persons");
    assertThat(personMap).isEqualTo(inserted);
}
 
Example 3
Source File: DataTest.java    From Paper with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutPOJO() {
    final Person person = genPerson(new Person(), 1);
    Paper.put("profile", person);

    final Person savedPerson = Paper.get("profile");
    assertThat(savedPerson).isEqualTo(person);
    assertThat(savedPerson).isNotSameAs(person);
}
 
Example 4
Source File: PaperDeprecatedAPITest.java    From Paper with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutGetNormalAfterReinit() {
    Paper.put("city", "Lund");
    String val = Paper.get("city", "default");
    Paper.init(getTargetContext());// Reinit Paper instance
    assertThat(val).isEqualTo("Lund");
}
 
Example 5
Source File: DataTest.java    From Paper with Apache License 2.0 4 votes vote down vote up
private Object testReadWriteWithoutClassCheck(Object originObj) {
    Paper.put("obj", originObj);
    Object readObj = Paper.get("obj");
    assertThat(readObj).isEqualTo(originObj);
    return readObj;
}
 
Example 6
Source File: PaperDeprecatedAPITest.java    From Paper with Apache License 2.0 4 votes vote down vote up
@Test
public void testPutGetNormal() {
    Paper.put("city", "Lund");
    String val = Paper.get("city", "default");
    assertThat(val).isEqualTo("Lund");
}
 
Example 7
Source File: PaperDeprecatedAPITest.java    From Paper with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetNotExisted() {
    String val = Paper.get("non-existed");
    assertThat(val).isNull();
}
 
Example 8
Source File: PaperDeprecatedAPITest.java    From Paper with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetDefault() {
    String val = Paper.get("non-existed", "default");
    assertThat(val).isEqualTo("default");
}