Skip to content

Instantly share code, notes, and snippets.

View michal-lipski's full-sized avatar
🏠
Working from home

Michal Lipski michal-lipski

🏠
Working from home
View GitHub Profile
class Deque<T> {
private Element front, rear;
public Deque() {
setFrontPointerTo(null);
setRearPointerTo(null);
}
public void unshift(T data) {
@michal-lipski
michal-lipski / deque.java
Created June 21, 2012 00:18
question 1 (deque)
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class DequeTest {
@Test
public void should_return_null_on_empty_deque() {
@michal-lipski
michal-lipski / postal_code.java
Created June 21, 2012 00:21
question 2 (postal code)
public Boolean canShip(int postalCode) {
//postalCodeDao operates on database to get list of postal codes
//there is a caching solution applied so that list is stored in memory
// and fetched only when database change
List<Integer> allPostalCodes = postalCodeDao.getAllPostalCodes();
return allPostalCodes.contains(postalCode);
}
driver.findElement(By.id("login_field")).sendKeys("text");
loginField.sendKeys("text");
@FindBy(id="login_field")
WebElement loginField;
@FindBy(name="password")
WebElement passwordField;
@FindBy(className="error_box")
WebElement errorBox;
GitHubLoginPage page = PageFactory.initElements(driver, GitHubLoginPage.class);
public class GitHubLoginPage extends GitHubPage {
@FindBy(id = "login_field")
WebElement loginField;
@FindBy(name = "password")
WebElement passwordField;
@FindBy(name = "commit")
WebElement commitButton;
@Test
public void shouldNotLoginWithWrongCredentials() {
//given
GitHubLoginPage loginPage = new GitHubHomePage().open().goToLoginPage();
//when
loginPage.login("user", "wrong_password");
//then
assertThat(loginPage.isLoginError()).isTrue();
}
@michal-lipski
michal-lipski / gist:3434637
Created August 23, 2012 09:29
deploying current branch on heroku
#!/bin/bash
#Script for deploying current branch to heroku app given as parameter
die () {
echo >&1 "$@"
echo usage $0 app-name
echo example: $0 dev-ml
exit 1
}