Esempio n. 1
0
 @Test
 public void brandsAndStoresDisplayedCorrectly() {
   Brand newBrand = new Brand("Nike");
   newBrand.save();
   Store newStore = new Store("Foot Traffic");
   newStore.save();
   goTo("http://localhost:4567/");
   assertThat(pageSource()).contains("Nike");
   assertThat(pageSource()).contains("Foot Traffic");
 }
Esempio n. 2
0
 @Test
 public void brandIsAddedToStore() {
   Brand newBrand = new Brand("Asics");
   newBrand.save();
   Store newStore = new Store("Foot Traffic");
   newStore.save();
   newStore.addBrand(newBrand.getId());
   goTo("http://localhost:4567/stores/" + newStore.getId());
   assertThat(pageSource()).contains("Asics");
 }
 public void addBrand(Brand brand) {
   try (Connection con = DB.sql2o.open()) {
     String sql = "INSERT INTO stores_brands (store_id, brand_id) VALUES (:store_id, :brand_id)";
     con.createQuery(sql)
         .addParameter("store_id", this.getId())
         .addParameter("brand_id", brand.getId())
         .executeUpdate();
   }
 }
 @Override
 public boolean equals(Object otherBrand) {
   if (!(otherBrand instanceof Brand)) {
     return false;
   } else {
     Brand newBrand = (Brand) otherBrand;
     return this.getBrandName().equals(newBrand.getBrandName())
         && this.getStyle().equals(newBrand.getStyle())
         && this.getType().equals(newBrand.getType())
         && this.getColor().equals(newBrand.getColor())
         && this.getId() == newBrand.getId();
   }
 }