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

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


  public void should_persist_and_find() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    Integer index = 11;
    compoundKey = new EmbeddedKey(id, "type", index);

    entity = new ClusteredEntityWithCompositePartitionKey(id, "type", index, "value");

    manager.insert(entity);

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

    assertThat(found.getId()).isEqualTo(compoundKey);
    assertThat(found.getValue()).isEqualTo("value");
  }
View Full Code Here


  public void should_persist_and_get_proxy() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    Integer index = 11;
    compoundKey = new EmbeddedKey(id, "type", index);

    entity = new ClusteredEntityWithCompositePartitionKey(id, "type", index, "clustered_value");

    manager.insert(entity);

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

    assertThat(found.getId()).isEqualTo(compoundKey);
    assertThat(found.getValue()).isEqualTo("clustered_value");
  }
View Full Code Here

  public void should_update_modifications() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    Integer index = 11;
    compoundKey = new EmbeddedKey(id, "type", index);

    entity = new ClusteredEntityWithCompositePartitionKey(id, "type", index, "clustered_value");

    entity = manager.insert(entity);

    entity.setValue("new_clustered_value");
    manager.update(entity);
View Full Code Here

  public void should_delete() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    Integer index = 11;
    compoundKey = new EmbeddedKey(id, "type", index);

    entity = new ClusteredEntityWithCompositePartitionKey(id, "type", index, "clustered_value");

    entity = manager.insert(entity);

    manager.delete(entity);
View Full Code Here

  public void should_delete_by_id() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    Integer index = 11;
    compoundKey = new EmbeddedKey(id, "type", index);

    entity = new ClusteredEntityWithCompositePartitionKey(id, "type", index, "clustered_value");

    entity = manager.insert(entity);

    manager.deleteById(ClusteredEntityWithCompositePartitionKey.class, entity.getId());
View Full Code Here

  public void should_refresh() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    Integer index = 11;
    compoundKey = new EmbeddedKey(id, "type", index);

    entity = new ClusteredEntityWithCompositePartitionKey(id, "type", index, "clustered_value");

    entity = manager.insert(entity);

    session.execute("UPDATE " + TABLE_NAME + " SET value='new_clustered_value' WHERE id=" + id
        + " AND type='type' AND indexes=11");
View Full Code Here

  @Test
  public void should_check_for_common_operation_on_found_clustered_entity() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    insertValues(id, 1);

    ClusteredEntityWithCompositePartitionKey clusteredEntity = manager
        .sliceQuery(ClusteredEntityWithCompositePartitionKey.class)
                .forSelect()
                .withPartitionComponents(id, "type")
                .orderByAscending()
        .getOne();

    // Check for update
    clusteredEntity.setValue("dirty");
    manager.update(clusteredEntity);

    ClusteredEntityWithCompositePartitionKey check = manager.find(ClusteredEntityWithCompositePartitionKey.class,
        clusteredEntity.getId());
    assertThat(check.getValue()).isEqualTo("dirty");

    // Check for refresh
    check.setValue("dirty_again");
    manager.update(check);

    manager.refresh(clusteredEntity);
    assertThat(clusteredEntity.getValue()).isEqualTo("dirty_again");
View Full Code Here

  }

  @Test
  public void should_query_with_getFirst() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    ClusteredEntityWithCompositePartitionKey entity = manager
        .sliceQuery(ClusteredEntityWithCompositePartitionKey.class)
                .forSelect()
                .withPartitionComponents(id, "type")
                .orderByAscending()
        .getOne();

    assertThat(entity).isNull();

    insertValues(id, 5);

    entity = manager.sliceQuery(ClusteredEntityWithCompositePartitionKey.class)
                .forSelect()
                .withPartitionComponents(id, "type")
                .orderByAscending()
                .getOne();

    assertThat(entity.getValue()).isEqualTo("value1");

    List<ClusteredEntityWithCompositePartitionKey> entities = manager
        .sliceQuery(ClusteredEntityWithCompositePartitionKey.class)
                .forSelect()
                .withPartitionComponents(id, "type")
View Full Code Here

  @Test
  public void should_query_with_getLast() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);

    ClusteredEntityWithCompositePartitionKey entity = manager
        .sliceQuery(ClusteredEntityWithCompositePartitionKey.class)
                .forSelect()
                .withPartitionComponents(id, "type")
                .orderByDescending()
                .getOne();

    assertThat(entity).isNull();

    insertValues(id, 5);

    entity = manager.sliceQuery(ClusteredEntityWithCompositePartitionKey.class)
                .forSelect()
                .withPartitionComponents(id, "type")
                .orderByDescending()
                .getOne();

    assertThat(entity.getValue()).isEqualTo("value5");

    List<ClusteredEntityWithCompositePartitionKey> entities = manager
        .sliceQuery(ClusteredEntityWithCompositePartitionKey.class)
                .forSelect()
                .withPartitionComponents(id, "type")
View Full Code Here

                .forIteration()
                .withPartitionComponents(id, "type")
                .iterator();

    assertThat(iter.hasNext()).isTrue();
    ClusteredEntityWithCompositePartitionKey next = iter.next();
    assertThat(next.getValue()).isEqualTo("value1");
    assertThat(next.getId().getId()).isEqualTo(id);
    assertThat(next.getId().getType()).isEqualTo("type");
    assertThat(next.getId().getIndexes()).isEqualTo(11);
    assertThat(iter.hasNext()).isTrue();

    assertThat(iter.hasNext()).isTrue();
    next = iter.next();
    assertThat(next.getValue()).isEqualTo("value2");
    assertThat(next.getId().getId()).isEqualTo(id);
    assertThat(next.getId().getType()).isEqualTo("type");
    assertThat(next.getId().getIndexes()).isEqualTo(12);
    assertThat(iter.hasNext()).isTrue();

    assertThat(iter.hasNext()).isTrue();
    next = iter.next();
    assertThat(next.getValue()).isEqualTo("value3");
    assertThat(next.getId().getId()).isEqualTo(id);
    assertThat(next.getId().getType()).isEqualTo("type");
    assertThat(next.getId().getIndexes()).isEqualTo(13);
    assertThat(iter.hasNext()).isTrue();

    assertThat(iter.hasNext()).isTrue();
    next = iter.next();
    assertThat(next.getValue()).isEqualTo("value4");
    assertThat(next.getId().getId()).isEqualTo(id);
    assertThat(next.getId().getType()).isEqualTo("type");
    assertThat(next.getId().getIndexes()).isEqualTo(14);
    assertThat(iter.hasNext()).isTrue();

    assertThat(iter.hasNext()).isTrue();
    next = iter.next();
    assertThat(next.getValue()).isEqualTo("value5");
    assertThat(next.getId().getId()).isEqualTo(id);
    assertThat(next.getId().getType()).isEqualTo("type");
    assertThat(next.getId().getIndexes()).isEqualTo(15);

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

TOP

Related Classes of info.archinnov.achilles.test.integration.entity.ClusteredEntityWithCompositePartitionKey

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.