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

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



        PropertyMeta idMeta = null;
        List<Field> inheritedFields = introspector.getInheritedPrivateFields(entityClass);
        for (Field field : inheritedFields) {
            PropertyParsingContext propertyContext = context.newPropertyContext(field);
            if (filter.hasAnnotation(field, Id.class)) {
                propertyContext.setPrimaryKey(true);
                idMeta = parser.parse(propertyContext);
            } else if (filter.hasAnnotation(field, EmbeddedId.class)) {
                propertyContext.setEmbeddedId(true);
                idMeta = parser.parse(propertyContext);
            } else if (filter.hasAnnotation(field, Column.class)) {
                parser.parse(propertyContext);
            } else {
                log.trace("Un-mapped field {} of entity {} will not be managed by Achilles", field.getName(), context
View Full Code Here


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


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


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

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

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

        final Field nameField = CorrectEmbeddedReversedKey.class.getDeclaredField("name");
        final Field rankField = CorrectEmbeddedReversedKey.class.getDeclaredField("rank");
        final Field countField = CorrectEmbeddedReversedKey.class.getDeclaredField("count");
        parser = new EmbeddedIdParser(new PropertyParsingContext(context, nameField));

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

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

    public void should_exception_when_embedded_id_incorrect_type() throws Exception {

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

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

        exception.expect(AchillesBeanMappingException.class);
        exception.expectMessage(format("The class '%s' is not a valid component type for the @EmbeddedId class '%s'",
                List.class.getCanonicalName(), EmbeddedKeyIncorrectType.class.getCanonicalName()));
View Full Code Here

    public void should_exception_when_embedded_id_wrong_key_order() throws Exception {

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

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

        exception.expect(AchillesBeanMappingException.class);
        exception.expectMessage(format("The component ordering is wrong for @EmbeddedId class '%s'",EmbeddedKeyWithNegativeOrder.class.getCanonicalName()));

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

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

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

        exception.expect(AchillesBeanMappingException.class);
        exception.expectMessage(format("There should be at least 2 fields annotated with @Order for the @EmbeddedId class '%s'",EmbeddedKeyWithNoAnnotation.class.getCanonicalName()));

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

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

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

        exception.expect(AchillesBeanMappingException.class);
        exception.expectMessage(format("The order '1' is duplicated in @EmbeddedId class '%s",EmbeddedKeyWithDuplicateOrder.class.getCanonicalName()));

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

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

        final Field userField = EmbeddedKeyWithOnlyOneComponent.class.getDeclaredField("userId");
        parser = new EmbeddedIdParser(new PropertyParsingContext(context, userField));

        exception.expect(AchillesBeanMappingException.class);
        exception.expectMessage(format("There should be at least 2 fields annotated with @Order for the @EmbeddedId class '%s'",EmbeddedKeyWithOnlyOneComponent.class.getCanonicalName()));
        parser.parseEmbeddedId(EmbeddedKeyWithOnlyOneComponent.class, propertyParser);
    }
View Full Code Here

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

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

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

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

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

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


        exception.expect(AchillesBeanMappingException.class);
        exception.expectMessage(format("The composite partition key ordering is wrong for @EmbeddedId class '%s'",EmbeddedKeyWithInconsistentCompoundPartitionKey.class.getCanonicalName()));
        parser.parseEmbeddedId(EmbeddedKeyWithInconsistentCompoundPartitionKey.class, propertyParser);
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.