Package info.archinnov.achilles.internal.metadata.holder

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta


    @Test
    public void should_bind_for_simple_counter_select() throws Exception {

        Long primaryKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        PropertyMeta counterMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(context.getPrimaryKey()).thenReturn(primaryKey);
        when(overrider.getWriteLevel(context)).thenReturn(ALL);
        when(entityMeta.getClassName()).thenReturn("CompleteBean");
        when(idMeta.forTranscoding().forceEncodeToJSONForCounter(primaryKey)).thenReturn(primaryKey.toString());
        when(counterMeta.getCQL3ColumnName()).thenReturn("count");

        when(ps.bind("CompleteBean", primaryKey.toString(), "count")).thenReturn(bs);

        BoundStatementWrapper actual = binder.bindForSimpleCounterSelect(context, ps, counterMeta, ALL);
View Full Code Here


    @Test
    public void should_get_simple_counter() throws Exception {
        // Given
        Row row = mock(Row.class);
        PropertyMeta pm = PropertyMetaTestBuilder.valueClass(String.class).propertyName("name").consistencyLevels(Pair.create(EACH_QUORUM, EACH_QUORUM)).build();

        when(counterQueryMap.get(CQLQueryType.SELECT)).thenReturn(ps);
        when(binder.bindForSimpleCounterSelect(context, ps, pm, EACH_QUORUM)).thenReturn(bsWrapper);
        when(context.executeImmediate(bsWrapper)).thenReturn(futureResultSet);
        when(asyncUtils.transformFuture(futureResultSet, RESULTSET_TO_ROW, executorService)).thenReturn(futureRow);
View Full Code Here

    }

    @Test
    public void should_bind_simple_counter_delete() throws Exception {
        // Given
        PropertyMeta pm = PropertyMetaTestBuilder.valueClass(String.class).propertyName("name").consistencyLevels(Pair.create(EACH_QUORUM, EACH_QUORUM)).build();

        // When
        when(context.getConsistencyLevel()).thenReturn(Optional.<ConsistencyLevel>fromNullable(null));
        when(counterQueryMap.get(CQLQueryType.DELETE)).thenReturn(ps);
        when(binder.bindForSimpleCounterDelete(context, ps, pm)).thenReturn(bsWrapper);
View Full Code Here

    // Clustered counter
    @Test
    public void should_push_clustered_counter_increment() throws Exception {
        // Given
        PropertyMeta counterMeta = PropertyMetaTestBuilder.valueClass(Long.class).propertyName("count")
                .consistencyLevels(Pair.create(EACH_QUORUM, EACH_QUORUM)).staticColumn(false).build();

        // When
        when(context.getTtl()).thenReturn(Optional.<Integer>absent());
        when(context.getConsistencyLevel()).thenReturn(Optional.<ConsistencyLevel>fromNullable(null));
View Full Code Here

    }

    @Test
    public void should_get_clustered_counter_column() throws Exception {
        // Given
        PropertyMeta counterMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        when(counterMeta.getCQL3ColumnName()).thenReturn("counter");
        when(counterMeta.structure().isStaticColumn()).thenReturn(true);
        Row row = mock(Row.class);

        clusteredCounterQueryMap.put(CompleteBean.class, ImmutableMap.<CQLQueryType, Map<String, PreparedStatement>>of(SELECT, of("counter", ps)));
        when(overrider.getReadLevel(context, counterMeta)).thenReturn(EACH_QUORUM);
        when(binder.bindForClusteredCounterSelect(context, ps, true, EACH_QUORUM)).thenReturn(bsWrapper);
View Full Code Here

    }

    @Test
    public void should_bind_for_simple_counter_delete() throws Exception {
        Long primaryKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        PropertyMeta counterMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(context.getPrimaryKey()).thenReturn(primaryKey);
        when(overrider.getWriteLevel(context)).thenReturn(ALL);
        when(entityMeta.getClassName()).thenReturn("CompleteBean");
        when(idMeta.forTranscoding().forceEncodeToJSONForCounter(primaryKey)).thenReturn(primaryKey.toString());
        when(counterMeta.getCQL3ColumnName()).thenReturn("count");

        when(ps.bind("CompleteBean", primaryKey.toString(), "count")).thenReturn(bs);

        BoundStatementWrapper actual = binder.bindForSimpleCounterDelete(context, ps, counterMeta);
View Full Code Here

    @Test
    public void should_bind_for_clustered_counter_increment_decrement() throws Exception {
        Long primaryKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        Long increment = RandomUtils.nextLong(0,Long.MAX_VALUE);
        PropertyMeta counterMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(context.getPrimaryKey()).thenReturn(primaryKey);
        when(overrider.getWriteLevel(context)).thenReturn(ALL);

        when(counterMeta.structure().isStaticColumn()).thenReturn(false);
        when(idMeta.structure().isEmbeddedId()).thenReturn(false);
        when(idMeta.forTranscoding().encodeToCassandra(primaryKey)).thenReturn(primaryKey);


        when(ps.bind(increment, primaryKey)).thenReturn(bs);
View Full Code Here

    }

    @Test
    public void should_bind_for_clustered_counter_select() throws Exception {
        Long primaryKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        PropertyMeta counterMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(context.getPrimaryKey()).thenReturn(primaryKey);
        when(overrider.getWriteLevel(context)).thenReturn(ALL);

        when(counterMeta.structure().isStaticColumn()).thenReturn(false);
        when(idMeta.structure().isEmbeddedId()).thenReturn(false);
        when(idMeta.forTranscoding().encodeToCassandra(primaryKey)).thenReturn(primaryKey);

        when(ps.bind(primaryKey)).thenReturn(bs);
View Full Code Here

    }

    @Test
    public void should_bind_for_clustered_counter_delete() throws Exception {
        Long primaryKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        PropertyMeta counterMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(context.getPrimaryKey()).thenReturn(primaryKey);
        when(overrider.getWriteLevel(context)).thenReturn(ALL);
        when(counterMeta.structure().isStaticColumn()).thenReturn(false);
        when(idMeta.structure().isEmbeddedId()).thenReturn(false);
        when(idMeta.forTranscoding().encodeToCassandra(primaryKey)).thenReturn(primaryKey);

        when(ps.bind(primaryKey)).thenReturn(bs);
View Full Code Here

        }

        PropertyParsingContext context = newContext(Test.class, Test.class.getDeclaredField("id"));
        context.setPrimaryKey(true);

        PropertyMeta meta = parser.parse(context);

        assertThat(meta.getPropertyName()).isEqualTo("id");
        assertThat(meta.<Long>getValueClass()).isEqualTo(Long.class);
        assertThat(context.getPropertyMetas()).hasSize(1);

    }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.internal.metadata.holder.PropertyMeta

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.