Skip to content

Commit

Permalink
Merge branch '1.1-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
agudian committed Jan 5, 2017
2 parents a2bd4a0 + ec69136 commit 22b28f5
Show file tree
Hide file tree
Showing 26 changed files with 2,555 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
<#elseif wildCardSuperBound>
? super <@includeModel object=typeBound />
<#else>
<#if imported>
${name}
<#else>
${fullyQualifiedName}
</#if>
</#if>
<#if (!ext.raw?? && typeParameters?size > 0) >
<<#list typeParameters as typeParameter><@includeModel object=typeParameter /><#if typeParameter_has_next>, </#if></#list>>
<#if imported>${name}<#else>${fullyQualifiedName}</#if></#if><#if (!ext.raw?? && typeParameters?size > 0) ><<#list typeParameters as typeParameter><@includeModel object=typeParameter /><#if typeParameter_has_next>, </#if></#list>>
</#if>
</@compress>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.mapstruct.ap.test.array;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.Arrays;
import java.util.List;

Expand All @@ -31,19 +33,14 @@
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import org.mapstruct.ap.testutil.runner.GeneratedSource;

import static org.assertj.core.api.Assertions.assertThat;

@WithClasses( { Scientist.class, ScientistDto.class, ScienceMapper.class } )
@RunWith(AnnotationProcessorTestRunner.class)
@IssueKey("108")
public class ArrayMappingTest {

private final GeneratedSource generatedSource = new GeneratedSource();

@Rule
public GeneratedSource getGeneratedSource() {
return generatedSource;
}
public final GeneratedSource generatedSource = new GeneratedSource()
.addComparisonToFixtureFor( ScienceMapper.class );

@Test
public void shouldCopyArraysInBean() {
Expand Down Expand Up @@ -238,6 +235,6 @@ public void shouldVoidMapintWhenReturnDefault() {
@Test
@IssueKey( "999" )
public void shouldNotContainFQNForStringArray() {
getGeneratedSource().forMapper( ScienceMapper.class ).content().doesNotContain( "java.lang.String[]" );
generatedSource.forMapper( ScienceMapper.class ).content().doesNotContain( "java.lang.String[]" );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import java.util.HashSet;
import java.util.Set;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import org.mapstruct.ap.testutil.runner.GeneratedSource;

/**
* All these test cases test the possible combinations in the SetterMapperForCollections.
Expand All @@ -49,6 +51,14 @@
@IssueKey( "913" )
public class Issue913SetterMapperForCollectionsTest {

@Rule
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
DomainDtoWithNvmsNullMapper.class,
DomainDtoWithNvmsDefaultMapper.class,
DomainDtoWithPresenceCheckMapper.class,
DomainDtoWithNcvsAlwaysMapper.class
);

/**
* The null value mapping strategy on type level (Mapper) should generate forged methods for the
* conversion from string to long that return null in the entire mapper, so also for the forged
Expand Down Expand Up @@ -325,8 +335,6 @@ public void shouldReturnNullForUpdateWithReturnWithNcvsAlways() {

/**
* These assert check if non-null and default mapping is working as expected.
*
* @param domain
*/
private void doControlAsserts( Domain domain ) {
assertThat( domain.getStringsInitialized() ).containsOnly( "5" );
Expand All @@ -336,8 +344,6 @@ private void doControlAsserts( Domain domain ) {

/**
* These assert check if non-null and default mapping is working as expected.
*
* @param domain
*/
private void doControlAsserts( Domain domain1, Domain domain2) {
assertThat( domain1 ).isEqualTo( domain2 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Arrays;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mapstruct.ap.test.collection.adder._target.AdderUsageObserver;
Expand All @@ -46,6 +47,7 @@
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import org.mapstruct.ap.testutil.runner.GeneratedSource;

/**
* @author Sjaak Derksen
Expand All @@ -70,11 +72,22 @@
IndoorPet.class,
OutdoorPet.class,
DogException.class,
CatException.class
CatException.class,
Target2.class,
Source2.class,
Source2Target2Mapper.class,
Foo.class
})
@RunWith(AnnotationProcessorTestRunner.class)
public class AdderTest {

@Rule
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
SourceTargetMapper.class,
SourceTargetMapperStrategyDefault.class,
SourceTargetMapperStrategySetterPreferred.class
);

@IssueKey("241")
@Test
public void testAdd() throws DogException {
Expand Down Expand Up @@ -245,13 +258,8 @@ public void testSingleElementSource() throws DogException {

@IssueKey( "310" )
@Test
@WithClasses( {
Target2.class,
Source2.class,
Source2Target2Mapper.class,
Foo.class
} )
public void testMissingImport() throws DogException {
generatedSource.addComparisonToFixtureFor( Source2Target2Mapper.class );

Source2 source = new Source2();
source.setAttributes( Arrays.asList( new Foo() ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
*/
package org.mapstruct.ap.test.conversion.string;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import org.mapstruct.ap.testutil.runner.GeneratedSource;

import static org.assertj.core.api.Assertions.assertThat;

@WithClasses({
Source.class,
Expand All @@ -36,6 +38,10 @@ public class StringConversionTest {

private static final String STRING_CONSTANT = "String constant";

@Rule
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
SourceTargetMapper.class );

@Test
public void shouldApplyStringConversions() {
Source source = new Source();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
package org.mapstruct.ap.test.updatemethods;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mapstruct.ap.testutil.IssueKey;
Expand All @@ -28,6 +27,9 @@
import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic;
import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import org.mapstruct.ap.testutil.runner.GeneratedSource;

import static org.assertj.core.api.Assertions.assertThat;

/**
*
Expand All @@ -52,11 +54,15 @@
})
public class UpdateMethodsTest {

@Rule
public final GeneratedSource generatedSource = new GeneratedSource();

@Test
@WithClasses( {
OrganizationMapper.class
} )
public void testPreferUpdateMethod() {
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );

OrganizationEntity organizationEntity = new OrganizationEntity();
CompanyEntity companyEntity = new CompanyEntity();
Expand Down Expand Up @@ -85,6 +91,7 @@ public void testPreferUpdateMethod() {
OrganizationMapper.class
} )
public void testUpdateMethodClearsExistingValues() {
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );

OrganizationEntity organizationEntity = new OrganizationEntity();
CompanyEntity companyEntity = new CompanyEntity();
Expand All @@ -109,6 +116,7 @@ public void testUpdateMethodClearsExistingValues() {
OrganizationMapper.class
})
public void testPreferUpdateMethodSourceObjectNotDefined() {
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );

OrganizationEntity organizationEntity = new OrganizationEntity();

Expand All @@ -134,6 +142,7 @@ public void testPreferUpdateMethodSourceObjectNotDefined() {
DepartmentInBetween.class
} )
public void testPreferUpdateMethodEncapsulatingCreateMethod() {
generatedSource.addComparisonToFixtureFor( CompanyMapper.class );

CompanyEntity companyEntity = new CompanyEntity();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
*/
package org.mapstruct.ap.test.updatemethods.selection;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mapstruct.ap.test.updatemethods.BossDto;
Expand All @@ -41,6 +40,9 @@
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import org.mapstruct.ap.testutil.runner.GeneratedSource;

import static org.assertj.core.api.Assertions.assertThat;

/**
*
Expand Down Expand Up @@ -68,11 +70,19 @@
})
public class ExternalSelectionTest {

@Rule
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
OrganizationMapper1.class,
ExternalMapper.class,
DepartmentMapper.class
);

@Test
@WithClasses({
OrganizationMapper1.class
})
public void shouldSelectGeneratedExternalMapper() {
generatedSource.addComparisonToFixtureFor( OrganizationMapper1.class );

CompanyEntity entity = new CompanyEntity();
CompanyDto dto = new CompanyDto();
Expand All @@ -85,6 +95,7 @@ public void shouldSelectGeneratedExternalMapper() {
})
@IssueKey("604")
public void shouldSelectGeneratedExternalMapperWithImportForPropertyType() {
generatedSource.addComparisonToFixtureFor( OrganizationMapper3.class );

BossEntity entity = new BossEntity();
BossDto dto = new BossDto();
Expand All @@ -96,6 +107,7 @@ public void shouldSelectGeneratedExternalMapperWithImportForPropertyType() {
OrganizationMapper2.class
})
public void shouldSelectGeneratedHandWrittenExternalMapper() {
generatedSource.addComparisonToFixtureFor( OrganizationMapper2.class );

CompanyEntity entity = new CompanyEntity();
CompanyDto dto = new CompanyDto();
Expand Down
Loading

0 comments on commit 22b28f5

Please sign in to comment.