Exemple #1
0
  @Test
  public void testRenderNewXmlView() {
    PageParameters pageParameters = new PageParameters();
    pageParameters.set(VIEW.toString(), "xml");

    tester.startPage(EditProductPage.class, pageParameters);

    tester.assertNoErrorMessage();
    tester.assertComponent("productPanel:feedback", FeedbackPanel.class);
    tester.assertComponent("productPanel:productForm", Form.class);
    tester.assertComponent("productPanel:productForm:uuid", HiddenField.class);
    tester.assertComponent("productPanel:productForm:control.xml:xml", TextArea.class);
  }
Exemple #2
0
  @Test
  public void testCreateNewXmlViewWithExistingProduct() {
    PageParameters pageParameters = new PageParameters();
    pageParameters.set(VIEW.toString(), "xml");
    tester.startPage(EditProductPage.class, pageParameters);
    FormTester formTester = tester.newFormTester("productPanel:productForm");
    formTester.setValue("control.xml:xml", productMarshaller.marshal(shsProduct));
    formTester.submitLink("submit", false);

    tester.assertRenderedPage(EditProductPage.class);

    tester.assertErrorMessages(
        "A product with the UUID " + shsProduct.getUuid() + " already exists");
  }
Exemple #3
0
  @Test
  public void testCreateNewXmlView() {
    PageParameters pageParameters = new PageParameters();
    pageParameters.set(VIEW.toString(), "xml");
    tester.startPage(EditProductPage.class, pageParameters);
    FormTester formTester = tester.newFormTester("productPanel:productForm");
    shsProduct.setUuid(UUID.randomUUID().toString());
    formTester.setValue("control.xml:xml", productMarshaller.marshal(shsProduct));
    formTester.submitLink("submit", false);

    tester.assertRenderedPage(ProductPage.class);

    tester.assertNoErrorMessage();
  }
Exemple #4
0
  @Test
  public void testSubmitInvalidXml() {
    PageParameters pageParameters = new PageParameters();
    pageParameters.set(VIEW.toString(), "xml");
    pageParameters.set(EDIT_MODE.toString(), true);
    pageParameters.set(CURRENT_UUID.toString(), shsProduct.getUuid());

    tester.startPage(EditProductPage.class, pageParameters);
    FormTester formTester = tester.newFormTester("productPanel:productForm");
    formTester.setValue("control.xml:xml", "Not xml");
    formTester.submitLink("submit", false);

    tester.assertRenderedPage(EditProductPage.class);

    tester.assertErrorMessages("The supplied product xml is invalid");
  }
Exemple #5
0
  @Test
  public void testEditProductXmlView() {
    PageParameters pageParameters = new PageParameters();
    pageParameters.set(VIEW.toString(), "xml");
    pageParameters.set(EDIT_MODE.toString(), true);
    pageParameters.set(CURRENT_UUID.toString(), shsProduct.getUuid());

    tester.startPage(EditProductPage.class, pageParameters);
    FormTester formTester = tester.newFormTester("productPanel:productForm");
    shsProduct.setCommonName("New common name");
    formTester.setValue("control.xml:xml", productMarshaller.marshal(shsProduct));
    formTester.submitLink("submit", false);

    tester.assertRenderedPage(ProductPage.class);

    tester.assertNoErrorMessage();
  }
Exemple #6
0
  @Test
  public void testChangeUUIDXmlView() {
    PageParameters pageParameters = new PageParameters();
    pageParameters.set(VIEW.toString(), "xml");
    pageParameters.set(EDIT_MODE.toString(), true);
    pageParameters.set(CURRENT_UUID.toString(), shsProduct.getUuid());

    tester.startPage(EditProductPage.class, pageParameters);
    FormTester formTester = tester.newFormTester("productPanel:productForm");
    shsProduct.setUuid(UUID.randomUUID().toString());
    formTester.setValue("control.xml:xml", productMarshaller.marshal(shsProduct));
    formTester.submitLink("submit", false);

    tester.assertRenderedPage(EditProductPage.class);

    tester.assertErrorMessages(
        "UUID must not be updated when editing an existing product. Original uuid "
            + ObjectMother.DEFAULT_PRODUCT_ID);
  }
Exemple #7
0
  @Test
  public void testRenderEditXmlView() {
    PageParameters pageParameters = new PageParameters();
    pageParameters.set(VIEW.toString(), "xml");
    pageParameters.set(EDIT_MODE.toString(), true);
    pageParameters.set(CURRENT_UUID.toString(), shsProduct.getUuid());

    tester.startPage(EditProductPage.class, pageParameters);

    tester.assertNoErrorMessage();
    tester.assertComponent("productPanel:feedback", FeedbackPanel.class);
    tester.assertComponent("productPanel:productForm", Form.class);
    tester.assertComponent("productPanel:productForm:uuid", HiddenField.class);
    tester.assertComponent("productPanel:productForm:control.xml:xml", TextArea.class);

    final TextArea<String> xmlField =
        (TextArea<String>)
            tester.getComponentFromLastRenderedPage("productPanel:productForm:control.xml:xml");
    assertThat(xmlField.getValue(), containsString(shsProduct.getUuid()));
  }