File tree Expand file tree Collapse file tree
plugin/src/test/java/io/jenkins/plugins/casc Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66import static org .junit .Assert .assertTrue ;
77
88import io .jenkins .plugins .casc .model .Mapping ;
9+ import java .lang .reflect .Method ;
910import java .util .Arrays ;
1011import java .util .List ;
1112import java .util .Map ;
@@ -376,4 +377,21 @@ public void testFindGetterReturnsNullForMissingOrInvalidGetters() {
376377
377378 assertTrue ("Properties without valid getters should yield no attributes" , attributes .isEmpty ());
378379 }
380+
381+ @ Test
382+ public void testResolveBestSetterBranchCoverage () throws Exception {
383+ DummyConfigurator configurator = new DummyConfigurator ();
384+
385+ Method resolveMethod = BaseConfigurator .class .getDeclaredMethod ("resolveBestSetter" , List .class , Class .class );
386+ resolveMethod .setAccessible (true );
387+
388+ Method setObj = DummyTarget .class .getMethod ("setPet" , Object .class );
389+ Method setAnimal = DummyTarget .class .getMethod ("setPet" , Animal .class );
390+
391+ List <Method > orderedMethods = Arrays .asList (setObj , setAnimal );
392+
393+ Method best = (Method ) resolveMethod .invoke (configurator , orderedMethods , null );
394+
395+ assertEquals ("Should upgrade bestType and resolve to the more specific Animal setter" , setAnimal , best );
396+ }
379397}
You can’t perform that action at this time.
0 commit comments