Package info.archinnov.achilles.type

Examples of info.archinnov.achilles.type.Counter


        // Build proxy when necessary
        switch (propertyMeta.type()) {
            case COUNTER:
                if (rawValue == null) {
                    final Counter counter = InternalCounterBuilder.initialValue(null);
                    propertyMeta.forValues().setValueToField(target, counter);
                }
                result = rawValue;
                break;
            case LIST:
View Full Code Here


    public void setCounterToEntity(PropertyMeta counterMeta, Object entity, Long counterValue) {
        if (log.isDebugEnabled()) {
            log.debug("Set counter value {} to property {} of entity class {}", counterValue, counterMeta.getPropertyName(), counterMeta.getEntityClassName());
        }
        final Counter counter = InternalCounterBuilder.initialValue(counterValue);
        counterMeta.forValues().setValueToField(entity, counter);
    }
View Full Code Here

public final class CounterDeserializer extends JsonDeserializer<Counter> {

    @Override
    public Counter deserialize(JsonParser parser, DeserializationContext context) throws IOException {

        Counter counter = null;
        String value = parser.getText();
        if (value != null && !"".equals(value.trim())) {
            try {
                counter = CounterBuilder.incr(Long.parseLong(value));
            } catch (NumberFormatException e) {
View Full Code Here

        entity.setName("name");
        entity.setCount(CounterBuilder.incr());
        entity = manager.insert(entity);

        logAsserter.prepareLogLevel();
        Counter counter = entity.getCount();
        counter.incr(10L);
        assertThat(counter.get()).isEqualTo(11L);
        logAsserter.assertConsistencyLevels(ONE);
    }
View Full Code Here

  @Test
  public void should_get_counter_from_refreshed_entity() throws Exception {
    CompleteBean bean = builder().randomId().buid();
    bean = manager.insert(bean);

    Counter version = bean.getVersion();
    version.incr(5L);

    manager.update(bean);

    assertThat(version.get()).isEqualTo(5L);

    manager.refresh(bean);

    assertThat(bean.getVersion().get()).isEqualTo(5L);
  }
View Full Code Here

        assertThat(found.getName()).isEqualTo(entity.getName());
    }

    @Test
    public void should_return_raw_entities_for_raw_typed_query_with_select_star() throws Exception {
        Counter counter1 = CounterBuilder.incr(15L);
        CompleteBean entity1 = builder().randomId().name("DuyHai").age(35L)
                .addFriends("foo", "bar").addFollowers("George", "Paul").addPreference(1, "FR")
                .addPreference(2, "Paris").addPreference(3, "75014").version(counter1).buid();

        Counter counter2 = CounterBuilder.incr(17L);
        CompleteBean entity2 = builder().randomId().name("John DOO").age(34L)
                .addFriends("qux", "twix").addFollowers("Isaac", "Lara").addPreference(1, "US")
                .addPreference(2, "NewYork").version(counter2).buid();

        manager.insert(entity1);
View Full Code Here

        }
    }

    @Test
    public void should_return_raw_entities_for_raw_typed_query_with_simple_select() throws Exception {
        Counter counter1 = CounterBuilder.incr(15L);
        CompleteBean entity1 = builder().randomId().name("DuyHai").age(35L)
                .addFriends("foo", "bar").addFollowers("George", "Paul").addPreference(1, "FR")
                .addPreference(2, "Paris").addPreference(3, "75014").version(counter1).buid();

        Counter counter2 = CounterBuilder.incr(17L);
        CompleteBean entity2 = builder().randomId().name("John DOO").age(34L)
                .addFriends("qux", "twix").addFollowers("Isaac", "Lara").addPreference(1, "US")
                .addPreference(2, "NewYork").version(counter2).buid();

        manager.insert(entity1);
View Full Code Here

    /////////////////////// STATIC AND NON STATIC COUNTER COLUMNS ////////////////////////////////
    @Test
    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
View Full Code Here

    @Test
    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);
View Full Code Here

    @Test
    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());
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.type.Counter

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.