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

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


    }

    @Test
    public void should_update_table_with_new_list_field() throws Exception {
        // Given
        PropertyMeta idMeta = valueClass(Long.class).type(ID).cqlColumnName("id").build();
        PropertyMeta listStringPM = valueClass(String.class).type(LIST).cqlColumnName("list_string").build();

        when(meta.getAllMetasExceptId()).thenReturn(asList(listStringPM));
        when(meta.getIdMeta()).thenReturn(idMeta);
        when(tableMeta.getColumns()).thenReturn(Arrays.<ColumnMetadata>asList());
View Full Code Here


    }

    @Test
    public void should_update_table_with_new_set_field() throws Exception {
        // Given
        PropertyMeta idMeta = valueClass(Long.class).type(ID).cqlColumnName("id").build();
        PropertyMeta setStringPM = valueClass(String.class).type(SET).cqlColumnName("set_string").build();

        when(meta.getAllMetasExceptId()).thenReturn(asList(setStringPM));
        when(meta.getIdMeta()).thenReturn(idMeta);
        when(tableMeta.getColumns()).thenReturn(Arrays.<ColumnMetadata>asList());
View Full Code Here

    }

    @Test
    public void should_update_table_with_new_map_field() throws Exception {
        // Given
        PropertyMeta idMeta = valueClass(Long.class).type(ID).cqlColumnName("id").build();
        PropertyMeta mapStringPM = completeBean(Integer.class, String.class).type(MAP).cqlColumnName("preferences").build();

        when(meta.getAllMetasExceptId()).thenReturn(asList(mapStringPM));
        when(meta.getIdMeta()).thenReturn(idMeta);
        when(tableMeta.getColumns()).thenReturn(Arrays.<ColumnMetadata>asList());
View Full Code Here

    }

    @Test
    public void should_update_table_with_new_clustered_counter_field() throws Exception {
        // Given
        PropertyMeta idMeta = valueClass(Long.class).type(ID).cqlColumnName("id").build();
        PropertyMeta counterPM = valueClass(Counter.class).type(COUNTER).cqlColumnName("count").build();

        when(meta.getAllMetasExceptId()).thenReturn(asList(counterPM));
        when(meta.getIdMeta()).thenReturn(idMeta);
        when(tableMeta.getColumns()).thenReturn(Arrays.<ColumnMetadata>asList());
        when(meta.structure().isClusteredCounter()).thenReturn(true);
View Full Code Here

        assertThat(stringCaptor.getValue()).isEqualTo("\n\tALTER TABLE tableName ADD count counter");
    }

    @Test
    public void should_not_add_counter_field_if_non_clustered_counter_entity() throws Exception {
        PropertyMeta idMeta = valueClass(Long.class).type(ID).propertyName("id").build();
        PropertyMeta counterPM = valueClass(Counter.class).type(COUNTER).propertyName("count").build();

        when(meta.getAllMetasExceptId()).thenReturn(asList(counterPM));
        when(meta.getIdMeta()).thenReturn(idMeta);
        when(tableMeta.getColumns()).thenReturn(Arrays.<ColumnMetadata>asList());
        when(meta.structure().isClusteredCounter()).thenReturn(false);
View Full Code Here

        when(proxifier.getRealObject(entity)).thenReturn(entity);
        when(proxifier.getInterceptor(entity)).thenReturn(interceptor);
        when(interceptor.getDirtyMap()).thenReturn(dirtyMap);
        when(meta.getAllCounterMetas()).thenReturn(allCounterMetas);

        PropertyMeta pm = PropertyMetaTestBuilder.completeBean(Void.class, UserBean.class).propertyName("user").type(SIMPLE)
                .accessors().build();
        DirtyChecker dirtyChecker = new SimpleDirtyChecker(pm);
        dirtyMap.put(pm.getGetter(), dirtyChecker);
        when(context.isClusteredCounter()).thenReturn(false);

        entityUpdater.update(context, entity);

        verify(context).setEntity(entity);
View Full Code Here

        when(proxifier.isProxy(entity)).thenReturn(true);
        when(proxifier.getRealObject(entity)).thenReturn(entity);
        when(proxifier.getInterceptor(entity)).thenReturn(interceptor);
        when(interceptor.getDirtyMap()).thenReturn(dirtyMap);

        PropertyMeta pm = PropertyMetaTestBuilder.completeBean(Void.class, UserBean.class).propertyName("user").type(SIMPLE)
                .accessors().build();
        DirtyChecker dirtyChecker = new SimpleDirtyChecker(pm);
        dirtyMap.put(pm.getGetter(), dirtyChecker);
        when(context.isClusteredCounter()).thenReturn(true);

        entityUpdater.update(context, entity);

        verify(context).setEntity(entity);
View Full Code Here

        validator.validateRawTypedQuery(CompleteBean.class, statement, meta);
    }

    @Test
    public void should_exception_when_missing_id_column() throws Exception {
        PropertyMeta idMeta = PropertyMetaTestBuilder.completeBean(Void.class, Long.class).propertyName("id").cqlColumnName("id").type(PropertyType.ID).build();

        when(meta.getIdMeta()).thenReturn(idMeta);

        final RegularStatement statement = select("name","age").from("table").where(eq("col", 10L));
View Full Code Here

        validator.validateTypedQuery(CompleteBean.class, statement, meta);
    }

    @Test
    public void should_skip_id_column_validation_when_select_star() throws Exception {
        PropertyMeta idMeta = PropertyMetaTestBuilder.completeBean(Void.class, Long.class).propertyName("id").type(PropertyType.ID).build();

        when(meta.getIdMeta()).thenReturn(idMeta);

        final RegularStatement statement = select().from("table").where(eq("id",10L));
View Full Code Here

    @Test
    public void should_set_value_to_clustered_counter_entity() throws Exception {
        //Given
        Long counterValue = 10L;
        PropertyMeta counterMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        when(counterMeta.getCQL3ColumnName()).thenReturn("counter");
        when(entityMeta.getAllCounterMetas()).thenReturn(asList(counterMeta));
        when(cqlRowInvoker.invokeOnRowForType(row, Long.class, "counter")).thenReturn(counterValue);

        //When
        entityMapper.setValuesToClusteredCounterEntity(row, entityMeta, entity);

        //Then
        verify(counterMeta.forValues()).setValueToField(eq(entity), counterCaptor.capture());

        assertThat(counterCaptor.getValue().get()).isEqualTo(counterValue);
    }
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.