Exemplo n.º 1
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");
 }
Exemplo n.º 2
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");
 }
Exemplo n.º 3
0
  public void startGuessing(int index) {

    brandIndex = index;
    brand = BrandManager.get(index);

    logoImage.setImageDrawable(brand.logo);

    variant1.setText(brand.getVariant(1));
    variant2.setText(brand.getVariant(2));
    variant3.setText(brand.getVariant(3));
    variant4.setText(brand.getVariant(4));
    brandName.setText(brand.name);

    if (brand.guessed) {
      guessed();
    }
  }
Exemplo n.º 4
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();
   }
 }
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    final Toy toy = (Toy) o;

    if (!brand.equals(toy.brand)) return false;
    if (!name.equals(toy.name)) return false;
    if (!serial.equals(toy.serial)) return false;

    return true;
  }
Exemplo n.º 6
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();
   }
 }
Exemplo n.º 7
0
 private Alias generateAliasFor(Brand content) {
   return PaHelper.getBrandAlias(content.getId().toString());
 }
 public int hashCode() {
   int result;
   result = name.hashCode();
   result = 29 * result + brand.hashCode();
   return result;
 }
  private void updateModelList(String brandName) {
    Brand brandEnum = Brand.getEnum(brandName);

    switch (brandEnum) {
      case BAT:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_bat_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case BRENNENSTUHL:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_brennenstuhl_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case ELRO:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_elro_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case HAMA:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_hama_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case INTERTECHNO:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_intertechno_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case INTERTEK:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_intertek_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case MUMBI:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_mumbi_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case POLLIN_ELECTRONIC:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_pollin_electronic_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case REV:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_rev_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case ROHRMOTOR24:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_rohrmotor24_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case UNIVERSAL:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_universal_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case VIVANCO:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_vivanco_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      default:
        setModelVisibility(View.GONE);
        break;
    }

    if (modelNamesAdapter.getCount() > modelListView.getSelectedItemPosition()) {
      modelListView.setItemChecked(0, true);
      modelListView.smoothScrollToPosition(0);
    }

    modelNamesAdapter.notifyDataSetChanged();
  }
Exemplo n.º 10
0
  public static void main(String[] args) {
    staticFileLocation("/public");
    String layout = "templates/layout.vtl";

    get(
        "/",
        (request, response) -> {
          response.redirect("/stores");
          return null;
        });

    get(
        "/stores",
        (request, response) -> {
          HashMap<String, Object> model = new HashMap<String, Object>();
          model.put("stores", Store.all());
          model.put("template", "templates/stores.vtl");

          return new ModelAndView(model, layout);
        },
        new VelocityTemplateEngine());

    get(
        "/stores/:id",
        (request, response) -> {
          HashMap<String, Object> model = new HashMap<String, Object>();
          model.put("store", Store.find(Integer.parseInt(request.params("id"))));
          model.put("brands", Brand.all());
          model.put("template", "templates/store.vtl");
          return new ModelAndView(model, layout);
        },
        new VelocityTemplateEngine());

    post(
        "/stores/addstore",
        (request, response) -> {
          Store store = new Store(request.queryParams("store-name"));
          store.save();
          response.redirect("/stores/" + store.getId());
          return null;
        });

    post(
        "/stores/:id/addbrand",
        (request, response) -> {
          Store store = Store.find(Integer.parseInt(request.queryParams("addbrand-store-id")));
          store.add(Integer.parseInt(request.queryParams("addbrand-brand-id")));
          response.redirect("/stores/" + store.getId());
          return null;
        });

    post(
        "/stores/:id/unlinkbrand",
        (request, response) -> {
          Store store = Store.find(Integer.parseInt(request.params("id")));
          store.unlink(Integer.parseInt(request.queryParams("unlink-brand")));
          response.redirect("/stores/" + store.getId());
          return null;
        });

    post(
        "/stores/:id/update",
        (request, response) -> {
          Store store = Store.find(Integer.parseInt(request.params("id")));
          store.update(request.queryParams("update-store-name"));
          response.redirect("/stores/" + store.getId());
          return null;
        });

    post(
        "/stores/deletestore",
        (request, response) -> {
          Store store = Store.find(Integer.parseInt(request.queryParams("store-id")));
          store.delete();
          response.redirect("/stores");
          return null;
        });

    get(
        "/brands",
        (request, response) -> {
          HashMap<String, Object> model = new HashMap<String, Object>();
          model.put("template", "templates/brands.vtl");
          model.put("brands", Brand.all());
          return new ModelAndView(model, layout);
        },
        new VelocityTemplateEngine());

    get(
        "/brands/:id",
        (request, response) -> {
          HashMap<String, Object> model = new HashMap<String, Object>();
          model.put("brand", Brand.find(Integer.parseInt(request.params("id"))));
          model.put("stores", Store.all());
          model.put("template", "templates/brand.vtl");
          return new ModelAndView(model, layout);
        },
        new VelocityTemplateEngine());

    post(
        "/brands/addbrand",
        (request, response) -> {
          Brand brand = new Brand(request.queryParams("brand-name"));
          brand.save();
          response.redirect("/brands/" + brand.getId());
          return null;
        });

    post(
        "/brands/:id/addstore",
        (request, response) -> {
          Brand brand = Brand.find(Integer.parseInt(request.queryParams("addstore-brand-id")));
          brand.add(Integer.parseInt(request.queryParams("addstore-store-id")));
          response.redirect("/brands/" + brand.getId());
          return null;
        });

    post(
        "/brands/:id/unlinkstore",
        (request, response) -> {
          Brand brand = Brand.find(Integer.parseInt(request.params("id")));
          brand.unlink(Integer.parseInt(request.queryParams("unlink-store")));
          response.redirect("/brands/" + brand.getId());
          return null;
        });

    post(
        "/brands/:id/update",
        (request, response) -> {
          Brand brand = Brand.find(Integer.parseInt(request.params("id")));
          brand.update(request.queryParams("update-brand-name"));
          response.redirect("/brands/" + brand.getId());
          return null;
        });

    post(
        "/brands/deletebrand",
        (request, response) -> {
          Brand brand = Brand.find(Integer.parseInt(request.queryParams("brand-id")));
          brand.delete();
          response.redirect("/brands");
          return null;
        });
  }