Package org.jboss.forge.addon.ui.impl.mock

Examples of org.jboss.forge.addon.ui.impl.mock.MockValidationContext


   @Test
   public void testRequiredWithMessage()
   {
      UIContext ctx = new MockUIContext();
      MockValidationContext context = new MockValidationContext(ctx);
      requiredWithMessage.validate(context);
      List<String> errors = context.getErrorsFor(requiredWithMessage);
      Assert.assertThat(errors, notNullValue());
      Assert.assertThat(errors.size(), equalTo(1));
      Assert.assertThat(errors, hasItem("MSG"));
   }
View Full Code Here


   @Test
   public void testRequiredNoMessage()
   {
      UIContext ctx = new MockUIContext();
      MockValidationContext context = new MockValidationContext(ctx);
      requiredNoMessage.validate(context);
      List<String> errors = context.getErrorsFor(requiredNoMessage);
      Assert.assertThat(errors, notNullValue());
      Assert.assertThat(errors.size(), equalTo(1));
      Assert.assertThat(errors, hasItem(InputComponents.validateRequired(requiredNoMessage)));
   }
View Full Code Here

   @Test
   public void testNotRequired()
   {
      UIContext ctx = new MockUIContext();
      MockValidationContext context = new MockValidationContext(ctx);
      notRequired.validate(context);
      List<String> errors = context.getErrorsFor(notRequired);
      Assert.assertThat(errors, nullValue());
   }
View Full Code Here

   @Test
   public void testAdditionalValidator()
   {
      UIContext ctx = new MockUIContext();
      MockValidationContext context = new MockValidationContext(ctx);
      withValidator.addValidator(new UIValidator()
      {
         @Override
         public void validate(UIValidationContext validator)
         {
            validator.addValidationError(withValidator, "MSG");
         }
      });
      withValidator.setValue("FOO");
      withValidator.validate(context);
      List<String> errors = context.getErrorsFor(withValidator);
      Assert.assertThat(errors, notNullValue());
      Assert.assertThat(errors.size(), equalTo(1));
      Assert.assertThat(errors, hasItem("MSG"));
   }
View Full Code Here

   @Test
   public void testDoNotValidateOnNullValues()
   {
      UIContext ctx = new MockUIContext();
      MockValidationContext context = new MockValidationContext(ctx);
      withValidator.addValidator(new UIValidator()
      {
         @Override
         public void validate(UIValidationContext validator)
         {
            validator.addValidationError(withValidator, "MSG");
         }
      });
      withValidator.validate(context);
      List<String> errors = context.getErrorsFor(withValidator);
      Assert.assertThat(errors, nullValue());
   }
View Full Code Here

   @Test
   public void testRequiredAndAdditionalValidator()
   {
      UIContext ctx = new MockUIContext();
      MockValidationContext context = new MockValidationContext(ctx);
      requiredNoMessage.addValidator(new UIValidator()
      {
         @Override
         public void validate(UIValidationContext validator)
         {
            validator.addValidationError(withValidator, "MSG");
         }
      });
      requiredNoMessage.validate(context);
      List<String> errors = context.getErrorsFor(requiredNoMessage);
      Assert.assertThat(errors, notNullValue());
      Assert.assertThat(errors.size(), equalTo(1));
      Assert.assertThat(errors, hasItem(InputComponents.validateRequired(requiredNoMessage)));
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.ui.impl.mock.MockValidationContext

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.