1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Car car = new Car(null, "A", 1, 400.123456, BigDecimal.valueOf(200000 ) ); String message = validator.validateProperty(car, "manufacturer" ) .iterator() .next() .getMessage(); assertEquals("must not be null", message ); message = validator.validateProperty(car, "licensePlate" ) .iterator() .next() .getMessage(); assertEquals( "The license plate 'A' must be between 2 and 14 characters long", message ); message = validator.validateProperty(car, "seatCount" ).iterator().next().getMessage(); assertEquals("There must be at least 2 seats", message ); message = validator.validateProperty(car, "topSpeed" ).iterator().next().getMessage(); assertEquals("The top speed 400.12 is higher than 350", message ); message = validator.validateProperty(car, "price" ).iterator().next().getMessage(); assertEquals("Price must not be higher than $100000", message );
|