mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2530: fix missing supporting fields for ReverseConversion
This commit is contained in:
parent
e6e9b6ce92
commit
196528e578
@ -9,6 +9,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.mapstruct.ap.internal.model.common.Assignment;
|
||||
import org.mapstruct.ap.internal.model.common.ConversionContext;
|
||||
import org.mapstruct.ap.internal.model.common.FieldReference;
|
||||
import org.mapstruct.ap.internal.model.HelperMethod;
|
||||
|
||||
/**
|
||||
@ -44,4 +45,8 @@ public class ReverseConversion implements ConversionProvider {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FieldReference> getRequiredHelperFields(ConversionContext conversionContext) {
|
||||
return conversionProvider.getRequiredHelperFields( conversionContext );
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._2530;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@Mapper
|
||||
public interface Issue2530Mapper {
|
||||
|
||||
Issue2530Mapper INSTANCE = Mappers.getMapper( Issue2530Mapper.class );
|
||||
|
||||
@Mapping(target = "date", source = ".", dateFormat = "yyyy-MM-dd")
|
||||
Test map(String s);
|
||||
|
||||
class Test {
|
||||
|
||||
LocalDate date;
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate dateTime) {
|
||||
this.date = dateTime;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._2530;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.time.Month;
|
||||
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@IssueKey("2530")
|
||||
@WithClasses({
|
||||
Issue2530Mapper.class
|
||||
})
|
||||
public class Issue2530Test {
|
||||
|
||||
@ProcessorTest
|
||||
public void shouldConvert() {
|
||||
Issue2530Mapper.Test target = Issue2530Mapper.INSTANCE.map( "2021-07-31" );
|
||||
|
||||
assertThat( target ).isNotNull();
|
||||
assertThat( target.getDate().getYear() ).isEqualTo( 2021 );
|
||||
assertThat( target.getDate().getMonth() ).isEqualTo( Month.JULY );
|
||||
assertThat( target.getDate().getDayOfMonth() ).isEqualTo( 31 );
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user