예제 #1
0
 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();
   }
 }
예제 #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");
 }
예제 #3
0
 @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();
   }
 }