@Test
  public void testLazyLoadedOneToOne() {
    Datastore ds = new RedisDatastore();
    ds.getMappingContext().addPersistentEntity(Person.class);
    Session conn = ds.connect();

    Person p = new Person();
    p.setName("Bob");
    Address a = new Address();
    a.setNumber("22");
    a.setPostCode("308420");
    p.setAddress(a);
    conn.persist(p);

    p = (Person) conn.retrieve(Person.class, p.getId());

    Address proxy = p.getAddress();

    assertTrue(proxy instanceof javassist.util.proxy.ProxyObject);
    assertTrue(proxy instanceof EntityProxy);

    EntityProxy ep = (EntityProxy) proxy;
    assertFalse(ep.isInitialized());
    assertEquals(a.getId(), proxy.getId());

    assertFalse(ep.isInitialized());
    assertEquals("22", a.getNumber());
  }
  @Test
  public void testProxyMethod() {
    Datastore ds = new RedisDatastore();
    ds.getMappingContext().addPersistentEntity(Person.class);
    Session conn = ds.connect();

    Person p = new Person();
    p.setName("Bob");
    Address a = new Address();
    a.setNumber("22");
    a.setPostCode("308420");
    p.setAddress(a);
    conn.persist(p);

    Person personProxy = (Person) conn.proxy(Person.class, p.getId());

    EntityProxy proxy = (EntityProxy) personProxy;

    assertFalse(proxy.isInitialized());
    assertEquals(p.getId(), personProxy.getId());

    assertFalse(proxy.isInitialized());

    assertEquals("Bob", personProxy.getName());

    assertTrue(proxy.isInitialized());
  }
 private Address getAddress() {
   Address address = new Address();
   address.setCountry("Belgium");
   address.setCity("Zaventem");
   address.setPostalCode("1930");
   address.setStreet("Airportstreet");
   address.setNumber("1");
   return address;
 }
    @Override
    public Address next() {
      try {
        if (line == null) line = reader.readLine();
      } catch (IOException e) {
        throw new UncheckedIOException(e);
      }
      if (line == null) throw new NoSuchElementException();

      final String[] fields = CsvUtils.parseCsvLine(SEP, QUOTE, line);

      line = null;

      final Address address = new Address();
      address.setId(readField(fields, idIndex));
      address.setStreet(readField(fields, streetIndex));
      address.setNumber(readField(fields, numberIndex));
      address.setZipcode(readField(fields, zipIndex));
      address.setMunicipality(readField(fields, municipalityIndex));
      final String country = readField(fields, countryIndex);
      address.setCountry(country != null ? country : "CH");

      return address;
    }