Skip to content

Commit

Permalink
Merge pull request #246 from weberhofer/fixed-assert-equals-order
Browse files Browse the repository at this point in the history
fixed order of actual and expected parameters in assertEquals()
  • Loading branch information
garydgregory authored Aug 1, 2024
2 parents 4a87127 + 8c2aa4e commit 2f044f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/test/java/org/apache/commons/validator/VarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,27 @@ public void testVars() {
// Get field 1
final Field field1 = form.getField("field-1");
assertNotNull(field1, "field-1 is null.");
assertEquals(field1.getProperty(), "field-1", "field-1 property is wrong");
assertEquals("field-1", field1.getProperty(), "field-1 property is wrong");

// Get var-1-1
final Var var11 = field1.getVar("var-1-1");
assertNotNull(var11, "var-1-1 is null.");
assertEquals(var11.getName(), "var-1-1", "var-1-1 name is wrong");
assertEquals(var11.getValue(), "value-1-1", "var-1-1 value is wrong");
assertEquals(var11.getJsType(), "jstype-1-1", "var-1-1 jstype is wrong");
assertEquals("var-1-1", var11.getName(), "var-1-1 name is wrong");
assertEquals("value-1-1", var11.getValue(), "var-1-1 value is wrong");
assertEquals("jstype-1-1", var11.getJsType(), "var-1-1 jstype is wrong");
assertFalse(var11.isResource(), "var-1-1 resource is true");
assertNull(var11.getBundle(), "var-1-1 bundle is not null.");

// Get field 2
final Field field2 = form.getField("field-2");
assertNotNull(field2, "field-2 is null.");
assertEquals(field2.getProperty(), "field-2", "field-2 property is wrong");
assertEquals("field-2", field2.getProperty(), "field-2 property is wrong");

// Get var-2-1
final Var var21 = field2.getVar("var-2-1");
assertNotNull(var21, "var-2-1 is null.");
assertEquals(var21.getName(), "var-2-1", "var-2-1 name is wrong");
assertEquals(var21.getValue(), "value-2-1", "var-2-1 value is wrong");
assertEquals("var-2-1", var21.getName(), "var-2-1 name is wrong");
assertEquals("value-2-1", var21.getValue(), "var-2-1 value is wrong");
assertEquals("jstype-2-1", var21.getJsType(), "var-2-1 jstype is wrong");
assertTrue(var21.isResource(), "var-2-1 resource is false");
assertEquals(var21.getBundle(), "bundle-2-1", "var-2-1 bundle is wrong");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,31 +108,31 @@ public void testMissingRegex() {
new RegexValidator((String) null);
fail("Single Null - expected IllegalArgumentException");
} catch (final IllegalArgumentException e) {
assertEquals(e.getMessage(), "Regular expression[0] is missing", "Single Null");
assertEquals("Regular expression[0] is missing", e.getMessage(), "Single Null");
}

// Single Regular Expression - Zero Length
try {
new RegexValidator("");
fail("Single Zero Length - expected IllegalArgumentException");
} catch (final IllegalArgumentException e) {
assertEquals(e.getMessage(), "Regular expression[0] is missing", "Single Zero Length");
assertEquals("Regular expression[0] is missing", e.getMessage(), "Single Zero Length");
}

// Multiple Regular Expression - Null array
try {
new RegexValidator((String[]) null);
fail("Null Array - expected IllegalArgumentException");
} catch (final IllegalArgumentException e) {
assertEquals(e.getMessage(), "Regular expressions are missing", "Null Array");
assertEquals("Regular expressions are missing", e.getMessage(), "Null Array");
}

// Multiple Regular Expression - Zero Length array
try {
new RegexValidator();
fail("Zero Length Array - expected IllegalArgumentException");
} catch (final IllegalArgumentException e) {
assertEquals(e.getMessage(), "Regular expressions are missing", "Zero Length Array");
assertEquals("Regular expressions are missing", e.getMessage(), "Zero Length Array");
}

// Multiple Regular Expression - Array has Null
Expand All @@ -141,7 +141,7 @@ public void testMissingRegex() {
new RegexValidator(expressions);
fail("Array has Null - expected IllegalArgumentException");
} catch (final IllegalArgumentException e) {
assertEquals(e.getMessage(), "Regular expression[1] is missing", "Array has Null");
assertEquals("Regular expression[1] is missing", e.getMessage(), "Array has Null");
}

// Multiple Regular Expression - Array has Zero Length
Expand All @@ -150,7 +150,7 @@ public void testMissingRegex() {
new RegexValidator(expressions);
fail("Array has Zero Length - expected IllegalArgumentException");
} catch (final IllegalArgumentException e) {
assertEquals(e.getMessage(), "Regular expression[0] is missing", "Array has Zero Length");
assertEquals("Regular expression[0] is missing", e.getMessage(), "Array has Zero Length");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,9 @@ public void testFormat() {

final Object test = TimeValidator.getInstance().validate("16:49:23", "HH:mm:ss");
assertNotNull(test, "Test Date ");
assertEquals(validator.format(test, "HH-mm-ss"), "16-49-23", "Format pattern");
assertEquals(validator.format(test, Locale.US), "4:49 PM", "Format locale");
assertEquals(validator.format(test), "16:49", "Format default");

assertEquals("16-49-23", validator.format(test, "HH-mm-ss"), "Format pattern");
assertEquals("4:49 PM", validator.format(test, Locale.US), "Format locale");
assertEquals("16:49", validator.format(test), "Format default");
}

/**
Expand Down

0 comments on commit 2f044f8

Please sign in to comment.