Package org.mapstruct.ap.test.collection.adder.source

Examples of org.mapstruct.ap.test.collection.adder.source.Source


    @IssueKey("241")
    @Test
    public void testAdd() throws DogException {
        AdderUsageObserver.setUsed( false );

        Source source = new Source();
        source.setPets( Arrays.asList( "mouse" ) );

        Target target = SourceTargetMapper.INSTANCE.toTarget( source );
        assertThat( target ).isNotNull();
        assertThat( target.getPets().size() ).isEqualTo( 1 );
        assertThat( target.getPets().get( 0 ) ).isEqualTo( 2L );
View Full Code Here


    @Test(expected = DogException.class)
    public void testAddWithExceptionInThrowsClause() throws DogException {
        AdderUsageObserver.setUsed( false );

        Source source = new Source();
        source.setPets( Arrays.asList( "dog" ) );

        SourceTargetMapper.INSTANCE.toTarget( source );
    }
View Full Code Here

    @Test(expected = RuntimeException.class)
    public void testAddWithExceptionNotInThrowsClause() throws DogException {
        AdderUsageObserver.setUsed( false );

        Source source = new Source();
        source.setPets( Arrays.asList( "cat" ) );

        SourceTargetMapper.INSTANCE.toTarget( source );
    }
View Full Code Here

    @IssueKey("241")
    @Test
    public void testAddwithExistingTarget() throws DogException {
        AdderUsageObserver.setUsed( false );

        Source source = new Source();
        source.setPets( Arrays.asList( "mouse" ) );

        Target target = new Target();
        target.setPets( new ArrayList<Long>( Arrays.asList( 1L ) ) );

        SourceTargetMapper.INSTANCE.toExistingTarget( source, target );
View Full Code Here

    @Test
    public void testShouldUseDefaultStrategy() throws DogException {
        AdderUsageObserver.setUsed( false );

        Source source = new Source();
        source.setPets( Arrays.asList( "mouse" ) );

        Target target = SourceTargetMapperStrategyDefault.INSTANCE.shouldFallBackToAdder( source );
        assertThat( target ).isNotNull();
        assertThat( target.getPets().size() ).isEqualTo( 1 );
        assertThat( target.getPets().get( 0 ) ).isEqualTo( 2L );
View Full Code Here

    @Test
    public void testShouldPreferSetterStrategyButThereIsNone() throws DogException {
        AdderUsageObserver.setUsed( false );

        Source source = new Source();
        source.setPets( Arrays.asList( "mouse" ) );

        TargetWithoutSetter target = SourceTargetMapperStrategySetterPreferred.INSTANCE.toTargetDontUseAdder( source );
        assertThat( target ).isNotNull();
        assertThat( target.getPets().size() ).isEqualTo( 1 );
        assertThat( target.getPets().get( 0 ) ).isEqualTo( 2L );
View Full Code Here

        AdderUsageObserver.setUsed( false );

        Target source = new Target();
        source.setPets( Arrays.asList( 3L ) );

        Source target = SourceTargetMapper.INSTANCE.toSource( source );
        assertThat( target ).isNotNull();
        assertThat( target.getPets().size() ).isEqualTo( 1 );
        assertThat( target.getPets().get( 0 ) ).isEqualTo( "cat" );
    }
View Full Code Here

    @Test
    public void testAddOnlyGetter() throws DogException {
        AdderUsageObserver.setUsed( false );

        Source source = new Source();
        source.setPets( Arrays.asList( "mouse" ) );

        TargetOnlyGetter target = SourceTargetMapper.INSTANCE.toTargetOnlyGetter( source );
        assertThat( target ).isNotNull();
        assertThat( target.getPets().size() ).isEqualTo( 1 );
        assertThat( target.getPets().get( 0 ) ).isEqualTo( 2L );
View Full Code Here

    @Test
    public void testAddViaTargetType() throws DogException {
        AdderUsageObserver.setUsed( false );

        Source source = new Source();
        source.setPets( Arrays.asList( "mouse" ) );

        TargetViaTargetType target = SourceTargetMapper.INSTANCE.toTargetViaTargetType( source );
        assertThat( target ).isNotNull();
        assertThat( target.getPets().size() ).isEqualTo( 1 );
        assertThat( target.getPets().get( 0 ) ).isNotNull();
View Full Code Here

TOP

Related Classes of org.mapstruct.ap.test.collection.adder.source.Source

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.