Created
August 11, 2012 05:22
-
-
Save eiswind/3321417 to your computer and use it in GitHub Desktop.
Hack to render contribution ids in for RAP UI Tests (Snippet from Widget.java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void setData( Object data ) { | |
checkWidget(); | |
if( ( state & KEYED_DATA ) != 0 ) { | |
( ( Object[] )this.data )[ 0 ] = data; | |
} else { | |
this.data = data; | |
} | |
if( UITestUtil.isEnabled() && data != null ) { | |
Class<? extends Object> clazz = data.getClass(); | |
while( clazz != Object.class ) { | |
for( Class<?> type : clazz.getInterfaces() ) { | |
if( type.getSimpleName().equals( "IContributionItem" ) ) { | |
try { | |
Method getter = clazz.getMethod( "getId", new Class<?>[]{} ); | |
String id = ( String )getter.invoke( data, new Object[]{} ); | |
handleCustomId( WidgetUtil.CUSTOM_WIDGET_ID, id ); | |
} catch( Exception e ) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
clazz = clazz.getSuperclass(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment