id
stringlengths
36
36
text
stringlengths
1
1.25M
9f9ed5f8-0cbc-42a1-9ef6-3480ac676b48
public MyDog() { // TODO Auto-generated constructor stub super("dog right.png","dog left.png", .35); }
8606f123-c6b8-45bd-aed9-4e60f973ad70
public MyMouse() { // TODO Auto-generated constructor stub super("mouse left.png", "mouse right.png", .15); }
67bce0ca-740a-485b-b424-06e03a6f58c3
public HealthItem(double width, double height) { super(width, height); // TODO Auto-generated constructor stub }
d0d63baa-a4fe-4df5-8e1e-cf736dc45791
public void testSearchContactAndText() throws RemoteException, UiObjectNotFoundException { UiDevice uiDevice = UiDevice.getInstance(); uiDevice.pressHome(); uiDevice.setOrientationNatural(); // KeyguardManager mKeyGuardManager = new Keyg(KeyguardManager) getSystemService(KEYGUARD_SERVI...
75df8faf-c74b-4dfc-a327-6c56a041d99a
private void searchContact() throws UiObjectNotFoundException { // to.talk:id/search_box UiObject searchUiObject = new UiObject(new UiSelector().resourceId("to.talk:id/menu_home_activity_search_contact")); searchUiObject.clickAndWaitForNewWindow(); UiObject searchEditTextUiObject = new Ui...
37eb6460-25dd-4de8-8f6b-7c31b50f176f
private void writeText() { UiObject writeMessageUiObject = new UiObject(new UiSelector().packageName("to.talk").className("android.widget.EditText").resourceId("to.talk:id/message_field")); UiObject contentSharingBtn = new UiObject(new UiSelector().resourceId("to.talk:id/content_sharing_btn")); ...
aec59f23-b0e8-4b4e-9b6b-dd538211a0b3
private void sendText() throws UiObjectNotFoundException { UiObject sendMessageButtonUiObject = new UiObject(new UiSelector().resourceId("to.talk:id/send")); sendMessageButtonUiObject.click(); }
0cce6d02-cd18-4187-8bea-326a477372fe
public void sendText1() { UiObject messageTextbox = new UiObject(new UiSelector().packageName("to.talk").resourceId("to.talk:id/message_field")); UiObject sendButton = new UiObject(new UiSelector().packageName("to.talk").resourceId("to.talk:id/send")); if (messageTextbox.waitForExists(5000)) ...
c6228e91-d136-4d67-b495-d862d357e76d
public void testAudio() throws UiObjectNotFoundException, RemoteException { UiDevice uiDevice = UiDevice.getInstance(); uiDevice.pressHome(); uiDevice.setOrientationNatural(); UiObject appUiObject = new UiObject(new UiSelector().descriptionContains("Apps")); appUiObject.clickAnd...
9285e624-6d6b-47f0-8089-a18e5f7b13e3
private void searchContact() throws UiObjectNotFoundException { UiObject searchUiObject = new UiObject(new UiSelector().resourceId("to.talk:id/menu_home_activity_search_contact")); searchUiObject.clickAndWaitForNewWindow(); UiObject searchEditTextUiObject = new UiObject(new UiSelector().resourc...
cdbc0d69-3c10-495e-b9da-c61d30656e96
private void selectAudio() throws UiObjectNotFoundException { UiObject sharingUiObject = new UiObject(new UiSelector().resourceId("to.talk:id/content_sharing_btn")); sharingUiObject.click(); }
550f6bb1-f04a-43fd-86ec-c31649ac5872
private void sendAudio() { }
ede3a163-c6be-4412-aaa1-f873e59b59a2
public void testDemo() throws UiObjectNotFoundException { // UiObject ttApp = new UiObject(new UiSelector().packageName("com.android.launcher").text("Talk.to")); // // ttApp.clickAndWaitForNewWindow(); // UiDevice myDevice = UiDevice.getInstance(); // // myDevice.pressHome(); // // U...
8d164715-df24-4e31-8423-c01041bcdadb
public void testOpenTalkToThroughAppMenu() throws UiObjectNotFoundException, RemoteException { UiDevice uiDevice = UiDevice.getInstance(); uiDevice.pressHome(); uiDevice.setOrientationNatural(); // KeyguardManager mKeyGuardManager = new Keyg(KeyguardManager) getSystemService(KEYGUARD_SE...
88642d0d-01b5-4140-af91-a2bec591a757
public void testDemo() throws UiObjectNotFoundException { // Simulate a short press on the HOME button. getUiDevice().pressHome(); // We’re now in the home screen. Next, we want to simulate // a user bringing up the All Apps screen. // If you use the uiautoma...
630f0273-805b-4c24-9941-60b0a91b6e71
public void testRough() throws UiObjectNotFoundException { UiObject textBox = new UiObject(new UiSelector().packageName("to.talk").resourceId("to.talk:id/message_field")); UiObject sendButton = new UiObject(new UiSelector().packageName("to.talk").resourceId("to.talk:id/message_field")); te...
48f3ff25-85bd-43f6-818d-01414ba4b813
public void testSearchContactAndText() throws RemoteException, UiObjectNotFoundException { String searchText = getParams().getString("search"); String newString = ""; if(searchText.contains("%nbsp")) { newString = searchText.replaceAll("%nbsp", " "); System.out.print("Searched Text"+new...
b417f175-14f0-4072-89ed-3cd2d2edab5c
private void searchContact(String searchText) throws UiObjectNotFoundException { // to.talk:id/search_box UiObject searchUiObject = new UiObject(new UiSelector().resourceId("to.talk:id/menu_home_activity_search_contact")); searchUiObject.clickAndWaitForNewWindow(); UiObject searchEdit...
9b5b8193-8160-4451-95cf-c3cc6c83331c
private void writeText() { // UiObject writeMessageUiObject = new UiObject(new UiSelector().resourceId("to.talk:id/message_field")); try { new UiObject(new UiSelector().resourceId("to.talk:id/message_field")).setText("TEST"); // writeMessageUiObject.click(); // ...
9f7da381-8ea1-415c-928d-fa70b5278dd7
private void sendText() throws UiObjectNotFoundException { UiObject sendMessageButtonUiObject = new UiObject(new UiSelector().resourceId("to.talk:id/send")); sendMessageButtonUiObject.click(); }
9fc10b88-90e1-4960-be62-27c1a962e106
public StockPrice(int dayNumber, double price) { this.dayNumber = dayNumber; this.price = price; }
5103c3ea-2939-4a92-9e1a-a559a36707f8
public int getDayNumber() { return dayNumber; }
b64708e0-cba4-45d7-9062-b49e858e402c
public void setDayNumber(int dayNumber) { this.dayNumber = dayNumber; }
e9b44c04-e0b7-4d38-b1f6-1143bbd0e7b3
public double getPrice() { return price; }
c7ceb463-edaf-4aff-b538-096fd3930540
public void setPrice(double price) { this.price = price; }
cd08cf53-5843-4947-83d9-7fee6851803e
public String getActionName() { return type.toString(); }
cfa886b9-4d7d-47ea-9e97-aadb95020117
public String getDetails() { return null; }
f9c994e9-ceb7-4811-accd-628e04b136dd
public int getDayNumber() { return dayNumber; }
a0e8bf61-8fad-4dbb-894d-618aa5313527
public ActionType getType() { return type; }
fc47352d-2d47-4a95-bdc8-47feac04c061
public Share(double initialPrice) { this.initialPrice = initialPrice; }
75b4e813-817e-4a58-8adc-18fd349f8137
public double getInitialPrice() { return initialPrice; }
3c08eb0b-4879-44b7-9154-62e896c17bab
private static List<StockPrice> getStockPrices1() { List<StockPrice> stockPrices = new LinkedList<StockPrice>(); stockPrices.add(new StockPrice(1, 2.0)); stockPrices.add(new StockPrice(2, 3.0)); stockPrices.add(new StockPrice(3, 5.0)); stockPrices.add(new StockPrice(4, 4.0)); ...
2e580d03-d249-4836-a864-4c74fec1966d
private static List<StockPrice> getStockPrices2() { List<StockPrice> stockPrices = new LinkedList<StockPrice>(); stockPrices.add(new StockPrice(1, 2.0)); stockPrices.add(new StockPrice(2, 3.0)); stockPrices.add(new StockPrice(3, 10.0)); stockPrices.add(new StockPrice(4, 4.0)); ...
8c4ebc5f-fc2e-4347-8011-b87caf3bd6d9
public static void main(String[] args) { List<StockPrice> stockPrices = getStockPrices1(); Collection<Action> bestActions = StocksGenius.getBestActions1(stockPrices); print(stockPrices, bestActions); }
71a85bd2-e6d9-4461-930c-328e670ac8b3
private static void print(Collection<StockPrice> stockPrices, Collection<Action> bestActions) { assert stockPrices.size() == bestActions.size(); assert stockPrices.size() != 0; Iterator<StockPrice> stockPriceIt = stockPrices.iterator(); Iterator<Action> actionIt = bestActions.iterator(...
485c2cae-8633-425c-8de5-306dd29dd886
private BuySellPeriod(int periodStartDayNumber, int periodEndDayNumber, double maxSellPrice) { assert periodStartDayNumber <= periodEndDayNumber; this.periodStartDayNumber = periodStartDayNumber; this.periodEndDayNumber = periodEndDayNumber; this.maxSellPrice = maxSellPri...
f2127b5a-60a0-4edf-8a57-245563f2f1da
public int getPeriodStartDayNumber() { return periodStartDayNumber; }
1b5364aa-fa97-4c97-ba49-f83324dced78
public int getPeriodEndDayNumber() { return periodEndDayNumber; }
43c897e8-bd9b-4b98-8357-7783a625daa3
public Collection<Action> generateActionsForPeriod(Collection<StockPrice> stockPrices) { Collection<Action> listOfActions = new LinkedList<Action>(); if (periodStartDayNumber == periodEndDayNumber) { listOfActions.add(new PassAction(periodStartDayNumber)); return ...
86bf6ba6-c3e9-41c0-9e2b-1d83781899dc
private StockPrice getStockPriceForDay(int day, Collection<StockPrice> stockPrices) { for (StockPrice stockPrice : stockPrices) { if (stockPrice.getDayNumber() == day) { return stockPrice; } } return null; }
59e84623-4520-4540-a269-cca9a30a0659
public static Collection<Action> getBestActions1(List<StockPrice> stockPrices) { Collection<BuySellPeriod> periods = getPeriods(stockPrices); // complexity O(N^2) Collection<Action> actions = new LinkedList<Action>(); for (BuySellPeriod period : periods) { // complexity O(N) actions...
8cafaa49-967d-4697-be1b-1ba4dc16677e
private static Collection<BuySellPeriod> getPeriods(List<StockPrice> stockPricesForPeriod) { Collection<BuySellPeriod> periods = new LinkedList<BuySellPeriod>(); StockPrice maxStockPriceForPeriod; do { // First we are looking for max stock price for all available days. ma...
2b1d87dd-6166-41da-875f-98668ab43de5
private static List<StockPrice> getNewPeriodStockPrices(List<StockPrice> stockPricesForPeriod, StockPrice maxStockPriceForPeriod) { // complexity O(N) // Cut data for [day 1, day with max price] List<StockPrice> stockPricesForNewPeriod = new LinkedList<StockPrice>(stockPricesForPeriod .s...
9ccb1a1c-e38b-47c9-8cc0-d1db364f28d3
private static StockPrice getDayWithMaxStockPrice(Collection<StockPrice> stockPrices) { // complexity O(N) assert stockPrices.size() != 0; StockPrice maxStockPrice = stockPrices.iterator().next(); // get first element for (StockPrice stockPrice : stockPrices) { if (maxStockPrice.get...
fddc66b6-e5df-4815-af0a-eafbba032ce5
public BuyAction(int day, Share share) { this.type = ActionType.BUY; this.dayNumber = day; this.share = share; }
11a016ec-1f77-400c-b7ee-cecaf814656c
public String getDetails() { return "-" + String.valueOf(share.getInitialPrice()); }
92f925ef-a745-42f7-8780-b2ca3b72d02c
public PassAction(int day) { this.type = ActionType.PASS; this.dayNumber = day; }
63343b52-aba6-49ad-8832-a37d98eed714
public String getDetails() { return "Pass"; }
37f191f1-db39-4560-98cc-1d8875684b70
public SellAction(int day, double profit) { this.type = ActionType.SELL; this.dayNumber = day; this.profit = profit; }
a18a76fe-1354-41ee-ad28-8c8d54abf1a9
public String getDetails() { return "+" + String.valueOf(profit); }
de173d61-d857-41de-b167-752700025ea0
public static Collection<Integer> findDuplicates(Collection<Integer> numbers) { // full complexity O(n^2) List<Integer> duplicates = new LinkedList<Integer>(); // Set<Integer> duplicates = new HashSet<Integer>(); // if we need same order as in example Set<Integer> processedValues = new HashSet<...
43f1bfd7-95eb-4a21-9fd1-fbf04cfca187
public static void main(String[] args) { Collection<Integer> numbers = Arrays.asList(6, 1, 1, 2, 3, 4, 8, 43, 5, 8, 1, 43, 2, 2, 9); Collection<Integer> dupes = findDuplicates(numbers); for (int dupe : dupes) { System.out.println("dupe = " + dupe); } }
0cc3d0e7-c48b-494a-9461-60835c27ebf9
private static Collection<Email> generateTestData(RandomOrder shouldBeRandom) { Collection<Email> emails; if (shouldBeRandom == RandomOrder.TRUE) { emails = new HashSet<Email>(); // can be used if we need randomly ordered input data } else { emails = new LinkedList<Email>...
b7377db8-1923-47a4-b2a7-93ab7d5b61e3
private static void print(Collection<Collection<Email>> emailBatches) { int i = 1; for (Collection<Email> batch : emailBatches) { System.out.println("Email batch #" + i++); for (Email email : batch) { System.out.format(" [%s]%s\n", email.getTo(), email.getMessa...
ff42f439-4751-45f3-bc36-3743b23d3264
public static void main(String[] args) { Collection<Email> emails = generateTestData(RandomOrder.FALSE); // switch to TRUE for randomly ordered input data // print input emails for (Email email : emails) { System.out.format("[%s]%s\n", email.getTo(), email.getMessage()); } ...
cf5e0276-dcea-41e2-b888-137ae2669092
public static Collection<Collection<Email>> batchEmails1(Collection<Email> emails) { // complexity O(N^2) List<Collection<Email>> batchs = new LinkedList<Collection<Email>>(); // add list as first batch batchs.add(new LinkedList<Email>()); for (Email email : emails) { // complexity O(...
8ec63e69-a34e-42cb-b078-74c579e72b2e
private static boolean doesButchContainRecipient(Collection<Email> batch, String emailAddress) { // complexity O(n) for (Email email : batch) { if (email.getTo().equals(emailAddress)) { return true; } } return false; }
55f29529-78f2-4f70-9435-6f8ca5b0fe8a
public static Collection<Collection<Email>> batchEmails2(Collection<Email> emails) { // complexity O(N^2) List<Map<String, Email>> tempBatches = new LinkedList<Map<String, Email>>(); // Maps will contain pairs <EmailsAddress, EmailObject> // add first temporary batch tempBatches.add(new...
3a3c48cd-0a17-44c2-9b49-14c824f96726
public Email(String to, String message) { this.to = to; this.message = message; }
ce71f704-0ab5-4947-8c4f-e39ef2ea449a
public String getMessage() { return message; }
9175c1fb-dc23-4a8a-a102-346eb1be3659
public void setMessage(String message) { this.message = message; }
5611645d-cc90-4ba3-b91a-f93dce30c73b
public String getTo() { return to; }
ba9f4c88-121c-4a2f-94c9-ce061af06726
public void setTo(String to) { this.to = to; }
b8e09ccf-404e-4b3d-86eb-5f62e7b5dd5e
private static List<Task> getTestData() { List<Task> tasks = new ArrayList<Task>(); Date startDate = new Date(); Date endDate = new Date(); startDate.setSeconds(0); endDate.setSeconds(0); startDate.setHours(12); startDate.setMinutes(0); endDate.setHours...
c444d4b8-725c-4b3e-b2bc-d3488642c78b
private static void printTasks(List<Task> tasks) { System.out.println("Tasks:"); int i = 1; for (Task task : tasks) { System.out.format("%s: %02d:%02d - %02d:%02d\n", i++, task.getStart().getHours(), task.getStart().getMinutes(), task.getEnd().getHours(), task.get...
4b7aa39d-5d7e-4c43-bbd5-ac8a9a268ece
private static void printPoints(Collection<Point> points) { System.out.println("Points:"); int i = 1; for (Point point : points) { System.out.format("%s: %02d:%02d - %d\n", i++, point.getTime().getHours(), point.getTime().getMinutes(), point.getCount()); } }
96ae51a1-e1bb-4552-ab7d-4f899cdd47d7
public static void main(String[] args) { List<Task> tasks = getTestData(); printTasks(tasks); Collection<Point> points = TaskToPointConverter.createPoint1(tasks); printPoints(points); points = TaskToPointConverter.createPoint2(tasks); printPoints(points); }
e97d2f41-e10c-4400-a7ce-7388a211990c
public static Collection<Point> createPoint1(Collection<Task> tasks) { // complexity O(n^2) TreeSet<Date> possiblePointDates = new TreeSet<Date>(); for (Task task : tasks) { // complexity O(n) possiblePointDates.add(task.getStart()); possiblePointDates.add(task.getEnd()); ...
4706b787-f39e-43b6-b5c7-53098e69483e
private static int coutOfTasks(Date date, Collection<Task> tasks) { // complexity O(n) int i = 0; for (Task task : tasks) { if ((task.getStart().equals(date) || task.getStart().before(date)) && task.getEnd().after(date)) { i++; } } ...
532f42d4-25f0-448a-8d84-ac907f87bb71
public static Collection<Point> createPoint2(Collection<Task> tasks) { // complexity O(n*log_n) TreeMap<Date, Integer> points = new TreeMap<Date, Integer>(); for (Task task : tasks) { // complexity O(n*log_n) Date startDate = task.getStart(); Object count = points.get(startDate...
9a1be124-bfad-4079-8f65-fff74dfb54eb
public Task(Date start, Date end) { this.start = start; this.end = end; }
2c566e46-41d8-4789-80f5-d132c3095731
public Date getStart() { return start; }
7a94cc60-87e5-42d4-af8e-1b5884308534
public Date getEnd() { return end; }
163625c9-3235-4f7f-b3e8-e5a7cdfbf25c
public Point(Date time, int count) { this.time = time; this.count = count; }
0ae58f99-4bde-4fe3-a0c4-a7f00799a99a
public Date getTime() { return time; }
45817559-60e5-4f61-9fd7-77bc2cc509dc
public int getCount() { return count; }
830471a1-2599-4ea9-936a-23db08e3c390
public HomePage(WebDriver driver){ this.driver = driver; driver.get(BASE_URL); }
0ca3cc29-e0b0-408d-a3dc-ffaaa853ba5f
public String getCompanyName(){ LOG.debug(MSG_GETTING_COMPANY_NAME); return driver.findElement(BY_COMPANY_NAME).getText(); }
d593c748-e619-4c75-a6d5-68f0aade056b
public String getWelcomeMessage() { return driver.findElement(BY_WELCOME_MESSAGE).getText(); }
3e6b2878-12d8-4c59-8548-df1278f90ab8
public WebElement lookForElementNotOnPage(){ return driver.findElement(BY_DOES_NOT_EXIST); }
9b22da10-7f87-4566-8242-0ac3c62c6d23
public HistoryPage clickQuickHistory(){ driver.findElement(BY_QUICK_HISTORY).click(); return new HistoryPage(driver); }
42c3021c-ba4c-46e7-8a41-76b349a9eeb7
public boolean hasLongHistorySuccessOption(){ boolean found = false; driver.findElement(BY_LONG_HISTORY).click(); //simpleWaitLongHistoryOpts(); fluentWaitLongHistoryOpts(); List<WebElement> options = driver.findElement(BY_LONG_HISTORY_OPTIONS).findElements(By.tagName("option...
41c11af4-e007-44aa-80b2-45a70a1beaa0
private void simpleWaitLongHistoryOpts(){ WebElement longHistoryOptions = (new WebDriverWait(driver, 20)) .until(ExpectedConditions.presenceOfElementLocated(BY_LONG_HISTORY_OPTIONS)); }
5af5c9ec-052a-4da8-8401-d3afbbfd88d9
private void fluentWaitLongHistoryOpts(){ Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(20, TimeUnit.SECONDS) .pollingEvery(100, TimeUnit.MILLISECONDS) .ignoring(NoSuchElementException.class); wait.until(ExpectedConditions.element...
35369835-5e06-4653-af5b-270ed551bf5e
public PricingPage(WebDriver driver){ this.driver = driver; driver.get(BASE_URL); }
fa7bad83-c0ea-4090-988b-ecfedbe153df
public List<String> getRateTypes(){ ArrayList results = new ArrayList(); for(WebElement priceMapping : driver.findElements(LIST_ITEM_PRICE)){ results.add(priceMapping.getText().split(":")[0]); } return results; }
7d6051dc-c4be-49bf-9a88-cff477b7e370
public HistoryPage(WebDriver driver){ this.driver = driver; }
664b64f9-374a-4d7c-be8e-cbc8d93085c3
public String getTitle(){ return driver.findElement(BY_TITLE).getText(); }
9b3a2c3b-cd6d-40d8-bb9c-a83459c0c445
public FunctionalTest() { }
442fd0cd-2115-4afb-8016-37648746513d
@BeforeClass public static void createDriver() { LOG.debug("Instantiating new driver."); driver = new ChromeDriver(); }
bd223547-60c0-4e26-93e0-2001a45e9421
@AfterClass public static void closeDriver() { LOG.debug("Closing driver."); driver.close(); }
d84a4751-63f0-4977-ad3f-5acdf2f351bc
@Before public void setUp(){ pricingPage = new PricingPage(driver); }
5a333729-37d8-4b6e-84b7-c92b1d50edf2
@Test public void threeRateTypesAvailable(){ assertThat(pricingPage.getRateTypes().size()).isEqualTo(3); }
183fb022-5e2a-47ae-9461-9b6cbe8415e0
@Test public void hourDayWeekPricesAvailable(){ List<String> rateTypes = pricingPage.getRateTypes(); assertThat(rateTypes).containsExactly("Hour","Day","Week"); }
cc09054b-4a3d-4e40-964e-4944690a9448
@Before public void setUp(){ homePage = new HomePage(driver); }
76889566-0204-4bf4-9a78-ea03be46f422
@Test public void companyNameIsCorrect(){ assertThat(homePage.getCompanyName()).isEqualTo(HomePage.EXPECTED_COMPANY_NAME); }
9e6b566e-d4dd-4f13-82be-2055bba4fb71
@Test public void welcomeMessageIsCorrect(){ assertThat(homePage.getWelcomeMessage()).isEqualTo(HomePage.EXPECTED_WELCOME_MESSAGE); }
f7a3f9e7-cfc9-4e37-9029-c1de3065c397
@Test public void longHistoryHasSuccessOption(){ assertThat(homePage.hasLongHistorySuccessOption()).overridingErrorMessage("Success option not found!!!"); }
dc23fc29-cd99-4d4a-a9e0-3a8083f6685d
@Test public void getHistoryPage(){ HistoryPage historyPage = homePage.clickQuickHistory(); assertThat(historyPage.getTitle()).isEqualTo(HistoryPage.EXPECTED_TITLE); }
9d826f64-1441-44eb-833f-b8f404651d0b
@Test(expected = NoSuchElementException.class) public void lookForSomethingNotOnPage(){ homePage.lookForElementNotOnPage(); }