Skip to content

Commit

Permalink
[MNG-7138] Proper verify of plugin configuration Bean set method call
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Sep 2, 2022
1 parent 2f415ee commit 1acf188
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void testitMNG3827()

assertEquals( "field", props.getProperty( "beanParam.fieldParam" ) );
assertEquals( "setter", props.getProperty( "beanParam.setterParam" ) );
assertEquals( "false", props.getProperty( "beanParam.setCalled" ) );
assertEquals( "true", props.getProperty( "beanParam.setterCalled" ) );

assertEquals( "4", props.getProperty( "domParam.children" ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void testitMNG3864()

assertEquals( "field", props.getProperty( "beanParam.fieldParam" ) );
assertEquals( "setter", props.getProperty( "beanParam.setterParam" ) );
assertEquals( "false", props.getProperty( "beanParam.setCalled" ) );
assertEquals( "true", props.getProperty( "beanParam.setterCalled" ) );

assertEquals( "4", props.getProperty( "domParam.children" ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public void testit()

Properties props = verifier.loadProperties( "target/config.properties" );
assertEquals( "PASSED", props.getProperty( "beanParam.fieldParam" ) );
assertEquals( "true", props.getProperty( "beanParam.setterCalled" ) );
assertEquals( "true", props.getProperty( "beanParam.setCalled" ) );
assertEquals( "false", props.getProperty( "beanParam.setterCalled" ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@ public class Bean

String setterParam;

/**
* default method of bean was called
*/
boolean setCalled;

/**
* setter method of ben was called
*/
boolean setterCalled;

public void set( String value )
{
fieldParam = value;
setterCalled = true;
setCalled = true;
}

public void setSetterParam( String value )
Expand All @@ -49,7 +57,7 @@ public void setSetterParam( String value )
public String toString()
{
return getClass().getName() + "[fieldParam=" + fieldParam + ", setterParam=" + setterParam
+ ", setterCalled=" + setterCalled + "]";
+ ", setterCalled=" + setterCalled + ", setCalled=" + setCalled + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public class ConfigMojo
*
* @parameter
*/

private Bean beanParam;

/**
Expand Down Expand Up @@ -335,6 +336,7 @@ private void dumpConfiguration( Properties props )
{
PropertiesUtil.serialize( props, "beanParam.fieldParam", beanParam.fieldParam );
PropertiesUtil.serialize( props, "beanParam.setterParam", beanParam.setterParam );
PropertiesUtil.serialize( props, "beanParam.setCalled", beanParam.setCalled );
PropertiesUtil.serialize( props, "beanParam.setterCalled", beanParam.setterCalled );
}
}
Expand Down

0 comments on commit 1acf188

Please sign in to comment.