/** * Ensure a property doesn't occur in the specified list. * @param propertyName the name of a property * @param properties a list of properties * @throws ValidationException thrown when the specified property * is found in the list of properties */ public void assertNone(final String propertyName, final PropertyList properties) throws ValidationException { if (properties.getProperty(propertyName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {propertyName}); } }
@Stateless @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public class ExampleRepositoryDelegate { @EJB private ExampleRepository repository; public void add(MyEntity me) { try { repository.add(me); } catch (ValidationException e) { e.printStackTrace(); } } }
/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertNone(String componentName, ComponentList<?> components) throws ValidationException { if (components.getComponent(componentName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {componentName}); } }
private void saveAddressBook(String fullName) { try { PrintWriter out = new PrintWriter("filename.txt"); out.println(fullName); out.close(); } catch(ValidationException e) { e.printStackTrace(); } }
/** * Ensure a property doesn't occur in the specified list. * @param propertyName the name of a property * @param properties a list of properties * @throws ValidationException thrown when the specified property * is found in the list of properties */ public void assertNone(final String propertyName, final PropertyList properties) throws ValidationException { if (properties.getProperty(propertyName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {propertyName}); } }
/** * */ public final void testValidationException() { try { property.validate(); fail("Should throw ValidationException"); } catch (ValidationException e) { e.printStackTrace(); } }
/** * Ensure a parameter doesn't occur in the specified list. * @param paramName the name of a parameter * @param parameters a list of parameters * @throws ValidationException thrown when the specified property * is found in the list of properties */ public void assertNone(final String paramName, final ParameterList parameters) throws ValidationException { if (parameters.getParameter(paramName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {paramName}); } }
@Test public void shouldCorrectCalendarBody() throws IOException, ParserException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { String[] calendarNames = { "yahoo1.txt", "yahoo2.txt", "outlook1.txt", "outlook2.txt", "apple.txt" }; for (String calendarName : calendarNames) { Calendar calendar = buildCalendar(calendarName); calendar = transformer.transform(calendar); try { calendar.validate(); } catch (ValidationException e) { e.printStackTrace(); fail("Validation failed for " + calendarName); } } }
/** * Ensure a property doesn't occur in the specified list. * @param propertyName the name of a property * @param properties a list of properties * @throws ValidationException thrown when the specified property * is found in the list of properties */ public void assertNone(final String propertyName, final PropertyList properties) throws ValidationException { if (properties.getProperty(propertyName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {propertyName}); } }
/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertNone(String componentName, ComponentList<?> components) throws ValidationException { if (components.getComponent(componentName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {componentName}); } }
/** * Ensure a parameter doesn't occur in the specified list. * @param paramName the name of a parameter * @param parameters a list of parameters * @throws ValidationException thrown when the specified property * is found in the list of properties */ public void assertNone(final String paramName, final ParameterList parameters) throws ValidationException { if (parameters.getParameter(paramName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {paramName}); } }
/** * Ensure a parameter doesn't occur in the specified list. * @param paramName the name of a parameter * @param parameters a list of parameters * @throws ValidationException thrown when the specified property * is found in the list of properties */ public void assertNone(final String paramName, final ParameterList parameters) throws ValidationException { if (parameters.getParameter(paramName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {paramName}); } }
/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertNone(String componentName, ComponentList<?> components) throws ValidationException { if (components.getComponent(componentName) != null) { throw new ValidationException(ASSERT_NONE_MESSAGE, new Object[] {componentName}); } }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { if (percentage < 0 || percentage > 100) { throw new ValidationException(getName() + " with invalid value: " + percentage); } }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { if (percentage < 0 || percentage > 100) { throw new ValidationException(getName() + " with invalid value: " + percentage); } }
public void validate() throws ValidationException { throw new ValidationException(); } };
/** * {@inheritDoc} */ public final void validate() throws ValidationException { if (percentage < 0 || percentage > 100) { throw new ValidationException(getName() + " with invalid value: " + percentage); } }
/** * @throws ValidationException where the parameter list is not empty */ protected final void assertParametersEmpty() throws ValidationException { if (!getParameters().isEmpty()) { throw new ValidationException("No parameters allowed for property: " + id); } }
/** * @param propertyId * @throws ValidationException */ private void assertOne(final Property.Id propertyId) throws ValidationException { final List<Property> properties = getProperties(propertyId); if (properties.size() != 1) { throw new ValidationException("Property [" + propertyId + "] must be specified once"); } }
/** * @throws ValidationException where the parameter list is not empty */ protected final void assertParametersEmpty() throws ValidationException { if (!getParameters().isEmpty()) { throw new ValidationException("No parameters allowed for property: " + id); } }