@Test
  public void should_set_primaryKey_to_true_when_embedded_id() throws Exception {
    // Given
    EntityParsingContext entityContext = mock(EntityParsingContext.class, RETURNS_DEEP_STUBS);
    when(entityContext.getCurrentEntityClass()).thenReturn((Class) CompleteBean.class);
    Field field = CompleteBean.class.getDeclaredField("age");

    PropertyParsingContext context = new PropertyParsingContext(entityContext, field);

    // When
    context.setEmbeddedId(true);

    // Then
    assertThat(context.isEmbeddedId()).isTrue();
    assertThat(context.isPrimaryKey()).isTrue();
    assertThat(context.<CompleteBean>getCurrentEntityClass()).isEqualTo(CompleteBean.class);
    assertThat(context.getCurrentPropertyName()).isEqualTo("age_in_years");
  }
  public PropertyMeta parse(PropertyParsingContext context) {
    log.debug(
        "Parsing property {} of entity class {}",
        context.getCurrentPropertyName(),
        context.getCurrentEntityClass().getCanonicalName());

    Field field = context.getCurrentField();
    inferPropertyName(context);
    context.setCustomConsistencyLevels(hasConsistencyAnnotation(context.getCurrentField()));

    validator.validateNoDuplicate(context);
    validator.validateIndexIfSet(context);

    Class<?> fieldType = field.getType();
    PropertyMeta propertyMeta;

    if (List.class.isAssignableFrom(fieldType)) {
      propertyMeta = parseListProperty(context);
    } else if (Set.class.isAssignableFrom(fieldType)) {
      propertyMeta = parseSetProperty(context);
    } else if (Map.class.isAssignableFrom(fieldType)) {
      propertyMeta = parseMapProperty(context);
    } else if (Counter.class.isAssignableFrom(fieldType)) {
      propertyMeta = parseCounterProperty(context);
    } else if (context.isEmbeddedId()) {
      propertyMeta = parseEmbeddedId(context);
    } else if (context.isPrimaryKey()) {
      propertyMeta = parseId(context);
    } else {
      propertyMeta = parseSimpleProperty(context);
      String indexName = getIndexName(field);
      if (indexName != null) {
        propertyMeta.setIndexProperties(new IndexProperties(indexName));
      }
    }
    context.getPropertyMetas().put(context.getCurrentPropertyName(), propertyMeta);
    return propertyMeta;
  }