本文整理汇总了Java中org.springframework.web.method.annotation.MethodArgumentTypeMismatchException类的典型用法代码示例。如果您正苦于以下问题:Java MethodArgumentTypeMismatchException类的具体用法?Java MethodArgumentTypeMismatchException怎么用?Java MethodArgumentTypeMismatchException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MethodArgumentTypeMismatchException类属于org.springframework.web.method.annotation包,在下文中一共展示了MethodArgumentTypeMismatchException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClientGenericBadRequest
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Client did not formulate a correct request.
* Log the exception message at warn level and stack trace as trace level.
* Return response status HttpStatus.BAD_REQUEST (400).
*/
@ExceptionHandler({
MissingServletRequestParameterException.class,
MethodArgumentTypeMismatchException.class,
InvalidStreamDefinitionException.class
})
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public VndErrors onClientGenericBadRequest(Exception e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}
示例2: handleMethodArgumentTypeMismatch
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
@ExceptionHandler({ MethodArgumentTypeMismatchException.class })
public ResponseEntity<Object> handleMethodArgumentTypeMismatch(final MethodArgumentTypeMismatchException ex, final WebRequest request) {
logger.info(ex.getClass().getName());
//
final String error = ex.getName() + " should be of type " + ex.getRequiredType().getName();
final AitException AitException = new AitException(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), error);
return new ResponseEntity<Object>(AitException, new HttpHeaders(), AitException.getStatus());
}
示例3: BaseExceptionHandler
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
public BaseExceptionHandler(final Logger log) {
this.log = log;
registerMapping(
MissingServletRequestParameterException.class,
"MISSING_PARAMETER",
"Missing request parameter",
BAD_REQUEST);
registerMapping(
MethodArgumentTypeMismatchException.class,
"ARGUMENT_TYPE_MISMATCH",
"Argument type mismatch",
BAD_REQUEST);
registerMapping(
HttpRequestMethodNotSupportedException.class,
"METHOD_NOT_SUPPORTED",
"HTTP method not supported",
METHOD_NOT_ALLOWED);
registerMapping(
ServletRequestBindingException.class,
"MISSING_HEADER",
"Missing header in request",
BAD_REQUEST);
}
示例4: testIllegalOfferId
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test illegal offer id.
*/
@Test
public void testIllegalOfferId() {
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.param("offer_id", "asdf")
.when()
.get(OFFERPHOTO_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例5: testIllegalRestaurantId
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test illegal restaurant id.
*/
@Test
public void testIllegalRestaurantId() {
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.param("restaurant_id", "asdf")
.when()
.get(OFFER_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例6: testIllegalLatitude
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test illegal latitude.
*/
@Test
public void testIllegalLatitude() {
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.param("radius", 0)
.param("longitude", -1)
.param("latitude", "asdf")
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例7: testIllegalLongitude
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test illegal longitude.
*/
@Test
public void testIllegalLongitude() {
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.param("radius", 0)
.param("longitude", "asdf")
.param("latitude", -1)
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例8: testIllegalRadius
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test illegal radius.
*/
@Test
public void testIllegalRadius() {
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.param("radius", "asdf")
.param("longitude", -1)
.param("latitude", -1)
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例9: tesLatitudeEmpty
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test empty latitude.
*/
@Test
public void tesLatitudeEmpty() {
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.param("radius", 0)
.param("longitude", -1)
.param("latitude", "")
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例10: testLongitudeEmpty
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test empty longitude.
*/
@Test
public void testLongitudeEmpty() {
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.param("radius", 0)
.param("longitude", "")
.param("latitude", -1)
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例11: testRadiusEmpty
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test empty radius.
*/
@Test
public void testRadiusEmpty() {
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.param("radius", "")
.param("longitude", -1)
.param("latitude", -1)
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例12: testIllegalLatitudeAuthorizedCall
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test illegal latitude.
*/
@Test
public void testIllegalLatitudeAuthorizedCall() {
User user = getUserWithUserTypeKunde();
userRepository.save(user);
String authString = user.getUsername() + ":" + user.getPasswordconfirm();
byte[] base64Encoded = Base64.getEncoder().encode(authString.getBytes());
String encodedString = new String(base64Encoded);
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.header("Authorization", "Basic " + encodedString)
.param("radius", 0)
.param("longitude", -1)
.param("latitude", "asdf")
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例13: testIllegalLongitudeAuthorizedCall
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test illegal longitude.
*/
@Test
public void testIllegalLongitudeAuthorizedCall() {
User user = getUserWithUserTypeKunde();
userRepository.save(user);
String authString = user.getUsername() + ":" + user.getPasswordconfirm();
byte[] base64Encoded = Base64.getEncoder().encode(authString.getBytes());
String encodedString = new String(base64Encoded);
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.header("Authorization", "Basic " + encodedString)
.param("radius", 0)
.param("longitude", "asdf")
.param("latitude", -1)
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例14: testIllegalRadiusAuthorizedCall
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test illegal radius.
*/
@Test
public void testIllegalRadiusAuthorizedCall() {
User user = getUserWithUserTypeKunde();
userRepository.save(user);
String authString = user.getUsername() + ":" + user.getPasswordconfirm();
byte[] base64Encoded = Base64.getEncoder().encode(authString.getBytes());
String encodedString = new String(base64Encoded);
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.header("Authorization", "Basic " + encodedString)
.param("radius", "asdf")
.param("longitude", -1)
.param("latitude", -1)
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
示例15: testLatitudeEmptyAuthorizedCall
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
* Test empty latitude.
*/
@Test
public void testLatitudeEmptyAuthorizedCall() {
User user = getUserWithUserTypeKunde();
userRepository.save(user);
String authString = user.getUsername() + ":" + user.getPasswordconfirm();
byte[] base64Encoded = Base64.getEncoder().encode(authString.getBytes());
String encodedString = new String(base64Encoded);
RestAssured
.registerParser("text/plain", Parser.TEXT);
RestAssured
.given()
.header("Authorization", "Basic " + encodedString)
.param("radius", 0)
.param("longitude", -1)
.param("latitude", "")
.when()
.get(RESTAURANT_API)
.then()
.statusCode(200)
.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}