Java Code Examples for javax.faces.validator.ValidatorException

The following are top voted examples for showing how to use javax.faces.validator.ValidatorException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: oscm   File: UrlValidator.java   View source code 6 votes vote down vote up
/**
 * Validates that the given value is an URL
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.length() == 0) {
        return;
    }

    if (ADMValidator.isUrl(str)) {
        return;
    }
    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    if (label != null) {
        args = new Object[] { label };
    }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.URL, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
Example 2
Project: oscm   File: CssValueValidator.java   View source code 6 votes vote down vote up
/**
 * Validates that the given value doesn't contain a '{', '}' or "/*".
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.indexOf('{') < 0 && str.indexOf('}') < 0
            && str.indexOf("/*") < 0) {
        return;
    }
    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    // if (label != null) {
    // args = new Object[] { label, str };
    // } else {
    // args = new Object[] { "", str };
    // }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.CSS_VALUE, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
Example 3
Project: oscm   File: LongValidator.java   View source code 6 votes vote down vote up
private static void validate(FacesContext context, UIComponent uiComponent,
        String value) throws ValidatorException {
    Long minValue = getMinValue(uiComponent);
    Long maxValue = getMaxValue(uiComponent);
    long parsedLong = parse(context, value, minValue, maxValue);
    if (!isInRange(parsedLong, minValue, maxValue)) {
        minValue = (minValue != null ? minValue : Long
                .valueOf(Long.MIN_VALUE));
        maxValue = (maxValue != null ? maxValue : Long
                .valueOf(Long.MAX_VALUE));
        String message = JSFUtils.getText(
                BaseBean.ERROR_LONG_VALUE_OUT_OF_RANGE,
                new String[] { String.valueOf(minValue),
                        String.valueOf(maxValue) }, context);
        throw getException(message);
    }
}
 
Example 4
Project: oscm   File: LongValidator.java   View source code 6 votes vote down vote up
/**
 * Parses the specified string into a long integer.
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to parse
 * @throws ValidatorException
 *             if the specified string could not be parsed into a valid long
 *             integer.
 */
public static long parse(FacesContext context, UIComponent uiComponent,
        String value) throws ValidatorException {
    if (!GenericValidator.isLong(value)) {
        Object[] args = null;
        String label = JSFUtils.getLabel(uiComponent);
        if (label != null) {
            args = new Object[] { label };
        }
        ValidationException e = new ValidationException(
                ValidationException.ReasonEnum.LONG, label, null);
        String message = JSFUtils.getText(e.getMessageKey(), args, context);
        throw getException(message);
    }
    return Long.parseLong(value);
}
 
Example 5
Project: myfaces-trinidad   File: LongRangeValidatorTest.java   View source code 6 votes vote down vote up
public void testWrongType()
{
  // since the pattern has not been set it will be null
  // let us push some arbitary value
  Mock mock = mock(UIComponent.class); 
  UIComponent component = (UIComponent) mock.proxy();
  MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
  setMockLabelForComponent(wrapper);

  try
  {
    LongRangeValidator validator = new LongRangeValidator();
    validator.setMaximum(2);
    validator.validate(facesContext, component, "thisShouldFail");
    // test fails if it is here

    fail("Expected Null pointer exception");
  }
  catch (ValidatorException ve)
  {
    // suppress it - this is as expected
  }
  mock.verify();
}
 
Example 6
Project: oscm   File: SupportedLanguageValidator.java   View source code 6 votes vote down vote up
@Override
public void validate(FacesContext context, UIComponent uiComponent,
        Object input) throws ValidatorException {
    String value = null;
    if (input != null) {
        value = input.toString();
    }
    if (value == null || value.length() == 0) {
        return;
    }
    if (!getApplicationBean().getActiveLocales().contains(value)) {
        ValidatorException e = getException(JSFUtils.getText(
                BaseBean.ERROR_LOCALE_INVALID, new String[] { new Locale(
                        value).getDisplayLanguage(ui.getViewLocale()) },
                context));
        throw e;
    }
}
 
Example 7
Project: myfaces-trinidad   File: DateTimeRangeValidator.java   View source code 6 votes vote down vote up
@Override
public void validate(
  FacesContext context,
  UIComponent  component,
  Object       value) throws ValidatorException
{
  if (value == null)
    return;
  
  if (!(value instanceof Date))
  {
    GenericConverterFactory fac = GenericConverterFactory.getCurrentInstance();
    value = fac.convert(value, Date.class);
  }
  super.validate(context, component, value);
}
 
