Examples of ProductAttribute


Examples of com.google.code.magja.model.product.ProductAttribute

   * Test method for {@link com.google.code.magja.service.product.ProductAttributeRemoteServiceImpl#getByCode(java.lang.String)}.
   */
  @Test
  public void testGetByCode() {
    try {
      ProductAttribute pa = service.getByCode("description");
      assertTrue(pa.getId() != null);
     
    } catch (ServiceException e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

      fail(e.getMessage());
    }
  }
 
  private ProductAttribute createSelectAttributeSimple() {
    ProductAttribute attribute = createTextAttributeSimple();
   
    attribute.setType("int");
    attribute.setInput("select");
   
    return attribute;
  }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

    return attribute;
  }

  private ProductAttribute createTextAttributeSimple() {

    ProductAttribute attribute = new ProductAttribute();

    attribute.setCode(MagjaStringUtils.randomString(3, 8).toUpperCase());
    attribute.setScope(ProductAttribute.Scope.STORE);
    attribute.setGroup("General");
    attribute.setType("varchar");
    attribute.setBackend("");
    attribute.setFrontend("");
    attribute.setLabel(MagjaStringUtils.randomString(3, 8).toUpperCase());
    attribute.setInput("text");
    attribute.setAttributeClass("");
    attribute.setSource("");
    attribute.setVisible(true);
    attribute.setRequired(false);
    attribute.setUserDefined(true);
    attribute.setDefaultValue("");
    attribute.setSearchable(true);
    attribute.setFilterable(true);
    attribute.setComparable(true);
    attribute.setVisibleOnFront(true);
    attribute.setVisibleInAdvancedSearch(true);
    attribute.setUnique(false);

    return attribute;
  }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

    return attribute;
  }

  public ProductAttribute createSelectWithOptionsAndApplyToSpecified() {

    ProductAttribute attribute = new ProductAttribute();

    attribute.setCode(MagjaStringUtils.randomString(3, 8).toUpperCase());
    attribute.setScope(ProductAttribute.Scope.STORE);

    attribute.setGroup("General");
    attribute.setType("int");
    attribute.setBackend("");
    attribute.setFrontend("");
    attribute.setLabel(MagjaStringUtils.randomString(3, 8).toUpperCase());
    attribute.setInput("select");
    attribute.setAttributeClass("");
    attribute.setSource("");
    attribute.setVisible(true);
    attribute.setRequired(false);
    attribute.setUserDefined(true);
    attribute.setDefaultValue("");
    attribute.setSearchable(true);
    attribute.setFilterable(true);
    attribute.setComparable(true);
    attribute.setVisibleOnFront(false);
    attribute.setVisibleInAdvancedSearch(true);
    attribute.setUnique(false);

    attribute.setApplyTo(new ArrayList<ProductType>());
    attribute.getApplyTo().add(ProductTypeEnum.SIMPLE.getProductType());
    attribute.getApplyTo().add(ProductTypeEnum.GROUPED.getProductType());
    attribute.getApplyTo().add(ProductTypeEnum.CONFIGURABLE.getProductType());

    // create some options
    attribute.setOptions(new HashMap<Integer, String>());
    attribute.getOptions().put(1, MagjaStringUtils.randomString(3, 8));
    attribute.getOptions().put(2, MagjaStringUtils.randomString(3, 8));
    attribute.getOptions().put(3, MagjaStringUtils.randomString(3, 8));

    return attribute;
  }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

   * @param attributes
   * @return ProductAttribute
   */
  private ProductAttribute buildProductAttribute(
      Map<String, Object> attributes) {
    ProductAttribute pa = new ProductAttribute();

    for (Map.Entry<String, Object> attr : attributes.entrySet())
      pa.set(attr.getKey(), attr.getValue());

    return pa;
  }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

    if (prd_attributes == null)
      return results;

    for (Map<String, Object> att : prd_attributes) {
      ProductAttribute prd_attribute = new ProductAttribute();
      for (Map.Entry<String, Object> attribute : att.entrySet()) {
        if (!attribute.getKey().equals("scope"))
          prd_attribute.set(attribute.getKey(), attribute.getValue());
      }

      prd_attribute.setScope(ProductAttribute.Scope
          .getByName((String) att.get("scope")));

      results.add(prd_attribute);
    }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

  @Test
  public void testDelete() {
    try {

      // first, create a attribute to be deleted
      ProductAttribute pa = createTextAttributeSimple();
      service.save(pa);
      assertTrue(pa.getId() != null);

      // then, delete the pa
      service.delete(pa.getCode());

    } catch (ServiceException e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

   * Test method for
   * {@link com.google.code.magja.service.product.ProductAttributeRemoteServiceImpl#addOption(com.google.code.magja.model.product.ProductAttribute, java.lang.String)}.
   */
  @Test
  public void testAddOption() {
    ProductAttribute pa = createSelectAttributeSimple();
   
    try {
     
      service.save(pa);
     
      service.addOption(pa, "Small");
      service.addOption(pa, "Medium");
      service.addOption(pa, "Big");
     
      assertTrue(pa.getId() != null);
     
      service.delete(pa.getCode());
     
    } catch (ServiceException e) {
      fail(e.getMessage());
    }
   
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

  @Test
  public void testGetOptions() {

    try {

      ProductAttribute pa = new ProductAttribute();
      pa.setCode("color");
      service.getOptions(pa);
      if(pa.getOptions() != null) {
        for (Map.Entry<Integer, String> opt : pa.getOptions().entrySet())
          System.out.println(opt.toString());
      }
     
    } catch (ServiceException e) {
      fail(e.getMessage());
View Full Code Here

Examples of com.google.code.magja.model.product.ProductAttribute

   */
  @Test
  public void testSave() {

    try {
      ProductAttribute pa1 = createTextAttributeSimple();
      service.save(pa1);

      assertTrue(pa1.getId() != null);

      ProductAttribute pa2 = createSelectWithOptionsAndApplyToSpecified();
      service.save(pa2);

      assertTrue(pa2.getId() != null);

      // comment if you don't want to delete the created pa's
      service.delete(pa1.getCode()); service.delete(pa2.getCode());

    } catch (ServiceException e) {
      fail(e.getMessage());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.