Skip to content

Commit

Permalink
mapstruct#1057 Add source fixtures for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphr committed Feb 19, 2017
1 parent 8653712 commit 2c59496
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ public class AutomappingAndNestedTest {

@Rule
public GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
FishTankMapperConstant.class
FishTankMapper.class,
FishTankMapperConstant.class,
FishTankMapperExpression.class,
FishTankMapperWithDocument.class
);

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
import javax.annotation.Generated;
import org.mapstruct.ap.test.nestedbeans.mixed._target.FishDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.FishTankDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.MaterialDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.MaterialTypeDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.WaterPlantDto;
import org.mapstruct.ap.test.nestedbeans.mixed.source.Fish;
import org.mapstruct.ap.test.nestedbeans.mixed.source.FishTank;
import org.mapstruct.ap.test.nestedbeans.mixed.source.MaterialType;
import org.mapstruct.ap.test.nestedbeans.mixed.source.WaterPlant;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2017-02-13T00:35:18+0100",
date = "2017-02-19T16:25:03+0100",
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
)
public class FishTankMapperConstantImpl implements FishTankMapperConstant {
Expand All @@ -41,13 +44,40 @@ public FishTankDto map(FishTank source) {

FishTankDto fishTankDto = new FishTankDto();

fishTankDto.setMaterial( fishTankToMaterialDto( source ) );
fishTankDto.setFish( fishToFishDto( source.getFish() ) );
fishTankDto.setPlant( waterPlantToWaterPlantDto( source.getPlant() ) );
fishTankDto.setName( source.getName() );

return fishTankDto;
}

protected MaterialTypeDto materialTypeToMaterialTypeDto(MaterialType materialType) {
if ( materialType == null ) {
return null;
}

MaterialTypeDto materialTypeDto = new MaterialTypeDto();

materialTypeDto.setType( materialType.getType() );

return materialTypeDto;
}

protected MaterialDto fishTankToMaterialDto(FishTank fishTank) {
if ( fishTank == null ) {
return null;
}

MaterialDto materialDto = new MaterialDto();

materialDto.setMaterialType( materialTypeToMaterialTypeDto( fishTank.getMaterial() ) );

materialDto.setManufacturer( "MMM" );

return materialDto;
}

protected FishDto fishToFishDto(Fish fish) {
if ( fish == null ) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.mixed;

import javax.annotation.Generated;
import org.mapstruct.ap.test.nestedbeans.mixed._target.FishDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.FishTankDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.WaterQualityDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.WaterQualityOrganisationDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.WaterQualityReportDto;
import org.mapstruct.ap.test.nestedbeans.mixed.source.Fish;
import org.mapstruct.ap.test.nestedbeans.mixed.source.FishTank;
import org.mapstruct.ap.test.nestedbeans.mixed.source.WaterQuality;
import org.mapstruct.ap.test.nestedbeans.mixed.source.WaterQualityReport;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2017-02-19T16:25:03+0100",
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
)
public class FishTankMapperExpressionImpl implements FishTankMapperExpression {

@Override
public FishTankDto map(FishTank source) {
if ( source == null ) {
return null;
}

FishTankDto fishTankDto = new FishTankDto();

fishTankDto.setFish( fishToFishDto( source.getFish() ) );
fishTankDto.setName( source.getName() );
fishTankDto.setQuality( waterQualityToWaterQualityDto( source.getQuality() ) );

return fishTankDto;
}

protected FishDto fishToFishDto(Fish fish) {
if ( fish == null ) {
return null;
}

FishDto fishDto = new FishDto();

fishDto.setKind( fish.getType() );

fishDto.setName( "Jaws" );

return fishDto;
}

protected WaterQualityOrganisationDto waterQualityReportToWaterQualityOrganisationDto(WaterQualityReport waterQualityReport) {
if ( waterQualityReport == null ) {
return null;
}

WaterQualityOrganisationDto waterQualityOrganisationDto = new WaterQualityOrganisationDto();

waterQualityOrganisationDto.setName( "Dunno" );

return waterQualityOrganisationDto;
}

protected WaterQualityReportDto waterQualityReportToWaterQualityReportDto(WaterQualityReport waterQualityReport) {
if ( waterQualityReport == null ) {
return null;
}

WaterQualityReportDto waterQualityReportDto = new WaterQualityReportDto();

waterQualityReportDto.setVerdict( waterQualityReport.getVerdict() );
waterQualityReportDto.setOrganisation( waterQualityReportToWaterQualityOrganisationDto( waterQualityReport ) );

return waterQualityReportDto;
}

protected WaterQualityDto waterQualityToWaterQualityDto(WaterQuality waterQuality) {
if ( waterQuality == null ) {
return null;
}

WaterQualityDto waterQualityDto = new WaterQualityDto();

waterQualityDto.setReport( waterQualityReportToWaterQualityReportDto( waterQuality.getReport() ) );

return waterQualityDto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2017-02-12T21:48:04+0100",
comments = "version: , compiler: javac, environment: Java 1.8.0_45 (Oracle Corporation)"
date = "2017-02-19T16:25:02+0100",
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
)
public class FishTankMapperImpl implements FishTankMapper {

Expand Down Expand Up @@ -76,7 +76,7 @@ public FishTankDto mapAsWell(FishTank source) {
fishTankDto.setMaterial( fishTankToMaterialDto( source ) );
fishTankDto.setFish( fishToFishDto( source.getFish() ) );
fishTankDto.setQuality( waterQualityToWaterQualityDto( source.getQuality() ) );
Ornament ornament = sourceInteriorOrnament1( source );
Ornament ornament = sourceInteriorOrnament( source );
if ( ornament != null ) {
fishTankDto.setOrnament( ornamentToOrnamentDto( ornament ) );
}
Expand Down Expand Up @@ -181,7 +181,6 @@ protected WaterQualityDto waterQualityToWaterQualityDto(WaterQuality waterQualit
}

private Ornament sourceInteriorOrnament(FishTank fishTank) {

if ( fishTank == null ) {
return null;
}
Expand Down Expand Up @@ -220,22 +219,6 @@ protected WaterPlantDto waterPlantToWaterPlantDto(WaterPlant waterPlant) {
return waterPlantDto;
}

private Ornament sourceInteriorOrnament1(FishTank fishTank) {

if ( fishTank == null ) {
return null;
}
Interior interior = fishTank.getInterior();
if ( interior == null ) {
return null;
}
Ornament ornament = interior.getOrnament();
if ( ornament == null ) {
return null;
}
return ornament;
}

protected Fish fishDtoToFish(FishDto fishDto) {
if ( fishDto == null ) {
return null;
Expand All @@ -249,7 +232,6 @@ protected Fish fishDtoToFish(FishDto fishDto) {
}

private String waterQualityReportDtoOrganisationName(WaterQualityReportDto waterQualityReportDto) {

if ( waterQualityReportDto == null ) {
return null;
}
Expand Down Expand Up @@ -317,7 +299,6 @@ protected Interior fishTankDtoToInterior(FishTankDto fishTankDto) {
}

private MaterialTypeDto sourceMaterialMaterialType(FishTankDto fishTankDto) {

if ( fishTankDto == null ) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.mixed;

import javax.annotation.Generated;
import org.mapstruct.ap.test.nestedbeans.mixed._target.FishDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.FishTankWithNestedDocumentDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.WaterQualityOrganisationDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.WaterQualityReportDto;
import org.mapstruct.ap.test.nestedbeans.mixed._target.WaterQualityWithDocumentDto;
import org.mapstruct.ap.test.nestedbeans.mixed.source.Fish;
import org.mapstruct.ap.test.nestedbeans.mixed.source.FishTank;
import org.mapstruct.ap.test.nestedbeans.mixed.source.WaterQuality;
import org.mapstruct.ap.test.nestedbeans.mixed.source.WaterQualityReport;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2017-02-19T16:25:03+0100",
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
)
public class FishTankMapperWithDocumentImpl implements FishTankMapperWithDocument {

@Override
public FishTankWithNestedDocumentDto map(FishTank source) {
if ( source == null ) {
return null;
}

FishTankWithNestedDocumentDto fishTankWithNestedDocumentDto = new FishTankWithNestedDocumentDto();

fishTankWithNestedDocumentDto.setFish( fishToFishDto( source.getFish() ) );
fishTankWithNestedDocumentDto.setQuality( waterQualityToWaterQualityWithDocumentDto( source.getQuality() ) );
fishTankWithNestedDocumentDto.setName( source.getName() );

return fishTankWithNestedDocumentDto;
}

protected FishDto fishToFishDto(Fish fish) {
if ( fish == null ) {
return null;
}

FishDto fishDto = new FishDto();

fishDto.setKind( fish.getType() );

fishDto.setName( "Jaws" );

return fishDto;
}

protected WaterQualityOrganisationDto waterQualityReportToWaterQualityOrganisationDto(WaterQualityReport waterQualityReport) {
if ( waterQualityReport == null ) {
return null;
}

WaterQualityOrganisationDto waterQualityOrganisationDto = new WaterQualityOrganisationDto();

waterQualityOrganisationDto.setName( "NoIdeaInc" );

return waterQualityOrganisationDto;
}

protected WaterQualityReportDto waterQualityReportToWaterQualityReportDto(WaterQualityReport waterQualityReport) {
if ( waterQualityReport == null ) {
return null;
}

WaterQualityReportDto waterQualityReportDto = new WaterQualityReportDto();

waterQualityReportDto.setVerdict( waterQualityReport.getVerdict() );
waterQualityReportDto.setOrganisation( waterQualityReportToWaterQualityOrganisationDto( waterQualityReport ) );

return waterQualityReportDto;
}

protected WaterQualityWithDocumentDto waterQualityToWaterQualityWithDocumentDto(WaterQuality waterQuality) {
if ( waterQuality == null ) {
return null;
}

WaterQualityWithDocumentDto waterQualityWithDocumentDto = new WaterQualityWithDocumentDto();

waterQualityWithDocumentDto.setDocument( waterQualityReportToWaterQualityReportDto( waterQuality.getReport() ) );

return waterQualityWithDocumentDto;
}
}

0 comments on commit 2c59496

Please sign in to comment.