Package info.archinnov.achilles.test.integration.entity

Examples of info.archinnov.achilles.test.integration.entity.ClusteredEntityWithCounter$ClusteredKey


  public void should_persist_and_find() throws Exception {
    long counterValue = RandomUtils.nextLong(0,Long.MAX_VALUE);
    long versionValue = RandomUtils.nextLong(0,Long.MAX_VALUE);
    compoundKey = new ClusteredKey(RandomUtils.nextLong(0,Long.MAX_VALUE), "name");

    entity = new ClusteredEntityWithCounter(compoundKey, incr(counterValue), incr(versionValue));

    manager.insert(entity);

    ClusteredEntityWithCounter found = manager.find(ClusteredEntityWithCounter.class, compoundKey);

    assertThat(found.getId()).isEqualTo(compoundKey);
    assertThat(found.getCounter().get()).isEqualTo(counterValue);
    assertThat(found.getVersion().get()).isEqualTo(versionValue);
  }
View Full Code Here


  @Test
  public void should_persist_and_get_proxy() throws Exception {
    long counterValue = RandomUtils.nextLong(0,Long.MAX_VALUE);
    compoundKey = new ClusteredKey(RandomUtils.nextLong(0,Long.MAX_VALUE), "name");
    entity = new ClusteredEntityWithCounter(compoundKey, incr(counterValue));

    manager.insert(entity);

    ClusteredEntityWithCounter found = manager.getProxy(ClusteredEntityWithCounter.class, compoundKey);

    assertThat(found.getId()).isEqualTo(compoundKey);
    assertThat(found.getCounter().get()).isEqualTo(counterValue);
    assertThat(found.getVersion().get()).isNull();
  }
View Full Code Here

    long initialValue = RandomUtils.nextLong(0,Long.MAX_VALUE);
    long increment = RandomUtils.nextLong(0,Long.MAX_VALUE);

    compoundKey = new ClusteredKey(RandomUtils.nextLong(0,Long.MAX_VALUE), "name");

    entity = new ClusteredEntityWithCounter(compoundKey, incr(initialValue),incr(initialValue));

    entity = manager.insert(entity);

        assertThat(entity.getCounter().get()).isEqualTo(initialValue);
View Full Code Here

  @Test
  public void should_delete() throws Exception {
    long counterValue = RandomUtils.nextLong(0,Long.MAX_VALUE);
    compoundKey = new ClusteredKey(RandomUtils.nextLong(0,Long.MAX_VALUE), "name");

    entity = new ClusteredEntityWithCounter(compoundKey, incr(counterValue));

    entity = manager.insert(entity);

    manager.delete(entity);
View Full Code Here

    long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
    String name = "name";
    compoundKey = new ClusteredKey(partitionKey, name);

    entity = new ClusteredEntityWithCounter(compoundKey, incr(counterValue));

    entity = manager.insert(entity);

    session.execute("UPDATE " + TABLE_NAME + " SET counter = counter + " + incr + " WHERE id=" + partitionKey
        + " AND name='name'");
View Full Code Here

                .forIteration()
        .withPartitionComponents(partitionKey)
                .iterator();

    assertThat(iter.hasNext()).isTrue();
    ClusteredEntityWithCounter next = iter.next();
    assertThat(next.getId().getId()).isEqualTo(partitionKey);
    assertThat(next.getId().getName()).isEqualTo("name1");
    assertThat(next.getCounter().get()).isEqualTo(1L);
    assertThat(next.getVersion().get()).isEqualTo(1L);
    assertThat(iter.hasNext()).isTrue();

    assertThat(iter.hasNext()).isTrue();
    next = iter.next();
    assertThat(next.getId().getId()).isEqualTo(partitionKey);
    assertThat(next.getId().getName()).isEqualTo("name2");
    assertThat(next.getCounter().get()).isEqualTo(2L);
        assertThat(next.getVersion().get()).isEqualTo(2L);

    assertThat(iter.hasNext()).isTrue();
    next = iter.next();
    assertThat(next.getId().getId()).isEqualTo(partitionKey);
    assertThat(next.getId().getName()).isEqualTo("name3");
    assertThat(next.getCounter().get()).isEqualTo(3L);
        assertThat(next.getVersion().get()).isEqualTo(3L);

    assertThat(iter.hasNext()).isTrue();
    next = iter.next();
    assertThat(next.getId().getId()).isEqualTo(partitionKey);
    assertThat(next.getId().getName()).isEqualTo("name4");
    assertThat(next.getCounter().get()).isEqualTo(4L);
        assertThat(next.getVersion().get()).isEqualTo(4L);

    assertThat(iter.hasNext()).isTrue();
    next = iter.next();
    assertThat(next.getId().getId()).isEqualTo(partitionKey);
    assertThat(next.getId().getName()).isEqualTo("name5");
    assertThat(next.getCounter().get()).isEqualTo(5L);
        assertThat(next.getVersion().get()).isEqualTo(5L);

    assertThat(iter.hasNext()).isFalse();
  }
View Full Code Here

        assertThat(entities.get(1).getVersion().get()).isEqualTo(3L);
  }

  private void insertClusteredEntity(Long partitionKey, String name, Long counterValue) {
    ClusteredKey embeddedId = new ClusteredKey(partitionKey, name);
    ClusteredEntityWithCounter entity = new ClusteredEntityWithCounter(embeddedId,
        incr(counterValue),incr(counterValue));
    manager.insert(entity);
  }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.test.integration.entity.ClusteredEntityWithCounter$ClusteredKey

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.