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

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


    public void should_query_static_counter_column() throws Exception {
        //Given
        Long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        Counter version = CounterBuilder.incr();

        ClusteredEntityWithStaticCounter count1 = new ClusteredEntityWithStaticCounter(new ClusteredKeyForCounter(partitionKey, "count1"), version, CounterBuilder.incr(11));
        ClusteredEntityWithStaticCounter count2 = new ClusteredEntityWithStaticCounter(new ClusteredKeyForCounter(partitionKey, "count2"), null, CounterBuilder.incr(12));

        //When
        manager.insert(count1);
        manager.insert(count2);

        //Then
        List<ClusteredEntityWithStaticCounter> found = manager.sliceQuery(ClusteredEntityWithStaticCounter.class)
                .forSelect()
                .withPartitionComponents(partitionKey)
                .get(100);

        assertThat(found).hasSize(2);
        final ClusteredEntityWithStaticCounter foundCount1 = found.get(0);
        final ClusteredEntityWithStaticCounter foundCount2 = found.get(1);

        assertThat(foundCount1.getCount().get()).isEqualTo(11L);
        assertThat(foundCount2.getCount().get()).isEqualTo(12L);

        ClusteredEntityWithStaticCounter count3 = new ClusteredEntityWithStaticCounter(new ClusteredKeyForCounter(partitionKey, "count3"), version, CounterBuilder.incr(13));
        manager.insert(count3);

        found = manager.sliceQuery(ClusteredEntityWithStaticCounter.class)
                .forSelect()
                .withPartitionComponents(partitionKey)
                .get(100);

        assertThat(found).hasSize(3);
        final ClusteredEntityWithStaticCounter foundNewCount1 = found.get(0);
        final ClusteredEntityWithStaticCounter foundNewCount2 = found.get(1);
        final ClusteredEntityWithStaticCounter foundNewCount3 = found.get(2);

        assertThat(foundNewCount1.getCount().get()).isEqualTo(11L);
        assertThat(foundNewCount1.getVersion().get()).isEqualTo(2L);
        assertThat(foundNewCount2.getCount().get()).isEqualTo(12L);
        assertThat(foundNewCount2.getVersion().get()).isEqualTo(2L);
        assertThat(foundNewCount3.getCount().get()).isEqualTo(13L);
        assertThat(foundNewCount3.getVersion().get()).isEqualTo(2L);
    }
View Full Code Here


    public void should_update_static_counter_and_non_static_counter_column() throws Exception {
        //Given
        Long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        Counter version = CounterBuilder.incr(1L);
        final Counter count = CounterBuilder.incr(11);
        ClusteredEntityWithStaticCounter entity = new ClusteredEntityWithStaticCounter(new ClusteredKeyForCounter(partitionKey, "count1"), version, count);

        //When
        final ClusteredEntityWithStaticCounter managed = manager.insert(entity);
        managed.getCount().incr(2L);
        manager.update(managed);

        //Then
        ClusteredEntityWithStaticCounter updated = manager.find(ClusteredEntityWithStaticCounter.class, entity.getId());
        assertThat(updated.getCount().get()).isEqualTo(13L);
        assertThat(updated.getVersion().get()).isEqualTo(1L);

        //When
        updated.getVersion().incr(2L);
        manager.update(updated);

        //Then
        ClusteredEntityWithStaticCounter staticUpdated = manager.find(ClusteredEntityWithStaticCounter.class, entity.getId());
        assertThat(staticUpdated.getCount().get()).isEqualTo(13L);
        assertThat(staticUpdated.getVersion().get()).isEqualTo(3L);
    }
View Full Code Here

    public void should_lazy_load_static_counter_and_non_static_counter_column() throws Exception {
        //Given
        Long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        Counter version = CounterBuilder.incr(1L);
        final Counter count = CounterBuilder.incr(11);
        ClusteredEntityWithStaticCounter entity = new ClusteredEntityWithStaticCounter(new ClusteredKeyForCounter(partitionKey, "count1"), version, count);

        manager.insert(entity);
        //When
        ClusteredEntityWithStaticCounter proxy = manager.getProxy(ClusteredEntityWithStaticCounter.class, entity.getId());
        assertThat(proxy.getCount().get()).isEqualTo(11L);
        assertThat(proxy.getVersion().get()).isEqualTo(1L);
        proxy.getCount().incr(2L);
        manager.update(proxy);

        //Then
        ClusteredEntityWithStaticCounter updated = manager.find(ClusteredEntityWithStaticCounter.class, entity.getId());
        assertThat(updated.getCount().get()).isEqualTo(13L);
        assertThat(updated.getVersion().get()).isEqualTo(1L);

        //When
        proxy = manager.getProxy(ClusteredEntityWithStaticCounter.class, entity.getId());
        assertThat(proxy.getCount().get()).isEqualTo(13L);
        assertThat(proxy.getVersion().get()).isEqualTo(1L);
        updated.getVersion().incr(2L);
        manager.update(updated);

        //Then
        ClusteredEntityWithStaticCounter staticUpdated = manager.find(ClusteredEntityWithStaticCounter.class, entity.getId());
        assertThat(staticUpdated.getCount().get()).isEqualTo(13L);
        assertThat(staticUpdated.getVersion().get()).isEqualTo(3L);
    }
View Full Code Here

    public void should_delete_static_counter_and_non_static_counter_column() throws Exception {
        //Given
        Long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        Counter version = CounterBuilder.incr(1L);
        final Counter count = CounterBuilder.incr(11);
        ClusteredEntityWithStaticCounter entity = new ClusteredEntityWithStaticCounter(new ClusteredKeyForCounter(partitionKey, "count1"), version, count);
        final ClusteredEntityWithStaticCounter managed = manager.insert(entity);

        //When
        manager.delete(managed);

        Thread.sleep(1000);

        //Then
        ClusteredEntityWithStaticCounter found = manager.find(ClusteredEntityWithStaticCounter.class, entity.getId());
        assertThat(found).isNull();
    }
View Full Code Here

TOP

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

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.