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

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


        assertThat(sliceIterator.hasNext()).isFalse();
    }

    @Test
    public void should_get_next_clustered_entity() throws Exception {
        ClusteredEntity entity = new ClusteredEntity();
        Row row = mock(Row.class);

        when(meta.<ClusteredEntity>getEntityClass()).thenReturn(ClusteredEntity.class);
        when(meta.forOperations().instanciate()).thenReturn(entity);

        when(iterator.next()).thenReturn(row);

        when(cqlInvoker.invokeOnRowForType(row, String.class, "name")).thenReturn("name1");

        when(context.duplicate(entity)).thenReturn(context);
        when(proxifier.buildProxyWithAllFieldsLoadedExceptCounters(entity, entityFacade)).thenReturn(entity);

        ClusteredEntity actual = sliceIterator.next();

        assertThat(actual).isSameAs(entity);
        verify(meta.forInterception()).intercept(entity, Event.POST_LOAD);
        verify(mapper).setNonCounterPropertiesToEntity(row, meta, entity);
    }
View Full Code Here


        verify(valueMeta.forValues()).setValueToField(entity, "value");
    }

    @Test
    public void should_map_row_to_entity_with_primary_key() throws Exception {
        ClusteredEntity entity = new ClusteredEntity();
        EmbeddedKey embeddedKey = new EmbeddedKey();
        PropertyMeta idMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(idMeta.structure().isEmbeddedId()).thenReturn(true);

        Map<String, PropertyMeta> propertiesMap = new HashMap<>();

        when(row.getColumnDefinitions()).thenReturn(columnDefs);
        when(columnDefs.iterator()).thenReturn(Arrays.<Definition>asList().iterator());
        when(entityMeta.forOperations().instanciate()).thenReturn(entity);
        when(entityMeta.getIdMeta()).thenReturn(idMeta);
        when(idMeta.forRowExtraction().extractCompoundPrimaryKeyFromRow(row, entityMeta, MANAGED)).thenReturn(embeddedKey);

        ClusteredEntity actual = entityMapper.mapRowToEntityWithPrimaryKey(entityMeta, row, propertiesMap, MANAGED);

        assertThat(actual).isSameAs(entity);
        verify(idMeta.forValues()).setValueToField(entity, embeddedKey);
    }
View Full Code Here

        verify(idMeta.forValues()).setValueToField(entity, embeddedKey);
    }

    @Test
    public void should_not_map_row_to_entity_with_primary_key_when_entity_null() {
        ClusteredEntity actual = entityMapper.mapRowToEntityWithPrimaryKey(entityMeta, row, null, MANAGED);

        assertThat(actual).isNull();
    }
View Full Code Here

TOP

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

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.