@Test public void valid_cases() { EventValidator.checkEventName(repeat("a", 400)); EventValidator.checkEventName(null); EventValidator.checkEventCategory(repeat("a", 50)); EventValidator.checkEventCategory(null); EventValidator.checkEventDescription(repeat("a", 4000)); EventValidator.checkEventDescription(null); }
/** * The category of an event should not be null, but we must accept null values as the DB column is not nullable */ public EventDto setCategory(@Nullable String category) { this.category = checkEventCategory(category); return this; }
/** * The name of an event should not be null, but we must accept null values as the DB column is not nullable */ public EventDto setName(@Nullable String name) { this.name = checkEventName(name); return this; }
public EventDto setDescription(@Nullable String description) { this.description = checkEventDescription(description); return this; }
@Test public void fail_if_category_longer_than_50() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Event category length (51) is longer than the maximum authorized (50). 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' was provided."); EventValidator.checkEventCategory(repeat("a", 50 + 1)); }
@Test public void fail_if_name_longer_than_400() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Event name length (401) is longer than the maximum authorized (400)."); EventValidator.checkEventName(repeat("a", 400 + 1)); }
@Test public void fail_if_description_longer_than_4000() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Event description length (4001) is longer than the maximum authorized (4000)."); EventValidator.checkEventDescription(repeat("a", 4000 + 1)); } }
/** * The category of an event should not be null, but we must accept null values as the DB column is not nullable */ public EventDto setCategory(@Nullable String category) { this.category = checkEventCategory(category); return this; }
/** * The name of an event should not be null, but we must accept null values as the DB column is not nullable */ public EventDto setName(@Nullable String name) { this.name = checkEventName(name); return this; }
public EventDto setDescription(@Nullable String description) { this.description = checkEventDescription(description); return this; }