Package info.archinnov.achilles.test.mapping.entity

Examples of info.archinnov.achilles.test.mapping.entity.CompleteBean


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

        when(embeddedIdProperties.getCQL3ComponentClasses()).thenReturn(Arrays.<Class<?>>asList(Long.class,String.class));
        when(embeddedIdProperties.getCQL3ComponentNames()).thenReturn(asList("id", "name"));

        Definition columnDef1 = ColumnDefinitionBuilder.buildColumnDef("ks", "table", "id", DataType.bigint());
View Full Code Here


    @Test
    public void should_create_empty_entity() throws Exception {
        when(meta.forOperations().instanciate()).thenReturn(entity);

        CompleteBean actual = loader.createEmptyEntity(context, CompleteBean.class);

        assertThat(actual).isSameAs(entity);

        verify(idMeta.forValues()).setValueToField(actual, primaryKey);
    }
View Full Code Here

        final AchillesFuture<CompleteBean> actual = loader.load(context, CompleteBean.class);

        // Then
        assertThat(actual).isSameAs(achillesFutureEntity);

        final CompleteBean actualEntity = rowToEntityCaptor.getValue().apply(row);
        assertThat(actualEntity).isSameAs(entity);

        verify(mapper).setNonCounterPropertiesToEntity(row, meta, entity);

        verifyZeroInteractions(counterLoader);
View Full Code Here

        final AchillesFuture<CompleteBean> actual = loader.load(context, CompleteBean.class);

        // Then
        assertThat(actual).isSameAs(achillesFutureEntity);

        final CompleteBean actualEntity = rowToEntityCaptor.getValue().apply(null);
        assertThat(actualEntity).isNull();
        verify(meta.forOperations(), never()).instanciate();
        verifyZeroInteractions(counterLoader, mapper);
    }
View Full Code Here

    @Mock
    private PropertyMeta idMeta;

    @Test
    public void should_derive_base_class_from_transient() throws Exception {
        assertThat(proxifier.<CompleteBean>deriveBaseClass(new CompleteBean())).isEqualTo(CompleteBean.class);
    }
View Full Code Here

        assertThat(proxifier.<CompleteBean>deriveBaseClass(new CompleteBean())).isEqualTo(CompleteBean.class);
    }

    @Test
    public void should_derive_base_class() throws Exception {
        CompleteBean entity = CompleteBeanTestBuilder.builder().id(1L).buid();
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(entity.getClass());
        enhancer.setCallback(interceptor);

        when(interceptor.getTarget()).thenReturn(entity);

        CompleteBean proxy = (CompleteBean) enhancer.create();
        assertThat(proxifier.<CompleteBean>deriveBaseClass(proxy)).isEqualTo(CompleteBean.class);
    }
View Full Code Here

        long primaryKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        PropertyMeta pm = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        PropertyMeta counterMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        Object value = new Object();

        CompleteBean entity = CompleteBeanTestBuilder.builder().id(primaryKey).name("name").buid();
        proxifier = spy(proxifier);

        doReturn(interceptor).when(proxifier).buildInterceptor(eq(context), eq(entity), anySetOf(Method.class));
        when(context.getEntityMeta()).thenReturn(entityMeta);
        when(entityMeta.getIdMeta()).thenReturn(idMeta);
        when(entityMeta.getAllMetasExceptCounters()).thenReturn(Arrays.asList(pm));
        when(entityMeta.getAllCounterMetas()).thenReturn(Arrays.asList(counterMeta));
        when(pm.forValues().getValueFromField(entity)).thenReturn(value);
        when(context.getConfigContext()).thenReturn(configContext);
        when(factory.createProxyClass(entity.getClass(), configContext)).thenReturn((Class) entity.getClass());
        when(instantiator.instantiate(Mockito.<Class<Factory>>any())).thenReturn(realProxy);

        Object proxy = proxifier.buildProxyWithAllFieldsLoadedExceptCounters(entity, context);

        assertThat(proxy).isNotNull();
View Full Code Here

    public void should_proxy_true() throws Exception {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(CompleteBean.class);
        enhancer.setCallback(NoOp.INSTANCE);

        CompleteBean proxy = (CompleteBean) enhancer.create();

        assertThat(proxifier.isProxy(proxy)).isTrue();
    }
View Full Code Here

        assertThat(proxifier.isProxy(proxy)).isTrue();
    }

    @Test
    public void should_proxy_false() throws Exception {
        CompleteBean bean = CompleteBeanTestBuilder.builder().id(1L).buid();
        assertThat(proxifier.isProxy(bean)).isFalse();
    }
View Full Code Here

    public void should_get_interceptor_from_proxy() throws Exception {

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(CompleteBean.class);
        enhancer.setCallback(interceptor);
        CompleteBean proxy = (CompleteBean) enhancer.create();

        ProxyInterceptor<CompleteBean> actual = proxifier.getInterceptor(proxy);

        assertThat(actual).isSameAs(interceptor);
    }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.test.mapping.entity.CompleteBean

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.