本文整理汇总了Java中org.zalando.problem.validation.ConstraintViolationProblemModule类的典型用法代码示例。如果您正苦于以下问题:Java ConstraintViolationProblemModule类的具体用法?Java ConstraintViolationProblemModule怎么用?Java ConstraintViolationProblemModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstraintViolationProblemModule类属于org.zalando.problem.validation包,在下文中一共展示了ConstraintViolationProblemModule类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldSerializeWithoutAutoDetect
import org.zalando.problem.validation.ConstraintViolationProblemModule; //导入依赖的package包/类
@Test
void shouldSerializeWithoutAutoDetect() throws JsonProcessingException {
final ObjectMapper mapper = new ObjectMapper()
.disable(MapperFeature.AUTO_DETECT_FIELDS)
.disable(MapperFeature.AUTO_DETECT_GETTERS)
.disable(MapperFeature.AUTO_DETECT_IS_GETTERS)
.registerModule(new ProblemModule())
.registerModule(new ConstraintViolationProblemModule());
final Violation violation = new Violation("bob", "was missing");
final ConstraintViolationProblem unit = new ConstraintViolationProblem(BAD_REQUEST, singletonList(violation));
with(mapper.writeValueAsString(unit))
.assertThat("status", is(400))
.assertThat("type", is(ConstraintViolationProblem.TYPE_VALUE))
.assertThat("title", is("Constraint Violation"))
.assertThat("violations", hasSize(1))
.assertThat("violations.*.field", contains("bob"))
.assertThat("violations.*.message", contains("was missing"));
}
开发者ID:zalando,项目名称:problem-spring-web,代码行数:21,代码来源:ConstraintViolationProblemModuleTest.java
示例2: shouldSerializeCustomType
import org.zalando.problem.validation.ConstraintViolationProblemModule; //导入依赖的package包/类
@Test
void shouldSerializeCustomType() throws JsonProcessingException {
final ObjectMapper mapper = new ObjectMapper()
.registerModule(new ProblemModule())
.registerModule(new ConstraintViolationProblemModule());
final URI type = URI.create("foo");
final ConstraintViolationProblem unit = new ConstraintViolationProblem(type, BAD_REQUEST, emptyList());
with(mapper.writeValueAsString(unit))
.assertThat("type", is("foo"));
}
开发者ID:zalando,项目名称:problem-spring-web,代码行数:13,代码来源:ConstraintViolationProblemModuleTest.java
示例3: constraintViolationProblemModule
import org.zalando.problem.validation.ConstraintViolationProblemModule; //导入依赖的package包/类
@Bean
ConstraintViolationProblemModule constraintViolationProblemModule() {
return new ConstraintViolationProblemModule();
}
开发者ID:xm-online,项目名称:xm-ms-balance,代码行数:5,代码来源:JacksonConfiguration.java
注:本文中的org.zalando.problem.validation.ConstraintViolationProblemModule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论