Package com.denisk.appengine.nl.server.data

Examples of com.denisk.appengine.nl.server.data.Category


  public ArrayList<Category> getCategories(Iterator<Entity> iterator) {
    ArrayList<Category> result = new ArrayList<Category>();
    while(iterator.hasNext()){
      Entity e = iterator.next();
      Category c = categoryFromEntity(e);
     
      result.add(c);
    }
   
    return result;
View Full Code Here


   
    return result;
  }

  private Category categoryFromEntity(Entity e) {
    Category c = new Category();
    setCommonJsonableProperties(e, c);
    c.setBackgroundBlobKey((String) e.getProperty(Category.BACKGROUND_BLOB_KEY));
   
    return c;
  }
View Full Code Here

  }

  @Test
  public void dataHandlerBasicTest() throws EntityNotFoundException {

    Category c = new Category();
    c.setName("hello");
    c.setDescription(new Text("desc"));

    Good g1 = new Good();
    Good g2 = new Good();

    g1.setName("g1_name");
    g2.setName("g2_name");

    g1.setName("g1_desc");
    g2.setDescription(new Text("g2_desc"));

    c.getGoods().add(g1);
    c.getGoods().add(g2);

    assertEquals(
        0,
        ds.prepare(new Query(Category.KIND)).countEntities(
            withLimit(10)));
View Full Code Here

  }

  @Override
  public String persistCategory(String categoryJson) {
    checkCredentials();
    Category category = new Category().getFromJson(categoryJson);
    return KeyFactory.keyToString(dh.saveCategoryWithGoods(category));
  }
View Full Code Here

  }

  @Test
  public void getCategories() {

    Category c = new Category();
    c.setName("hello");
    c.setDescription(new Text("desc"));

    Category c1 = new Category();
    c1.setName("another");
    c1.setDescription(new Text("desc"));

    Good g1 = new Good();
    Good g2 = new Good();

    g1.setName("g1_name");
View Full Code Here

    assertTrue(categories.contains(c1));
  }

  @Test
  public void getCategoriesJson() throws JSONException {
    Category c = new Category();
    c.setName("hello");
    c.setDescription(new Text("desc"));

    Category c1 = new Category();
    c1.setName("another");
    c1.setDescription(new Text("desc"));

    Good g1 = new Good();
    Good g2 = new Good();

    g1.setName("g1_name");
View Full Code Here

    assertTrue(categoriesJson.contains("hello"));
  }

  @Test
  public void getGoodsJson() {
    Category c = new Category();
    c.setName("hello");
    c.setDescription(new Text("desc"));

    Category c1 = new Category();
    c1.setName("another");
    c1.setDescription(new Text("desc"));

    Good g1 = new Good();
    Good g2 = new Good();
    Good g3 = new Good();

    g1.setName("g1_name");
    g2.setName("g2_name");
    g3.setName("g3_name");

    g1.setDescription(new Text("g1_desc"));
    g2.setDescription(new Text("g2_desc"));
    g3.setDescription(new Text("g3_desc"));

    c.getGoods().add(g1);
    c.getGoods().add(g2);

    c1.getGoods().add(g3);

    Key key1 = dh.saveCategoryWithGoods(c);
    dh.saveCategoryWithGoods(c1);

    String json = dh.getGoodsJson(KeyFactory.keyToString(key1));
View Full Code Here

    assertFalse(json.contains("g3_desc"));
  }

  @Test
  public void clearGoodsForCategory() {
    Category c = new Category();
    c.setName("hello");
    c.setDescription(new Text("desc"));

    Category c1 = new Category();
    c1.setName("another");
    c1.setDescription(new Text("desc"));

    Good g1 = new Good();
    Good g2 = new Good();
    Good g3 = new Good();

    g1.setName("g1_name");
    g2.setName("g2_name");
    g3.setName("g3_name");

    g1.setDescription(new Text("g1_desc"));
    g2.setDescription(new Text("g2_desc"));
    g3.setDescription(new Text("g3_desc"));

    c.getGoods().add(g1);
    c.getGoods().add(g2);

    c1.getGoods().add(g3);

    Key key1 = dh.saveCategoryWithGoods(c);
    Key key2 = dh.saveCategoryWithGoods(c1);

    String key1Str = KeyFactory.keyToString(key1);
View Full Code Here

    assertTrue(goodsJson.contains("g3_name"));
  }

  @Test
  public void persistGood() {
    Category c = new Category();
    Key categoryKey = dh.saveCategoryWithGoods(c);

    Good g = new Good();
    String name = "hello";
    String descr = "descr";
View Full Code Here

  @Test
  public void updateCategoryBackgroundImage() throws IOException {
    String imageKeyStr = createImage();

    Category c = new Category();
    String categoryKeyStr = KeyFactory.keyToString(dh
        .saveCategoryWithGoods(c));

    dh.updateCategoryBackground(categoryKeyStr, imageKeyStr);
View Full Code Here

TOP

Related Classes of com.denisk.appengine.nl.server.data.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.