Skip to content

Commit

Permalink
Merge pull request #431 from terasolunaorg/issues/430_typo-at-compare…
Browse files Browse the repository at this point in the history
…-annotation

Correct typo, and improve validation message #430
  • Loading branch information
ikeyat committed Dec 3, 2015
2 parents 311ba08 + 82ef16a commit d44f664
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ enum Operator {
EQUAL(CompareStrategy.EQ),

/**
* Left side object must be grater than Right side object.
* Left side object must be greater than Right side object.
*/
GRATER_THAN(CompareStrategy.GT),
GREATER_THAN(CompareStrategy.GT),

/**
* Left side object must be grater than or equal Right side object.
* Left side object must be greater than or equal Right side object.
*/
GRATER_THAN_OR_EQUAL(CompareStrategy.EQ, CompareStrategy.GT);
GREATER_THAN_OR_EQUAL(CompareStrategy.EQ, CompareStrategy.GT);

/**
* strategies to assert result of {@code Comparable#compareTo(Object)} as the expected.
Expand Down Expand Up @@ -181,7 +181,7 @@ protected boolean isExpected(int comparisonResult) {
},

/**
* Expected grater than ZERO.
* Expected greater than ZERO.
*/
GT {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class ByteMaxTest extends AbstractConstraintsTest<ByteMaxTestForm> {

private static final String MESSAGE_VALIDATION_ERROR = "must be under %d Bytes";
private static final String MESSAGE_VALIDATION_ERROR = "must be less than or equal to %d Bytes";

@Before
public void before() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class ByteMinTest extends AbstractConstraintsTest<ByteMinTestForm> {

private static final String MESSAGE_VALIDATION_ERROR = "must be over %d Bytes";
private static final String MESSAGE_VALIDATION_ERROR = "must be greater than or equal to %d Bytes";

@Before
public void before() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ public void testSpecifyOperatorEqual() throws Throwable {
* @throws Throwable
*/
@Test
public void testSpecifyOperatorGraterThan() throws Throwable {
public void testSpecifyOperatorGreaterThan() throws Throwable {

{
form.setLeft(99);
form.setRight(100);

violations = validator.validate(form, GraterThan.class);
violations = validator.validate(form, GreaterThan.class);
assertThat(violations.size(), is(1));
assertThat(violations.iterator().next().getMessage(), is(String
.format(MESSAGE_VALIDATION_ERROR, "left", "right")));
Expand All @@ -227,7 +227,7 @@ public void testSpecifyOperatorGraterThan() throws Throwable {
form.setLeft(100);
form.setRight(100);

violations = validator.validate(form, GraterThan.class);
violations = validator.validate(form, GreaterThan.class);
assertThat(violations.size(), is(1));
assertThat(violations.iterator().next().getMessage(), is(String
.format(MESSAGE_VALIDATION_ERROR, "left", "right")));
Expand All @@ -237,7 +237,7 @@ public void testSpecifyOperatorGraterThan() throws Throwable {
form.setLeft(101);
form.setRight(100);

violations = validator.validate(form, GraterThan.class);
violations = validator.validate(form, GreaterThan.class);
assertThat(violations.size(), is(0));
}
}
Expand All @@ -247,13 +247,13 @@ public void testSpecifyOperatorGraterThan() throws Throwable {
* @throws Throwable
*/
@Test
public void testSpecifyOperatorGraterThanOrEqual() throws Throwable {
public void testSpecifyOperatorGreaterThanOrEqual() throws Throwable {

{
form.setLeft(99);
form.setRight(100);

violations = validator.validate(form, GraterThanOrEqual.class);
violations = validator.validate(form, GreaterThanOrEqual.class);
assertThat(violations.size(), is(1));
assertThat(violations.iterator().next().getMessage(), is(String
.format(MESSAGE_VALIDATION_ERROR, "left", "right")));
Expand All @@ -263,15 +263,15 @@ public void testSpecifyOperatorGraterThanOrEqual() throws Throwable {
form.setLeft(100);
form.setRight(100);

violations = validator.validate(form, GraterThanOrEqual.class);
violations = validator.validate(form, GreaterThanOrEqual.class);
assertThat(violations.size(), is(0));
}

{
form.setLeft(101);
form.setRight(100);

violations = validator.validate(form, GraterThanOrEqual.class);
violations = validator.validate(form, GreaterThanOrEqual.class);
assertThat(violations.size(), is(0));
}
}
Expand Down Expand Up @@ -475,15 +475,15 @@ private static interface LessThan {
};

/**
* Validation group operator grater than.
* Validation group operator greater than.
*/
private static interface GraterThan {
private static interface GreaterThan {
};

/**
* Validation group operator grater than or equal.
* Validation group operator greater than or equal.
*/
private static interface GraterThanOrEqual {
private static interface GreaterThanOrEqual {
};

/**
Expand Down Expand Up @@ -536,8 +536,8 @@ private static interface NotComparableLeft {

@Compare.List({
@Compare(left = "left", right = "right", operator = Operator.EQUAL),
@Compare(left = "left", right = "right", operator = Operator.GRATER_THAN_OR_EQUAL, groups = { GraterThanOrEqual.class }),
@Compare(left = "left", right = "right", operator = Operator.GRATER_THAN, groups = { GraterThan.class }),
@Compare(left = "left", right = "right", operator = Operator.GREATER_THAN_OR_EQUAL, groups = { GreaterThanOrEqual.class }),
@Compare(left = "left", right = "right", operator = Operator.GREATER_THAN, groups = { GreaterThan.class }),
@Compare(left = "left", right = "right", operator = Operator.LESS_THAN_OR_EQUAL, groups = { LessThanOrEqual.class }),
@Compare(left = "left", right = "right", operator = Operator.LESS_THAN, groups = { LessThan.class }),
@Compare(left = "left", right = "right", operator = Operator.EQUAL, requireBoth = true, groups = { RequireBoth.class }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this file contains the default messages of JSR 303 bean validation for validations provided in the common library

org.terasoluna.gfw.common.validator.constraints.ByteMin.message = must be over {value} Bytes
org.terasoluna.gfw.common.validator.constraints.ByteMax.message = must be under {value} Bytes
org.terasoluna.gfw.common.validator.constraints.ByteMin.message = must be greater than or equal to {value} Bytes
org.terasoluna.gfw.common.validator.constraints.ByteMax.message = must be less than or equal to {value} Bytes
org.terasoluna.gfw.common.validator.constraints.Compare.message = not match '{left}' and '{right}'

0 comments on commit d44f664

Please sign in to comment.