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

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


      AbstractFlushContext flushContext) {
    log.trace("Build new PersistenceContext for entity '{}' with options '{}' and flush context '{}'", entity,
        options, flushContext);
    Validator.validateNotNull(entity, "entity should not be null for persistence context creation");
    Class<?> entityClass = proxifier.deriveBaseClass(entity);
    EntityMeta meta = entityMetaMap.get(entityClass);
    return new PersistenceContext(meta, configContext, daoContext, flushContext, entity, options);
  }
View Full Code Here


    log.trace(
        "Build new PersistenceContext for entity class '{}' with primary key '{}', options '{}' and flush context '{}'",
        entityClass, primaryKey, options, flushContext);
    Validator.validateNotNull(entityClass, "entityClass should not be null for persistence context creation");
    Validator.validateNotNull(primaryKey, "primaryKey should not be null for persistence context creation");
    EntityMeta meta = entityMetaMap.get(entityClass);
    return new PersistenceContext(meta, configContext, daoContext, flushContext, entityClass, primaryKey, options);
  }
View Full Code Here

  public PersistenceContext newContextForSliceQuery(Class<?> entityClass, List<Object> partitionComponents,
      ConsistencyLevel cl) {
    log.trace(
        "Build new PersistenceContext for slice query on entity class '{}' with partition key components '{}' and Consistency Level '{}'",
        entityClass, partitionComponents, cl);
    EntityMeta meta = entityMetaMap.get(entityClass);
        Object embeddedId = meta.getIdMeta().forSliceQueryContext().instantiateEmbeddedIdWithPartitionComponents(partitionComponents);

    ImmediateFlushContext flushContext = buildImmediateFlushContext(OptionsBuilder.withConsistency(cl));

    return new PersistenceContext(meta, configContext, daoContext, flushContext, entityClass, embeddedId,
        OptionsBuilder.withConsistency(cl));
View Full Code Here

        validator.validateHasIdMeta(entityClass, idMeta);

        // Deferred counter property meta completion
        completeCounterPropertyMeta(context, idMeta);

        EntityMeta entityMeta = entityMetaBuilder(idMeta).entityClass(entityClass)
                .className(entityClass.getCanonicalName())
                .keyspaceName(keyspaceName)
                .tableName(tableName).tableComment(tableComment)
                .propertyMetas(context.getPropertyMetas()).consistencyLevels(context.getCurrentConsistencyLevels())
                .insertStrategy(insertStrategy)
View Full Code Here

    }

    @Test
    public void should_validate_for_entity() throws Exception {
        // Given
        EntityMeta entityMeta = mock(EntityMeta.class);
        TableMetadata tableMetaData = mock(TableMetadata.class);

        // When
        context.validateForEntity(entityMeta, tableMetaData);
View Full Code Here

    @Test
    public void should_fetch_table_metas() throws Exception {
        // Given
        Map<String, TableMetadata> expected = new HashMap<>();
        EntityMeta meta = mock(EntityMeta.class, RETURNS_DEEP_STUBS);
        final List<EntityMeta> entityMetas = Arrays.asList(meta);
        when(entityMetaMap.values()).thenReturn(entityMetas);


        // When
View Full Code Here

    }

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

        // When
        context.createTableForEntity(entityMeta);

        // Then
View Full Code Here

    }

    @Test
  public void should_update_table_for_entity() throws Exception {
    // Given
    EntityMeta entityMeta = mock(EntityMeta.class);
    TableMetadata tableMetadata = mock(TableMetadata.class);

    // When
    context.updateForEntity(entityMeta, tableMetadata);
View Full Code Here

    @Test
    public void should_parse_entity() throws Exception {

        configContext.setEnableSchemaUpdate(true);
        initEntityParsingContext(Bean.class);
        EntityMeta meta = parser.parseEntity(entityContext);

        assertThat(meta.getClassName()).isEqualTo("info.archinnov.achilles.test.parser.entity.Bean");
        assertThat(meta.config().getQualifiedTableName()).isEqualTo("ks.bean");
        assertThat(meta.getIdMeta().<Long>getValueClass()).isEqualTo(Long.class);
        assertThat(meta.getIdMeta().getPropertyName()).isEqualTo("id");
        assertThat(meta.<Long>getIdClass()).isEqualTo(Long.class);
        assertThat(meta.getPropertyMetas()).hasSize(8);

        PropertyMeta id = meta.getPropertyMetas().get("id");
        PropertyMeta name = meta.getPropertyMetas().get("name");
        PropertyMeta age = meta.getPropertyMetas().get("age");
        PropertyMeta friends = meta.getPropertyMetas().get("friends");
        PropertyMeta followers = meta.getPropertyMetas().get("followers");
        PropertyMeta preferences = meta.getPropertyMetas().get("preferences");

        PropertyMeta creator = meta.getPropertyMetas().get("creator");
        PropertyMeta count = meta.getPropertyMetas().get("count");

        assertThat(id).isNotNull();
        assertThat(name).isNotNull();
        assertThat(age).isNotNull();
        assertThat(friends).isNotNull();
        assertThat(followers).isNotNull();
        assertThat(preferences).isNotNull();
        assertThat(creator).isNotNull();
        assertThat(count).isNotNull();

        assertThat(id.getPropertyName()).isEqualTo("id");
        assertThat(id.<Long>getValueClass()).isEqualTo(Long.class);
        assertThat(id.type()).isEqualTo(ID);
        assertThat(id.structure().getReadConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE);
        assertThat(id.structure().getWriteConsistencyLevel()).isEqualTo(ConsistencyLevel.ALL);

        assertThat(name.getPropertyName()).isEqualTo("name");
        assertThat(name.<String>getValueClass()).isEqualTo(String.class);
        assertThat(name.type()).isEqualTo(SIMPLE);
        assertThat(name.structure().getReadConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE);
        assertThat(name.structure().getWriteConsistencyLevel()).isEqualTo(ConsistencyLevel.ALL);

        assertThat(age.getPropertyName()).isEqualTo("age");
        assertThat(age.getCQL3ColumnName()).isEqualTo("age_in_year");
        assertThat(age.<Long>getValueClass()).isEqualTo(Long.class);
        assertThat(age.type()).isEqualTo(SIMPLE);
        assertThat(age.structure().getReadConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE);
        assertThat(age.structure().getWriteConsistencyLevel()).isEqualTo(ConsistencyLevel.ALL);

        assertThat(friends.getPropertyName()).isEqualTo("friends");
        assertThat(friends.<String>getValueClass()).isEqualTo(String.class);
        assertThat(friends.type()).isEqualTo(PropertyType.LIST);
        assertThat(friends.structure().getReadConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE);
        assertThat(friends.structure().getWriteConsistencyLevel()).isEqualTo(ConsistencyLevel.ALL);

        assertThat(followers.getPropertyName()).isEqualTo("followers");
        assertThat(followers.<String>getValueClass()).isEqualTo(String.class);
        assertThat(followers.type()).isEqualTo(PropertyType.SET);
        assertThat(followers.structure().getReadConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE);
        assertThat(followers.structure().getWriteConsistencyLevel()).isEqualTo(ConsistencyLevel.ALL);

        assertThat(preferences.getPropertyName()).isEqualTo("preferences");
        assertThat(preferences.<String>getValueClass()).isEqualTo(String.class);
        assertThat(preferences.type()).isEqualTo(PropertyType.MAP);
        assertThat(preferences.<Integer>getKeyClass()).isEqualTo(Integer.class);
        assertThat(preferences.structure().getReadConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE);
        assertThat(preferences.structure().getWriteConsistencyLevel()).isEqualTo(ConsistencyLevel.ALL);

        assertThat(creator.getPropertyName()).isEqualTo("creator");
        assertThat(creator.<UserBean>getValueClass()).isEqualTo(UserBean.class);
        assertThat(creator.type()).isEqualTo(SIMPLE);

        assertThat(count.getPropertyName()).isEqualTo("count");
        assertThat(count.<Counter>getValueClass()).isEqualTo(Counter.class);
        assertThat(count.type()).isEqualTo(COUNTER);

        assertThat(meta.config().getReadConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE);
        assertThat(meta.config().getWriteConsistencyLevel()).isEqualTo(ConsistencyLevel.ALL);

        assertThat(meta.getAllMetasExceptIdAndCounters()).hasSize(6).containsOnly(name, age, friends, followers, preferences, creator);
        assertThat(meta.getAllMetasExceptCounters()).hasSize(7).containsOnly(id, name, age, friends, followers, preferences, creator);

        assertThat(meta.config().getInsertStrategy()).isEqualTo(InsertStrategy.ALL_FIELDS);
        assertThat(meta.config().isSchemaUpdateEnabled()).isTrue();
    }
View Full Code Here

    @Test
    public void should_build_interceptor_with_eager_fields_already_loaded() 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

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.