Examples of ClusteredEntityWithCounter


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

  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

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

  @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

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

    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

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

  @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

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

    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

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

                .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

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

        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

Examples of info.archinnov.achilles.test.mapping.entity.ClusteredEntityWithCounter

    entityValidator.validateEntity(bean, entityMeta);
  }

  @Test
  public void should_validate_not_clustered_counter() throws Exception {
    ClusteredEntityWithCounter entity = new ClusteredEntityWithCounter();
    when(proxifier.<ClusteredEntityWithCounter> deriveBaseClass(entity)).thenReturn(
        ClusteredEntityWithCounter.class);
    when(entityMetaMap.get(ClusteredEntityWithCounter.class)).thenReturn(entityMeta);
    when(entityMeta.structure().isClusteredCounter()).thenReturn(false);
    entityValidator.validateNotClusteredCounter(entity, entityMetaMap);
View Full Code Here

Examples of info.archinnov.achilles.test.mapping.entity.ClusteredEntityWithCounter

    entityValidator.validateNotClusteredCounter(entity, entityMetaMap);
  }

  @Test
  public void should_exception_when_not_clustered_counter() throws Exception {
    ClusteredEntityWithCounter entity = new ClusteredEntityWithCounter();
    when(proxifier.<ClusteredEntityWithCounter> deriveBaseClass(entity)).thenReturn(
        ClusteredEntityWithCounter.class);
    when(entityMetaMap.get(ClusteredEntityWithCounter.class)).thenReturn(entityMeta);
    when(entityMeta.structure().isClusteredCounter()).thenReturn(true);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.