コード例 #1
0
  /**
   * Retrieve information about an Catalog. Check if the returned data are equal to the data of
   * create or update call
   *
   * @param isAlreadyUpdated if true check against update data, else against create data
   */
  public void testGetInfo(boolean isAlreadyUpdated) {
    TGetInfo_Return[] Catalogs_out =
        catalogService.getInfo(
            new String[] {full}, new String[] {"Date"}, new String[] {"de", "en"});

    // test if getinfo was successful and if all data are equal to input
    assertEquals("getInfo result set", 1, Catalogs_out.length);
    assertEquals("catalog alias", alias, Catalogs_out[0].getAlias());
    assertEquals("Number of languages", 2, Catalogs_out[0].getName().length);
    HashMap<String, String> hash = new HashMap<String, String>();
    hash.put(
        Catalogs_out[0].getName()[0].getLanguageCode(), Catalogs_out[0].getName()[0].getValue());
    hash.put(
        Catalogs_out[0].getName()[1].getLanguageCode(), Catalogs_out[0].getName()[1].getValue());

    if (isAlreadyUpdated) {

      try {
        Date date_in = sdf_in.parse(Catalog_up.getAttributes()[0].getValue());
        Date date_out = sdf_out.parse(Catalogs_out[0].getAttributes()[0].getValue());
        assertEquals("Date", date_in, date_out);
      } catch (ParseException e) {
        e.printStackTrace();
      }

      assertEquals(
          "updated localized Name",
          Catalog_up.getName()[0].getValue(),
          hash.get(Catalog_up.getName()[0].getLanguageCode()));
      assertEquals(
          "updated localized Name",
          Catalog_up.getName()[1].getValue(),
          hash.get(Catalog_up.getName()[1].getLanguageCode()));
    } else {

      try {
        Date date_in = sdf_in.parse(Catalog_in.getAttributes()[0].getValue());
        Date date_out = sdf_out.parse(Catalogs_out[0].getAttributes()[0].getValue());
        assertEquals("Date", date_in, date_out);
      } catch (ParseException e) {
        e.printStackTrace();
      }

      assertEquals(
          "initial localized Name",
          Catalog_in.getName()[0].getValue(),
          hash.get(Catalog_up.getName()[0].getLanguageCode()));
      assertEquals(
          "initial localized Name",
          Catalog_in.getName()[1].getValue(),
          hash.get(Catalog_up.getName()[1].getLanguageCode()));
    }

    assertThat(Catalogs_out[0].getParentCatalog(), endsWith(Catalog_in.getParentCatalog()));
    assertEquals("IsVisible", Catalog_in.getIsVisible(), Catalogs_out[0].getIsVisible());
  }
コード例 #2
0
  /** Sets all the required prerequisites for the tests. Will be called before the test are run. */
  @Before
  public void setUp() {

    // create test Catalogs that can be used with the create and update
    // methods
    Catalog_in.setAlias(alias);
    Catalog_in.setName(
        new TLocalizedValue[] {
          new TLocalizedValue("de", "Test-Katalog"), new TLocalizedValue("en", "test Catalog"),
        });
    Catalog_in.setIsVisible(true);
    Catalog_in.setParentCatalog(path);

    String dateStr =
        new String(sdf_in.format(new GregorianCalendar(2005, 11, 24, 18, 00).getTime()));
    TAttribute attr1 = new TAttribute();
    attr1.setName("Date");
    attr1.setType("DateTime");
    attr1.setValue(dateStr);
    Catalog_in.setAttributes(new TAttribute[] {attr1});

    TAttribute layout1 = new TAttribute();
    layout1.setName("Content-Order");
    layout1.setValue("Base_Products_Pages");
    TAttribute layout2 = new TAttribute();
    layout2.setName("Content-Pages");
    layout2.setValue("Pages_SingleColumn");
    Catalog_in.setTemplateTypes(new TAttribute[] {layout1, layout2});

    Catalog_up.setPath(full);
    Catalog_up.setName(
        new TLocalizedValue[] {
          new TLocalizedValue("de", "veränderter Test-Katalog"),
          new TLocalizedValue("en", "updated test Catalog"),
        });

    dateStr = sdf_in.format(new GregorianCalendar(2005, 11, 25, 18, 00).getTime());
    TAttribute attr_update = new TAttribute();
    attr_update.setName("Date");
    attr_update.setType("DateTime");
    attr_update.setValue(dateStr);
    Catalog_up.setAttributes(new TAttribute[] {attr_update});

    TAttribute layout3 = new TAttribute();
    layout3.setName("Content-Order");
    layout3.setValue("Pages_Products_Base");
    TAttribute layout4 = new TAttribute();
    layout4.setName("Content-Pages");
    layout4.setValue("Pages_TwoColumns");
    Catalog_up.setTemplateTypes(new TAttribute[] {layout3, layout4});

    Catalog_sort1.setPath(sort1);
    Catalog_sort2.setPath(sort2);
    Catalog_sort2.setSort("byPriceDESC");
    Catalog_sort3.setPath(sort3);
    Catalog_sort3.setSort("byPriceASC");
    Catalog_sort3.setAllSub(true);

    // delete the test catalog if it exists
    TExists_Return[] Catalogs_exists_out = catalogService.exists(new String[] {full});
    if (Catalogs_exists_out[0].getExists()) {
      catalogService.delete(new String[] {full});
    }
  }