Skip to content

Instantly share code, notes, and snippets.

@pieceofquality
Created September 6, 2016 22:12
Show Gist options
  • Save pieceofquality/f848506367c14ea4a77daea3d291d24d to your computer and use it in GitHub Desktop.
Save pieceofquality/f848506367c14ea4a77daea3d291d24d to your computer and use it in GitHub Desktop.
package com.pieceofquality.addressbook.tests;
import com.pieceofquality.addressbook.model.ContactData;
import com.pieceofquality.addressbook.model.Contacts;
import com.pieceofquality.addressbook.model.GroupData;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.List;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.testng.Assert.assertEquals;
public class ContactDeletionTests extends TestBase{
@BeforeMethod
public void ensurePreconditions(){
app.goTo().groupPage();
if (app.group().all().size() == 0) {
app.group().create(new GroupData().withName("test1"));
}
app.goTo().homePage();
if(app.contact().all().size() == 0) {
app.contact().create(new ContactData()
.withFirstName("First Name").withLastName("Last Name").withGroup("test1"));
}
}
@Test
public void testContactDeletion(){
Contacts before = app.contact().all();
ContactData deletedContact = before.iterator().next();
app.contact().delete(deletedContact);
Contacts after = app.contact().all();
assertEquals(after.size(), before.size() - 1);
assertThat(after, equalTo(before.without(deletedContact)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment