Package info.archinnov.achilles.internal.metadata.parsing.context

Examples of info.archinnov.achilles.internal.metadata.parsing.context.PropertyParsingContext


    @Test
    public void should_exception_when_embedded_id_has_static_column() throws Exception {
        when(context.getCurrentEntityClass()).thenReturn((Class) EmbeddedKeyWithStaticColumn.class);

        final Field nameField = EmbeddedKeyWithStaticColumn.class.getDeclaredField("name");
        parser = new EmbeddedIdParser(new PropertyParsingContext(context, nameField));

        exception.expect(AchillesBeanMappingException.class);
        exception.expectMessage(format("The property 'rank' of class '%s' cannot be a static column because it belongs to the primary key", EmbeddedKeyWithStaticColumn.class.getCanonicalName()));

        parser.parseEmbeddedId(EmbeddedKeyWithStaticColumn.class, propertyParser);
View Full Code Here


        when(context.getCurrentEntityClass()).thenReturn((Class) EmbeddedKeyAsCompoundPartitionKey.class);

        final Field idField = EmbeddedKeyAsCompoundPartitionKey.class.getDeclaredField("id");
        final Field typeField = EmbeddedKeyAsCompoundPartitionKey.class.getDeclaredField("type");
        parser = new EmbeddedIdParser(new PropertyParsingContext(context, idField));

        EmbeddedIdProperties props = parser.parseEmbeddedId(EmbeddedKeyAsCompoundPartitionKey.class, propertyParser);

        final PartitionComponents partitionComponents = props.getPartitionComponents();
        assertThat(partitionComponents.getComponentClasses()).containsExactly(Long.class, String.class);
View Full Code Here

        //When
        when(context.getCurrentEntityClass()).thenReturn((Class) EmbeddedKeyChild1.class);

        final Field partitionKeyField = EmbeddedKeyParent.class.getDeclaredField("partitionKey");
        final Field clusteringKeyField = EmbeddedKeyChild1.class.getDeclaredField("clustering");
        parser = new EmbeddedIdParser(new PropertyParsingContext(context, partitionKeyField));

        EmbeddedIdProperties props = parser.parseEmbeddedId(EmbeddedKeyChild1.class, propertyParser);

        //Then
        final PartitionComponents partitionComponents = props.getPartitionComponents();
View Full Code Here

        when(context.getCurrentEntityClass()).thenReturn((Class) EmbeddedKeyChild3.class);

        final Field partitionKey1Field = EmbeddedKeyParent.class.getDeclaredField("partitionKey");
        final Field partitionKey2Field = EmbeddedKeyChild2.class.getDeclaredField("partitionKey2");
        final Field clusteringKeyField = EmbeddedKeyChild3.class.getDeclaredField("clustering");
        parser = new EmbeddedIdParser(new PropertyParsingContext(context, partitionKey1Field));

        EmbeddedIdProperties props = parser.parseEmbeddedId(EmbeddedKeyChild3.class, propertyParser);

        //Then
        final PartitionComponents partitionComponents = props.getPartitionComponents();
View Full Code Here

        //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.getCurrentCQL3ColumnName()).isEqualTo("age_in_years");
    }
View Full Code Here

        //Then
        assertThat(actualClass).isEqualTo((Class)String.class);
    }

    private PropertyParsingContext createContext(Field field) {
        return new PropertyParsingContext(context, field);
    }
View Full Code Here

            public void setId(Long id) {
                this.id = id;
            }
        }

        PropertyParsingContext context = newContext(Test.class, Test.class.getDeclaredField("id"));
        context.setPrimaryKey(true);

        PropertyMeta meta = parser.parse(context);

        assertThat(meta.getPropertyName()).isEqualTo("id");
        assertThat(meta.<Long>getValueClass()).isEqualTo(Long.class);
        assertThat(context.getPropertyMetas()).hasSize(1);

    }
View Full Code Here

            public void setName(String name) {
                this.name = name;
            }
        }

        PropertyParsingContext context = newContext(Test.class, Test.class.getDeclaredField("name"));

        PropertyMeta meta = parser.parse(context);

        assertThat(meta.getPropertyName()).isEqualTo("name");
        assertThat(meta.<String>getValueClass()).isEqualTo(String.class);

        assertThat(meta.getGetter().getName()).isEqualTo("getName");
        assertThat((Class<String>) meta.getGetter().getReturnType()).isEqualTo(String.class);
        assertThat(meta.getSetter().getName()).isEqualTo("setName");
        assertThat((Class<String>) meta.getSetter().getParameterTypes()[0]).isEqualTo(String.class);

        assertThat(meta.type()).isEqualTo(PropertyType.SIMPLE);

        assertThat(context.getPropertyMetas().get("name")).isSameAs(meta);

    }
View Full Code Here

            public void setCustomId(Long customId) {
                this.customId = customId;
            }
        }
        PropertyParsingContext context = newContext(Test.class, Test.class.getDeclaredField("customId"));

        PropertyMeta meta = parser.parse(context);

        assertThat(meta.getCQL3ColumnName()).isEqualTo("my_custom_id");
    }
View Full Code Here

            public void setName(String name) {
                this.name = name;
            }
        }
        PropertyParsingContext context = newContext(Test.class, Test.class.getDeclaredField("name"));

        PropertyMeta meta = parser.parse(context);

        assertThat(meta.getCQL3ColumnName()).isEqualTo("firstname");
    }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.internal.metadata.parsing.context.PropertyParsingContext

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.