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

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


  private Session session = manager.getNativeSession();

  @Test
  public void should_persist() throws Exception {
    Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    EntityWithCompositePartitionKey entity = new EntityWithCompositePartitionKey(id, "type", "value");

    manager.insert(entity);

    Row row = session.execute("SELECT * FROM " + TABLE_NAME + " WHERE id=" + id + " AND type='type'").one();

View Full Code Here


  }

  @Test
  public void should_find() throws Exception {
    Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    EntityWithCompositePartitionKey entity = new EntityWithCompositePartitionKey(id, "type", "value");

    manager.insert(entity);

    EntityWithCompositePartitionKey found = manager.find(EntityWithCompositePartitionKey.class, new EmbeddedKey(id,
        "type"));

    assertThat(found).isNotNull();
    assertThat(found).isInstanceOf(Factory.class);
    assertThat(found.getId().getId()).isEqualTo(id);
    assertThat(found.getId().getType()).isEqualTo("type");
    assertThat(found.getValue()).isEqualTo("value");
  }
View Full Code Here

  @Test
  public void should_persist_and_get_proxy() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    EmbeddedKey compositeRowKey = new EmbeddedKey(id, "type");

    EntityWithCompositePartitionKey entity = new EntityWithCompositePartitionKey(id, "type", "clustered_value");

    manager.insert(entity);

    EntityWithCompositePartitionKey found = manager.getProxy(EntityWithCompositePartitionKey.class,
                                                                 compositeRowKey);

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

  }

  @Test
  public void should_update_modifications() throws Exception {
    Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    EntityWithCompositePartitionKey entity = new EntityWithCompositePartitionKey(id, "type", "value");

    entity = manager.insert(entity);

    entity.setValue("value2");
    manager.update(entity);

    EntityWithCompositePartitionKey found = manager.find(EntityWithCompositePartitionKey.class, new EmbeddedKey(id,
        "type"));
    assertThat(found.getValue()).isEqualTo("value2");
  }
View Full Code Here

  }

  @Test
  public void should_delete() throws Exception {
    Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    EntityWithCompositePartitionKey entity = new EntityWithCompositePartitionKey(id, "type", "value");

    entity = manager.insert(entity);

    manager.delete(entity);

    EntityWithCompositePartitionKey found = manager.find(EntityWithCompositePartitionKey.class, new EmbeddedKey(id,
        "type"));
    assertThat(found).isNull();
  }
View Full Code Here

  @Test
  public void should_delete_by_id() throws Exception {
    long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    EmbeddedKey compositeRowKey = new EmbeddedKey(id, "type");

    EntityWithCompositePartitionKey entity = new EntityWithCompositePartitionKey(id, "type", "clustered_value");

    manager.insert(entity);

    manager.deleteById(EntityWithCompositePartitionKey.class, compositeRowKey);
View Full Code Here

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

    EntityWithCompositePartitionKey entity = new EntityWithCompositePartitionKey(id, "type", "value");

    entity = manager.insert(entity);

    session.execute("UPDATE " + TABLE_NAME + " SET value='new_value' WHERE id=" + id + " AND type='type'");

    manager.refresh(entity);

    assertThat(entity.getValue()).isEqualTo("new_value");
  }
View Full Code Here

TOP

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

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.