Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support java expressions in Mapping#conditionExpression #154

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public class JavaExpressionInjector implements MultiHostInjector {
private static final ElementPattern<PsiElement> PATTERN =
StandardPatterns.or(
MapstructElementUtils.mappingElementPattern( "expression" ),
MapstructElementUtils.mappingElementPattern( "defaultExpression" )
MapstructElementUtils.mappingElementPattern( "defaultExpression" ),
MapstructElementUtils.mappingElementPattern( "conditionExpression" )
);

private void importIfNecessary(PsiClass cls, @NotNull Set<String> imports) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ protected void setUp() throws Exception {
public void testExpressionWithNoTargetDefinedMapper() {
noTargetDefinedMapper( "expression" );
noTargetDefinedMapper( "defaultExpression" );
noTargetDefinedMapper( "conditionExpression" );
}

protected void noTargetDefinedMapper(String attribute) {
Expand All @@ -215,6 +216,7 @@ protected void noTargetDefinedMapper(String attribute) {
public void testExpressionWithoutJavaExpression() {
withoutJavaExpression( "expression" );
withoutJavaExpression( "defaultExpression" );
withoutJavaExpression( "conditionExpression" );
}

protected void withoutJavaExpression(String attribute) {
Expand All @@ -233,6 +235,7 @@ protected void withoutJavaExpression(String attribute) {
public void testExpressionWithTargetDefinedMapper() {
withTargetDefinedMapper( "expression" );
withTargetDefinedMapper( "defaultExpression" );
withTargetDefinedMapper( "conditionExpression" );
}

protected void withTargetDefinedMapper(String attribute) {
Expand Down Expand Up @@ -268,6 +271,7 @@ protected void withTargetDefinedMapper(String attribute) {
public void testExpressionWithTargetDefinedMapperInMappings() {
withTargetDefinedMapperInMappings( "expression" );
withTargetDefinedMapperInMappings( "defaultExpression" );
withTargetDefinedMapperInMappings( "conditionExpression" );
}

protected void withTargetDefinedMapperInMappings(String attribute) {
Expand Down Expand Up @@ -305,6 +309,7 @@ protected void withTargetDefinedMapperInMappings(String attribute) {
public void testExpressionWithMapperWithImports() {
withMapperWithImports( "expression" );
withMapperWithImports( "defaultExpression" );
withMapperWithImports( "conditionExpression" );
}

protected void withMapperWithImports(String attribute) {
Expand Down Expand Up @@ -333,6 +338,7 @@ protected void withMapperWithImports(String attribute) {
public void testExpressionWithMapperWithCustomImports() {
withMapperWithCustomImports( "expression" );
withMapperWithCustomImports( "defaultExpression" );
withMapperWithCustomImports( "conditionExpression" );
}

protected void withMapperWithCustomImports(String attribute) {
Expand Down Expand Up @@ -360,6 +366,7 @@ protected void withMapperWithCustomImports(String attribute) {
public void testExpressionWithMapperWithoutImports() {
withMapperWithoutImports( "expression" );
withMapperWithoutImports( "defaultExpression" );
withMapperWithoutImports( "conditionExpression" );
}

protected void withMapperWithoutImports(String attribute) {
Expand Down Expand Up @@ -387,6 +394,7 @@ protected void withMapperWithoutImports(String attribute) {
public void testExpressionWithMultiSourceParameters() {
withMultiSourceParameters( "expression" );
withMultiSourceParameters( "defaultExpression" );
withMultiSourceParameters( "conditionExpression" );
}

protected void withMultiSourceParameters(String attribute) {
Expand Down Expand Up @@ -414,6 +422,7 @@ protected void withMultiSourceParameters(String attribute) {
public void testExpressionWithGenericSourceParameters() {
withGenericSourceParameters( "expression" );
withGenericSourceParameters( "defaultExpression" );
withGenericSourceParameters( "conditionExpression" );
}

protected void withGenericSourceParameters(String attribute) {
Expand Down Expand Up @@ -442,6 +451,7 @@ protected void withGenericSourceParameters(String attribute) {
public void testExpressionWithSourceParameterWithAnnotations() {
withExpressionWithSourceParameterWithAnnotations( "expression" );
withExpressionWithSourceParameterWithAnnotations( "defaultExpression" );
withExpressionWithSourceParameterWithAnnotations( "conditionExpression" );
}

protected void withExpressionWithSourceParameterWithAnnotations(String attribute) {
Expand Down Expand Up @@ -471,6 +481,7 @@ protected void withExpressionWithSourceParameterWithAnnotations(String attribute
public void testExpressionWithSourceParameterWithMultipleGenerics() {
withExpressionWithSourceParameterWithMultipleGenerics( "expression" );
withExpressionWithSourceParameterWithMultipleGenerics( "defaultExpression" );
withExpressionWithSourceParameterWithMultipleGenerics( "conditionExpression" );
}

protected void withExpressionWithSourceParameterWithMultipleGenerics(String attribute) {
Expand Down Expand Up @@ -500,6 +511,7 @@ protected void withExpressionWithSourceParameterWithMultipleGenerics(String attr
public void testExpressionWithGenericMethod() {
withExpressionWithGenericMethod( "expression" );
withExpressionWithGenericMethod( "defaultExpression" );
withExpressionWithGenericMethod( "conditionExpression" );
}

protected void withExpressionWithGenericMethod(String attribute) {
Expand All @@ -526,6 +538,7 @@ protected void withExpressionWithGenericMethod(String attribute) {
public void testExpressionWithGenericMapper() {
withGenericMapper( "expression" );
withGenericMapper( "defaultExpression" );
withGenericMapper( "conditionExpression" );
}

protected void withGenericMapper(String attribute) {
Expand Down Expand Up @@ -553,6 +566,7 @@ protected void withGenericMapper(String attribute) {
public void testExpressionWithClassMapper() {
withClassMapper( "expression" );
withClassMapper( "defaultExpression" );
withClassMapper( "conditionExpression" );
}

protected void withClassMapper(String attribute) {
Expand Down Expand Up @@ -587,6 +601,7 @@ protected void withClassMapper(String attribute) {
public void testExpressionWithTargetUsingStaticString() {
withTargetUsingStaticString( "expression" );
withTargetUsingStaticString( "defaultExpression" );
withTargetUsingStaticString( "conditionExpression" );
}

protected void withTargetUsingStaticString(String attribute) {
Expand Down Expand Up @@ -622,6 +637,7 @@ protected void withTargetUsingStaticString(String attribute) {
public void testExpressionWithMapperToDtoWithoutAccessors() {
withMapperToDtoWithoutAccessors( "expression" );
withMapperToDtoWithoutAccessors( "defaultExpression" );
withMapperToDtoWithoutAccessors( "conditionExpression" );
}

protected void withMapperToDtoWithoutAccessors(String attribute) {
Expand Down
Loading