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

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


    @Test
    public void should_build_interceptor_with_no_eager_fields() throws Exception {

        PropertyMeta idMeta = PropertyMetaTestBuilder.completeBean(Void.class, String.class).propertyName("id").build();

        EntityMeta meta = mock(EntityMeta.class, RETURNS_DEEP_STUBS);
        when(meta.getIdMeta()).thenReturn(idMeta);
        when(meta.getClassName()).thenReturn("classname");
        when(meta.getGetterMetas()).thenReturn(new HashMap<Method, PropertyMeta>());
        when(meta.getSetterMetas()).thenReturn(new HashMap<Method, PropertyMeta>());

        when(context.<CompleteBean>getEntityClass()).thenReturn(CompleteBean.class);
        when(context.getEntityMeta()).thenReturn(meta);
        when(context.getPrimaryKey()).thenReturn(entity.getId());
View Full Code Here


    @Test
    public void should_exception_when_static_column_on_non_clustered_entity() throws Exception {
        //Given
        PropertyMeta idMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        PropertyMeta pm = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        EntityMeta entityMeta = mock(EntityMeta.class, RETURNS_DEEP_STUBS);
        when(entityMeta.getPropertyMetas().values()).thenReturn(Arrays.asList(pm));
        when(pm.structure().isStaticColumn()).thenReturn(true);
        when(entityMeta.getClassName()).thenReturn("myEntity");
        when(idMeta.structure().isClustered()).thenReturn(false);

        //When //Then
        exception.expect(AchillesBeanMappingException.class);
        exception.expectMessage("The entity class 'myEntity' cannot have a static column because it does not declare any clustering column");
View Full Code Here

    public void should_exception_when_clustered_counter_entity_has_only_static_columns() throws Exception {
        //Given
        PropertyMeta idMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        PropertyMeta pm1 = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        PropertyMeta pm2 = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        EntityMeta entityMeta = mock(EntityMeta.class, RETURNS_DEEP_STUBS);
        when(entityMeta.getPropertyMetas().values()).thenReturn(Arrays.asList(pm1,pm2));
        when(entityMeta.getAllMetasExceptId().size()).thenReturn(2);
        when(entityMeta.getClassName()).thenReturn("myEntity");
        when(entityMeta.structure().isClusteredCounter()).thenReturn(true);
        when(idMeta.structure().isClustered()).thenReturn(true);
        when(pm1.structure().isStaticColumn()).thenReturn(true);
        when(pm2.structure().isStaticColumn()).thenReturn(true);
        when(pm1.structure().isCounter()).thenReturn(true);
        when(pm2.structure().isCounter()).thenReturn(true);
View Full Code Here

    }

    @Test
    public void should_add_event_interceptors_to_entity_metas() throws Exception {
        // Given
        final EntityMeta metaString = new EntityMeta();
        final EntityMeta metaLong = new EntityMeta();
        final List<Interceptor<?>> interceptors = Arrays.<Interceptor<?>>asList(stringInterceptor1,stringInterceptor2, longInterceptor);
        final Map<Class<?>, EntityMeta> entityMetaMap = ImmutableMap.<Class<?>, EntityMeta>of(String.class,metaString, Long.class, metaLong);

        // When
        bootstrapper.addInterceptorsToEntityMetas(interceptors, entityMetaMap);

        // Then
        assertThat(metaString.forInterception().getInterceptors()).contains(stringInterceptor1, stringInterceptor2);
        assertThat(metaLong.forInterception().getInterceptors()).contains(longInterceptor);
    }
View Full Code Here

    }

    @Test
    public void should_eager_load_entity() throws Exception {
        // Given
        EntityMeta entityMeta = mock(EntityMeta.class, RETURNS_DEEP_STUBS);


        PropertyMeta pm = PropertyMetaTestBuilder.valueClass(String.class).type(SIMPLE).build();

        when(entityMeta.structure().hasOnlyStaticColumns()).thenReturn(false);
        when(context.<CompleteBean>getEntityClass()).thenReturn(CompleteBean.class);
        when(context.getEntityMeta()).thenReturn(entityMeta);
        when(entityMeta.getAllMetasExceptId()).thenReturn(asList(pm));
        when(selectEagerPSs.get(CompleteBean.class)).thenReturn(ps);
        when(overrider.getReadLevel(context)).thenReturn(LOCAL_QUORUM);
        when(binder.bindStatementWithOnlyPKInWhereClause(context, ps, false, LOCAL_QUORUM)).thenReturn(bsWrapper);
        when(context.executeImmediate(bsWrapper)).thenReturn(futureResultSet);
        when(asyncUtils.transformFuture(futureResultSet, RESULTSET_TO_ROW, executorService)).thenReturn(futureRow);
View Full Code Here

        when(context.getOptions()).thenReturn(noOptions());
    }

    @Test
    public void should_get_cache_for_simple_field() throws Exception {
        EntityMeta meta = new EntityMeta();

        PropertyMeta pm = PropertyMetaTestBuilder.valueClass(String.class)
                .propertyName("name").cqlColumnName("name").type(SIMPLE)
                .build();
View Full Code Here

        assertThat(cacheKey.getFields()).containsExactly("name");
    }

    @Test
    public void should_get_cache_for_clustered_id() throws Exception {
        EntityMeta meta = new EntityMeta();
        PropertyMeta pm = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(context.<CompleteBean>getEntityClass()).thenReturn(CompleteBean.class);
        when(context.getEntityMeta()).thenReturn(meta);
        when(pm.forCache().extractClusteredFieldsIfNecessary()).thenReturn(Sets.newLinkedHashSet("id", "a", "b"));
View Full Code Here

        assertThat(cacheKey.getFields()).containsOnly("id", "a", "b");
    }

    @Test
    public void should_generate_select_prepared_statement_when_not_found_in_cache() throws Exception {
        EntityMeta meta = new EntityMeta();
//        meta.setTableName("table");

        PropertyMeta pm = PropertyMetaTestBuilder.valueClass(String.class).propertyName("name").type(SIMPLE)
                .build();
View Full Code Here

        verify(cache).put(cacheKey, ps);
    }

    @Test
    public void should_get_cache_for_entity_insert() throws Exception {
        EntityMeta meta = new EntityMeta();
//        meta.setTableName("table");

        PropertyMeta nameMeta = completeBean(Void.class, String.class).propertyName("name").type(SIMPLE).build();
        PropertyMeta ageMeta = completeBean(Void.class, String.class).propertyName("age").type(SIMPLE).build();
View Full Code Here

        assertThat(cacheKey.getFields()).containsOnly("name", "age");
    }

    @Test
    public void should_generate_insert_prepared_statement_when_not_found_in_cache() throws Exception {
        EntityMeta meta = new EntityMeta();
//        meta.setTableName("table");

        PropertyMeta nameMeta = completeBean(Void.class, String.class).propertyName("name").type(SIMPLE).build();

        PropertyMeta ageMeta = completeBean(Void.class, String.class).propertyName("age").type(SIMPLE).build();
View Full Code Here

TOP

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

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.