Beispiel #1
0
  @Test
  public void should_initialize_lazy_properties() throws Exception {
    Tweet tweet = new Tweet();
    tweet.setId(UUIDGen.getTimeUUID());
    tweet.setContent("welcome");

    CompleteBean entity =
        CompleteBeanTestBuilder.builder()
            .randomId()
            .name("name")
            .label("label")
            .age(45L)
            .addFriends("foo", "bar")
            .welcomeTweet(tweet)
            .version(CounterBuilder.incr(11L))
            .buid();

    manager.insert(entity);

    CompleteBean foundEntity = manager.find(CompleteBean.class, entity.getId());

    CompleteBean rawEntity = manager.initAndRemoveProxy(foundEntity);

    assertThat(rawEntity.getName()).isEqualTo("name");
    assertThat(rawEntity.getLabel()).isEqualTo("label");
    assertThat(rawEntity.getAge()).isEqualTo(45L);
    assertThat(rawEntity.getFriends()).containsExactly("foo", "bar");
    assertThat(rawEntity.getWelcomeTweet().getContent()).isEqualTo("welcome");
    assertThat(rawEntity.getVersion()).isInstanceOf(InternalCounterImpl.class);
    assertThat(rawEntity.getVersion().get()).isEqualTo(11L);
  }
Beispiel #2
0
  @Test
  public void should_re_prepare_statements_when_cache_size_exceeded() throws Exception {
    // Given
    CompleteBean bean = builder().id(RandomUtils.nextLong(0, Long.MAX_VALUE)).name("name").buid();

    CompleteBean managed = pm.insert(bean);

    // When
    managed.setAge(10L);
    pm.update(managed);

    managed.setFriends(Arrays.asList("foo", "bar"));
    pm.update(managed);

    managed.setFollowers(Sets.newHashSet("George", "Paul"));
    pm.update(managed);

    managed.setAge(11L);
    pm.update(managed);

    // Then
    CompleteBean found = pm.find(CompleteBean.class, bean.getId());

    assertThat(found.getAge()).isEqualTo(11L);
    assertThat(found.getName()).isEqualTo("name");
    assertThat(found.getFriends()).containsExactly("foo", "bar");
    assertThat(found.getFollowers()).containsOnly("George", "Paul");
  }