Example 8
Project: myfaces-trinidad   File: LengthValidatorTest.java   View source code 6 votes vote down vote up
public void testTooLargeLength()
{
  // since the pattern has not been set it will be null
  // let us push some arbitary value
  Mock mock = mock(UIComponent.class); 
  UIComponent component = (UIComponent) mock.proxy();
  MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
  setMockLabelForComponent(wrapper);

  try
  {
    LengthValidator validator = new LengthValidator();
    validator.setMaximum(2);
    validator.validate(facesContext, component, "someValue");
    // test fails if it is here

    fail("Expected Null pointer exception");
  }
  catch (ValidatorException ve)
  {
    // suppress it - this is as expected
  }
  mock.verify();
}
 
Example 9
Project: myfaces-trinidad   File: DoubleRangeValidatorTest.java   View source code 6 votes vote down vote up
public void testExactFailure()
{
  // some very basic sanity test
  Mock mock = buildMockUIComponent();
  UIComponent component = (UIComponent) mock.proxy();
  MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
  setMockLabelForComponent(wrapper);

  try
  {
    DoubleRangeValidator validator = new DoubleRangeValidator();
    double value = 20d;
    validator.setMinimum(2);
    validator.setMaximum(2);
    validator.validate(facesContext, component, value);
    fail("Expected ValidatorException for exact");
  }
  catch (ValidatorException ve)
  {
    // if exception then fine.
  }

  mock.verify();
}
 
Example 10
Project: myfaces-trinidad   File: DateTimeRangeValidatorTest.java   View source code 6 votes vote down vote up
/**
 * Tests that dates within the date range are valid.
 *
 * @throws ValidatorException  when test fails
 */
public void testWithinDateRange() throws ValidatorException
{
  long millis = System.currentTimeMillis();
  DateTimeRangeValidator validator = new DateTimeRangeValidator();
  validator.setMinimum(new Date(millis));
  validator.setMaximum(new Date(millis + 2));

  Mock mock = buildMockUIComponent();
  UIComponent component = (UIComponent) mock.proxy();

  try
  {
    setFacesContext(facesContext);
    validator.validate(facesContext, component, new Date(millis + 1));
  }
  finally
  {
    setFacesContext(null);
  }

  mock.verify();
}
 
Example 11
Project: myfaces-trinidad   File: LongRangeValidatorTest.java   View source code 6 votes vote down vote up
public void testTooLarge()
{
  // since the pattern has not been set it will be null
  // let us push some arbitary value
  Mock mock = mock(UIComponent.class); 
  UIComponent component = (UIComponent) mock.proxy();
  MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
  setMockLabelForComponent(wrapper);

  try
  {
    LongRangeValidator validator = new LongRangeValidator();
    validator.setMaximum(100);
    validator.validate(facesContext, component, 1000);
    // test fails if it is here

    fail("Expected Null pointer exception");
  }
  catch (ValidatorException ve)
  {
    // suppress it - this is as expected
  }
  mock.verify();
}
 
Example 12
Project: myfaces-trinidad   File: DateTimeRangeValidatorTest.java   View source code 6 votes vote down vote up
/**
 * Tests that dates before the maximum date are valid.
 *
 * @throws ValidatorException  when test fails
 */
public void testBeforeMaximumDate() throws ValidatorException
{
  long millis = System.currentTimeMillis();
  DateTimeRangeValidator validator = new DateTimeRangeValidator();
  validator.setMaximum(new Date(millis));

  Mock mock = buildMockUIComponent();
  UIComponent component = (UIComponent) mock.proxy();

  try
  {
    setFacesContext(facesContext);
    validator.validate(facesContext, component, new Date(millis - 1));
  }
  finally
  {
    setFacesContext(null);
  }
  mock.verify();
}
 
Example 13
Project: oscm   File: ConfigurationSettingsValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidate_String_Mandatory_TypeBoolean_Null() {
    // given
    UIComponentStub stub = getComponent(ConfigurationKey.TYPE_BOOLEAN,
            true, null, null);

    // when
    validator.validate(context, stub, null);
}
 
Example 14
Project: oscm   File: ConfigurationSettingsValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidate_String_Mandatory_TypeLong_Null() {
    // given
    UIComponentStub stub = getComponent(ConfigurationKey.TYPE_LONG, true,
            null, null);

    // when
    validator.validate(context, stub, null);
}
 
