Skip to content

Instantly share code, notes, and snippets.

@alexanderfloh
Created January 29, 2016 07:45
Show Gist options
  • Save alexanderfloh/0920df44f6cf95704aa7 to your computer and use it in GitHub Desktop.
Save alexanderfloh/0920df44f6cf95704aa7 to your computer and use it in GitHub Desktop.
lombok extension methods
import com.borland.silktest.jtf.Desktop;
import org.junit.Before;
import com.borland.silktest.jtf.AbstractTestObject;
import com.borland.silktest.jtf.BaseState;
import org.junit.Test;
import com.borland.silktest.jtf.Window;
import com.borland.silktest.jtf.TextField;
import com.borland.silktest.jtf.common.types.TextPosition;
import lombok.experimental.ExtensionMethod;
import com.borland.silktest.jtf.MenuItem;
import com.borland.silktest.jtf.PushButton;
@ExtensionMethod(Extensions.class)
public class MyTest {
private Desktop desktop = new Desktop();
@Before
public void baseState() {
BaseState baseState = new BaseState();
baseState.execute(desktop);
}
/**
* Test case show casing extension methods from https://projectlombok.org
*/
@Test
public void someTest() {
desktop.Window("Untitled - Notepad").setActive();
desktop.TextField("Untitled - Notepad.TextField").setPosition(new TextPosition(0, 0));
desktop.TextField("Untitled - Notepad.TextField").typeKeys("asdf");
desktop.MenuItem("Untitled - Notepad.About Notepad").select();
desktop.PushButton("Untitled - Notepad.About Notepad Dialog.OK").select();
}
}
class Extensions {
public static <T extends AbstractTestObject> Window Window(T obj, String locator) {
return obj.<Window>find(locator);
}
public static <T extends AbstractTestObject> TextField TextField(T obj, String locator) {
return obj.<TextField>find(locator);
}
public static <T extends AbstractTestObject> MenuItem MenuItem(T obj, String locator) {
return obj.<MenuItem>find(locator);
}
public static <T extends AbstractTestObject> PushButton PushButton(T obj, String locator) {
return obj.<PushButton>find(locator);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment