Package org.mapstruct.ap.test.complex.source

Examples of org.mapstruct.ap.test.complex.source.Car


    }

    @Test
    public void shouldMapAttributeByName() {
        //given
        Car car = new Car(
            "Morris",
            2,
            new GregorianCalendar( 1980, 0, 1 ).getTime(),
            new Person( "Bob" ),
            new ArrayList<Person>()
        );

        //when
        CarDto carDto = CarMapper.INSTANCE.carToCarDto( car );

        //then
        assertThat( carDto ).isNotNull();
        assertThat( carDto.getMake() ).isEqualTo( car.getMake() );
    }
View Full Code Here


    }

    @Test
    public void shouldMapReferenceAttribute() {
        //given
        Car car = new Car(
            "Morris",
            2,
            new GregorianCalendar( 1980, 0, 1 ).getTime(),
            new Person( "Bob" ),
            new ArrayList<Person>()
View Full Code Here

    public void shouldReverseMapReferenceAttribute() {
        //given
        CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<PersonDto>() );

        //when
        Car car = CarMapper.INSTANCE.carDtoToCar( carDto );

        //then
        assertThat( car ).isNotNull();
        assertThat( car.getDriver() ).isNotNull();
        assertThat( car.getDriver().getName() ).isEqualTo( "Bob" );
    }
View Full Code Here

    }

    @Test
    public void shouldMapAttributeWithCustomMapping() {
        //given
        Car car = new Car(
            "Morris",
            2,
            new GregorianCalendar( 1980, 0, 1 ).getTime(),
            new Person( "Bob" ),
            new ArrayList<Person>()
        );

        //when
        CarDto carDto = CarMapper.INSTANCE.carToCarDto( car );

        //then
        assertThat( carDto ).isNotNull();
        assertThat( carDto.getSeatCount() ).isEqualTo( car.getNumberOfSeats() );
    }
View Full Code Here

    public void shouldConsiderCustomMappingForReverseMapping() {
        //given
        CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<PersonDto>() );

        //when
        Car car = CarMapper.INSTANCE.carDtoToCar( carDto );

        //then
        assertThat( car ).isNotNull();
        assertThat( car.getNumberOfSeats() ).isEqualTo( carDto.getSeatCount() );
    }
View Full Code Here

    }

    @Test
    public void shouldApplyConverter() {
        //given
        Car car = new Car(
            "Morris",
            2,
            new GregorianCalendar( 1980, 0, 1 ).getTime(),
            new Person( "Bob" ),
            new ArrayList<Person>()
View Full Code Here

    public void shouldApplyConverterForReverseMapping() {
        //given
        CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<PersonDto>() );

        //when
        Car car = CarMapper.INSTANCE.carDtoToCar( carDto );

        //then
        assertThat( car ).isNotNull();
        assertThat( car.getManufacturingDate() ).isEqualTo( new GregorianCalendar( 1980, 0, 1 ).getTime() );
    }
View Full Code Here

    }

    @Test
    public void shouldMapIterable() {
        //given
        Car car1 = new Car(
            "Morris",
            2,
            new GregorianCalendar( 1980, 0, 1 ).getTime(),
            new Person( "Bob" ),
            new ArrayList<Person>()
        );
        Car car2 = new Car(
            "Railton",
            4,
            new GregorianCalendar( 1934, 0, 1 ).getTime(),
            new Person( "Bill" ),
            new ArrayList<Person>()
View Full Code Here

    }

    @Test
    public void shouldMapIterableAttribute() {
        //given
        Car car = new Car(
            "Morris",
            2,
            new GregorianCalendar( 1980, 0, 1 ).getTime(),
            new Person( "Bob" ),
            new ArrayList<Person>( Arrays.asList( new Person( "Alice" ), new Person( "Bill" ) ) )
View Full Code Here

            new PersonDto( "Bob" ),
            new ArrayList<PersonDto>( Arrays.asList( new PersonDto( "Alice" ), new PersonDto( "Bill" ) ) )
        );

        //when
        Car car = CarMapper.INSTANCE.carDtoToCar( carDto );

        //then
        assertThat( car ).isNotNull();

        assertThat( car.getPassengers() ).hasSize( 2 );
        assertThat( car.getPassengers().get( 0 ).getName() ).isEqualTo( "Alice" );
        assertThat( car.getPassengers().get( 1 ).getName() ).isEqualTo( "Bill" );
    }
View Full Code Here

TOP

Related Classes of org.mapstruct.ap.test.complex.source.Car

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.