Example 15
Project: oscm   File: DateFromToValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidateNullParameters() throws Exception {
    validator.validate(fcStub, fromDateStub, null);

    validator.validate(fcStub, toDateStub, null);
    DateFromToValidator spy = spy(validator);
    doNothing().when(spy).handleError(Matchers.any(FacesContext.class),
            Matchers.anyString(), Matchers.anyString());
}
 
Example 16
Project: oscm   File: CaptchaValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void validateCaptcha_emptyInput() {
    // given
    setCaptcha("0815");
    inputField.setValue("");
    // when
    try {
        validator.validate(context, inputField, inputField.getValue());
    } finally {
        // then
        assertEquals(false, getCaptchaInputStatus());
        assertEquals(true, isInputCleared());
    }
}
 
Example 17
Project: oscm   File: LanguageISOCodeValidator.java   View source code 5 votes vote down vote up
private void addMessage(String languageISOCode, FacesContext facesContext,
        String key) {
    String text = JSFUtils.getText(key, new String[] { languageISOCode },
            facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
Example 18
Project: oscm   File: BillingBeanTest.java   View source code 5 votes vote down vote up
@Test
public void validateFromAndToDate_ValidatorException() {
    // given
    context = mock(FacesContext.class);
    toValidate = mock(UIComponent.class);
    value = mock(Object.class);
    ValidatorException ex = mock(ValidatorException.class);
    doThrow(ex).when(validator).validate(any(FacesContext.class),
            any(UIComponent.class), any(Object.class));
    // when
    bean.validateFromAndToDate(context, toValidate, value);
    // then
    verify(context, times(1)).addMessage(anyString(),
            any(FacesMessage.class));
}
 
Example 19
Project: oscm   File: ConfigurationSettingsValidator.java   View source code 5 votes vote down vote up
/**
 * Validates that the given value corresponding to the configuration key
 * type.
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext context, UIComponent uiComponent,
        Object input) throws ValidatorException {
    String datatype = getDataType(uiComponent);
    boolean mandatory = isRequired(uiComponent);
    String value = null;
    if (input != null) {
        value = input.toString().trim();
    }
    if (value == null || value.length() == 0) {
        if (mandatory) {
            ValidatorException e = getException(JSFUtils.getText(
                    BaseBean.ERROR_PARAMETER_VALUE_MANDATORY,
                    new String[] { JSFUtils.getLabel(uiComponent) },
                    context));
            throw e;
        } else {
            return;
        }
    }
    if (ConfigurationKey.TYPE_LONG.equals(datatype)) {
        validateLength(context, value, ADMValidator.LENGTH_DESCRIPTION);
        validateLong(context, uiComponent, value);
    } else if (ConfigurationKey.TYPE_URL.equals(datatype)) {
        validateLength(context, value, ADMValidator.LENGTH_DESCRIPTION);
        validateUrl(context, uiComponent, value);
    } else if (ConfigurationKey.TYPE_MAIL.equals(datatype)) {
        // the server also allows only 100 chars for email
        validateLength(context, value, ADMValidator.LENGTH_NAME);
        validateMail(context, uiComponent, value);
    } else if (ConfigurationKey.TYPE_BOOLEAN.equals(datatype)) {
        validateBoolean(context, uiComponent, value);
        // no need to validate length
    } else {
        validateLength(context, value, ADMValidator.LENGTH_DESCRIPTION);
    }
}
 
Example 20
Project: oscm   File: PasswordValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidateEmpty() throws ValidatorException {
    try {
        validator.validate(fcStub, ucStub2, "");
    } catch (ValidatorException e) {
        assertEquals("Wrong exception type - ",
                BaseBean.ERROR_USER_PWD_MATCH, requestedResourceKey);
        throw e;
    }
}
 
Example 21
Project: oscm   File: LdapUserValidator.java   View source code 5 votes vote down vote up
@Override
public void validate(FacesContext context, UIComponent component,
        Object valueToValidate) throws ValidatorException {

    if (valueToValidate == null) {
        return;
    }

    UserManagementService service = srvLocator
            .findService(UserManagementService.class);

    String organizationId;
    try {
        organizationId = retrieveOrganizationId(valueToValidate);
        if (service.isOrganizationLDAPManaged(organizationId)) {
            ValidationException e = new ValidationException(
                    ValidationException.ReasonEnum.LDAP_USER_ID, null, null);
            String text = JSFUtils
                    .getText(e.getMessageKey(), null, context);
            throw new ValidatorException(new FacesMessage(
                    FacesMessage.SEVERITY_ERROR, text, null));
        }
    } catch (ObjectNotFoundException | OperationNotPermittedException
            | OrganizationRemovedException e1) {
        return;
    }
}
 
Example 22
Project: oscm   File: DateFromToValidator.java   View source code 5 votes vote down vote up
protected void handleError(final FacesContext facesContext,
        @SuppressWarnings("unused") final String clientid,
        final String msgKey) throws ValidatorException {
    String text = JSFUtils.getText(msgKey, null, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
Example 23
Project: oscm   File: RelUrlValidator.java   View source code 5 votes vote down vote up
/**
 * Validates that the given value is a relative URL
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.length() == 0) {
        return;
    }

    // a relative URL must start with a "/"
    if (str.startsWith("/")) {
        // create a absolute URL to check all the other URL rules
        str = "http://xy".concat(str);
        if (ADMValidator.isUrl(str)) {
            return;
        }
    }

    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    if (label != null) {
        args = new Object[] { label };
    }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.RELATIVE_URL, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
Example 24
Project: myfaces-trinidad   File: LongRangeValidatorTest.java   View source code 5 votes vote down vote up
/**
 * Tests that null returns immediately.
 *
 * @throws ValidatorException  when test fails
 */
public void testNull() throws ValidatorException
{
  Mock mock = buildMockUIComponent();
  UIComponent component = (UIComponent) mock.proxy();
  MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
  LongRangeValidator validator = new LongRangeValidator();

  doTestNull(facesContext, wrapper, validator);
}
 
Example 25
Project: myfaces-trinidad   File: ValidatorTestCase.java   View source code 5 votes vote down vote up
/**
 * Test the validate action on validators.
 * @param validator validator on which validate action is to be tested
 * @param context MockFaces context
 * @param component MockFaces component
 * @throws javax.faces.validator.ValidatorException
 */
protected void doTestValidate(
  Validator validator,
  MockFacesContext context,
  MockUIComponentWrapper wrapper,
  Object value
  )  throws ValidatorException
{
  validator.validate(context, wrapper.getUIComponent(), value );
  wrapper.getMock().verify();
}
 
Example 26
Project: oscm   File: PasswordValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidateFirstParameterEmptyString() throws Exception {
    ucStub.setValue("");
    try {
        validator.validate(fcStub, ucStub, "");
    } catch (ValidatorException e) {
        assertEquals("Wrong exception type - ",
                BaseBean.ERROR_USER_PWD_LENGTH, requestedResourceKey);
        throw e;
    }
}
 
Example 27
Project: myfaces-trinidad   File: DateTimeRangeValidatorTest.java   View source code 5 votes vote down vote up
/**
 * Tests that dates before the date range cause a ValidationException.
 */
public void testBeforeDateRange()
{
  long millis = System.currentTimeMillis();
  DateTimeRangeValidator validator = new DateTimeRangeValidator();
  validator.setMinimum(new Date(millis));
  validator.setMaximum(new Date(millis + 10));

  Mock mock = buildMockUIComponent();
  UIComponent component = (UIComponent) mock.proxy();
  MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
  setMockLabelForComponent(wrapper);

  setMockCreateConverter(application);

  try
  {
    setFacesContext(facesContext);
    validator.setMessageDetailMinimum("min");
    validator.validate(facesContext, component, new Date(millis - 1));
    fail("ValidatorException not thrown");
  }
  catch (ValidatorException e)
  {
    // pass

  }
  finally
  {
    setFacesContext(null);
  }

  mock.verify();
}
 
Example 28
Project: myfaces-trinidad   File: DateTimeRangeValidatorTest.java   View source code 5 votes vote down vote up
/**
 * Tests that dates after the minimum date are valid.
 *
 * @throws ValidatorException  when test fails
 */
public void testAfterMinimumDate() throws ValidatorException
{
  long millis = System.currentTimeMillis();
  DateTimeRangeValidator validator = new DateTimeRangeValidator();
  validator.setMinimum(new Date(millis));

  Mock mock = buildMockUIComponent();
  UIComponent component = (UIComponent) mock.proxy();

  validator.validate(facesContext, component, new Date(millis + 1));

  mock.verify();
}
 
Example 29
Project: myfaces-trinidad   File: ValidatorTestCase.java   View source code 5 votes vote down vote up
/**
 * Tests that null returns immediately.
 *
 * @throws ValidatorException  when test fails
 */
protected void doTestNull(
  MockFacesContext context,
  MockUIComponentWrapper wrapper,
  Validator validator
  ) throws ValidatorException
{
  validator.validate(context, wrapper.getUIComponent(), null);

  wrapper.getMock().verify();
}
 
Example 30
Project: oscm   File: ConfigurationSettingsValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidate_String_Mandatory_TypeString_Null() {
    // given
    UIComponentStub stub = getComponent(ConfigurationKey.TYPE_STRING, true,
            null, null);

    // when
    validator.validate(context, stub, null);
}
 
Example 31
Project: oscm   File: ConfigurationSettingsValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidate_String_Mandatory_TypeMail_Null() {
    // given
    UIComponentStub stub = getComponent(ConfigurationKey.TYPE_MAIL, true,
            null, null);

    // when
    validator.validate(context, stub, null);
}
 
Example 32
Project: oscm   File: ParameterValueValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidateStringTooLong() {
    UIComponentStub stub = getComponent(DATATYPE_STRING, false, null, null);
    StringBuilder value = new StringBuilder();
    for (int i = 0; i < 500; i++) {
        value.append("a");
    }
    validator.validate(context, stub, value.toString());
}
 
Example 33
Project: myfaces-trinidad   File: DateTimeRangeValidatorTest.java   View source code 5 votes vote down vote up
/**
 * Tests that dates after the maximum date cause a ValidationException.
 */
public void testAfterMaximumDate()
{
  long millis = System.currentTimeMillis();
  DateTimeRangeValidator validator = new DateTimeRangeValidator();
  validator.setMaximum(new Date(millis));

  Mock mock = buildMockUIComponent();
  UIComponent component = (UIComponent) mock.proxy();
  MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
  setMockLabelForComponent(wrapper);

  setMockCreateConverter(application);
  try
  {
    setFacesContext(facesContext);
    validator.setMessageDetailMaximum("max set");
    validator.validate(facesContext, component, new Date(millis + 1));
    fail("ValidatorException not thrown");
  }
  catch (ValidatorException e)
  {
    // pass
    String msg = e.getFacesMessage().getDetail();
    assertEquals(msg, "max set");
  }
  finally
  {
    setFacesContext(null);
  }

  mock.verify();
}
 
Example 34
Project: oscm   File: PasswordValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidateFirstParameterNullShort() throws Exception {
    ucStub2.setValue(null);
    try {
        validator.validate(fcStub, ucStub, "bla");
    } catch (ValidatorException e) {
        assertEquals("Wrong exception type - ",
                BaseBean.ERROR_USER_PWD_LENGTH, requestedResourceKey);
        throw e;
    }
}
 
Example 35
Project: oscm   File: ParameterValueValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidateDurationTooLongNumber() {
    UIComponentStub stub = getComponent(DATATYPE_DURATION, false, null,
            null);
    char[] nines = new char[256];
    Arrays.fill(nines, '9');
    validator.validate(context, stub, new String(nines));
}
 
Example 36
Project: oscm   File: ConfigurationSettingsValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidate_String_Mandatory_TypeBoolean_Empty() {
    // given
    UIComponentStub stub = getComponent(ConfigurationKey.TYPE_BOOLEAN,
            true, null, null);

    // when
    validator.validate(context, stub, "");
}
 
Example 37
Project: oscm   File: TenantValidatorTest.java   View source code 5 votes vote down vote up
@Test(expected = ValidatorException.class)
public void testValidateWithNotExistingTenant() throws Exception {

    // given
    long tenantKey = 12111;
    when(tenantService.getTenantByKey(tenantKey))
            .thenThrow(new ObjectNotFoundException());

    // when
    tenantValidator.validate(context, component, tenantKey);

    // then
    verify(tenantService, times(1)).getTenantByKey(anyLong());
}
 
Example 38
Project: oscm   File: TranslationBeanTest.java   View source code 4 votes vote down vote up
@Test
public void validateImprint_Null() throws ValidatorException {
    tb.validateImprint(context, component, null);
}
 
Example 39
Project: oscm   File: IdValidatorTest.java   View source code 4 votes vote down vote up
@Test
public void testValidate() throws ValidatorException {
    validator.validate(context, component, "some_valid_id");
}
 
Example 40
Project: oscm   File: TranslationBeanTest.java   View source code 4 votes vote down vote up
@Test
public void validateImprint_html() throws ValidatorException {
    // see [5157]
    tb.validateImprint(context, component,
            "http://estbesrh4:8090/smartdocs/crm.html");
}