本文整理汇总了Java中org.springframework.restdocs.constraints.ConstraintDescriptions类的典型用法代码示例。如果您正苦于以下问题:Java ConstraintDescriptions类的具体用法?Java ConstraintDescriptions怎么用?Java ConstraintDescriptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstraintDescriptions类属于org.springframework.restdocs.constraints包,在下文中一共展示了ConstraintDescriptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ConstrainedFields
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
ConstrainedFields(Class<T> input) {
try {
this.constraintDescriptions = new ConstraintDescriptions(input);
this.customValidationDescription.load(
getClass().getResourceAsStream("CustomValidationDescription.properties"));
} catch (IOException e) {
throw new IllegalArgumentException(
"unable to load properties for custom validation description");
}
}
开发者ID:reflectoring,项目名称:coderadar,代码行数:12,代码来源:ControllerTestTemplate.java
示例2: getConstraintMessages
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
@Override
public List<String> getConstraintMessages(Class<?> javaBaseClass, String javaFieldName) {
ConstraintDescriptions constraints = new ConstraintDescriptions(javaBaseClass,
constraintResolver, constraintDescriptionResolver);
List<String> constraintMessages = new ArrayList<>();
constraintMessages.addAll(constraints.descriptionsForProperty(javaFieldName));
constraintMessages.addAll(getEnumConstraintMessage(javaBaseClass, javaFieldName));
return constraintMessages;
}
开发者ID:ScaCap,项目名称:spring-auto-restdocs,代码行数:10,代码来源:ConstraintReaderImpl.java
示例3: getWriteArticleCommentFormDescriptor
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
private FieldDescriptor[] getWriteArticleCommentFormDescriptor() {
ConstraintDescriptions userConstraints = new ConstraintDescriptions(WriteArticleComment.class);
return new FieldDescriptor[] {
fieldWithPath("content").type(JsonFieldType.STRING).description("댓글 내용. " + userConstraints.descriptionsForProperty("content")),
fieldWithPath("galleries").type(JsonFieldType.ARRAY).description("(optional) 그림 목록")
};
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:9,代码来源:ArticleCommentMvcTests.java
示例4: getWriteArticleFormDescriptor
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
private FieldDescriptor[] getWriteArticleFormDescriptor() {
ConstraintDescriptions userConstraints = new ConstraintDescriptions(WriteArticle.class);
return new FieldDescriptor[] {
fieldWithPath("subject").type(JsonFieldType.STRING).description("글 제목. " + userConstraints.descriptionsForProperty("subject")),
fieldWithPath("content").type(JsonFieldType.STRING).description("글 내용. " + userConstraints.descriptionsForProperty("content")),
fieldWithPath("categoryCode").type(JsonFieldType.STRING)
.description("(optional, default ALL) 말머리. board가 FREE 일때에는 무시된다. FOOTBALL, DEVELOPER일 때에는 필수다."),
fieldWithPath("galleries").type(JsonFieldType.ARRAY).description("(optional) 그림 목록")
};
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:12,代码来源:ArticleMvcTests.java
示例5: findPasswordTest
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
@Test
@WithMockUser
public void findPasswordTest() throws Exception {
UserPasswordFindForm form = UserPasswordFindForm.builder()
.email(jakdukUser.getEmail())
.callbackUrl("http://dev-wev.jakduk/find/password")
.build();
UserPasswordFindResponse expectResponse = UserPasswordFindResponse.builder()
.subject(form.getEmail())
.message(JakdukUtils.getMessageSource("user.msg.reset.password.send.email"))
.build();
when(userService.sendEmailToResetPassword(anyString(), anyString()))
.thenReturn(expectResponse);
ConstraintDescriptions userConstraints = new ConstraintDescriptions(UserPasswordFindForm.class, new ValidatorConstraintResolver(),
new ResourceBundleConstraintDescriptionResolver(ResourceBundle.getBundle("ValidationMessages")));
mvc.perform(post("/api/user/password/find")
.contentType(MediaType.APPLICATION_JSON)
.content(ObjectMapperUtils.writeValueAsString(form)))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectResponse)))
.andDo(
document("user-find-password",
requestFields(
fieldWithPath("email").type(JsonFieldType.STRING).description("이메일 주소. " +
userConstraints.descriptionsForProperty("email")),
fieldWithPath("callbackUrl").type(JsonFieldType.STRING).description("콜백 받을 URL. " +
userConstraints.descriptionsForProperty("callbackUrl"))
),
responseFields(this.getPasswordFindDescriptor())
));
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:38,代码来源:UserMvcTests.java
示例6: resetPasswordTest
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
@Test
@WithMockUser
public void resetPasswordTest() throws Exception {
UserPasswordResetForm form = UserPasswordResetForm.builder()
.code("16948f83-1af8-4736-9e12-cf57f03a981c")
.password("1112")
.build();
UserPasswordFindResponse expectResponse = UserPasswordFindResponse.builder()
.subject(jakdukUser.getEmail())
.message(JakdukUtils.getMessageSource("user.msg.success.change.password"))
.build();
when(userService.resetPasswordWithToken(anyString(), anyString()))
.thenReturn(expectResponse);
ConstraintDescriptions userConstraints = new ConstraintDescriptions(UserPasswordResetForm.class, new ValidatorConstraintResolver(),
new ResourceBundleConstraintDescriptionResolver(ResourceBundle.getBundle("ValidationMessages")));
mvc.perform(post("/api/user/password/reset")
.contentType(MediaType.APPLICATION_JSON)
.content(ObjectMapperUtils.writeValueAsString(form)))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectResponse)))
.andDo(
document("user-reset-password",
requestFields(
fieldWithPath("code").type(JsonFieldType.STRING).description("임시 발행한 토큰 코드. (5분간 유지) " +
userConstraints.descriptionsForProperty("code")),
fieldWithPath("password").type(JsonFieldType.STRING).description("바꿀 비밀번호 " +
userConstraints.descriptionsForProperty("password"))
),
responseFields(this.getPasswordFindDescriptor())
));
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:38,代码来源:UserMvcTests.java
示例7: ConstrainedFields
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
ConstrainedFields(Class<?> input) {
this.constraintDescriptions = new ConstraintDescriptions(input);
}
开发者ID:ePages-de,项目名称:restdocs-raml,代码行数:4,代码来源:ApiDocumentation.java
示例8: ConstrainedFields
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
public ConstrainedFields(Class<?> input) {
this.constraintDescriptions = new ConstraintDescriptions(input);
}
开发者ID:tsypuk,项目名称:springrestdoc,代码行数:4,代码来源:ConstrainedFields.java
示例9: ConstrainedFields
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
public ConstrainedFields(Class<?> input) {
this.constraintDescriptions = new ConstraintDescriptions(input,
new ValidatorConstraintResolver(),
new ResourceBundleConstraintDescriptionResolver());
}
开发者ID:uweschaefer,项目名称:factcast,代码行数:6,代码来源:ConstrainedFields.java
示例10: ConstrainedFields
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
ConstrainedFields(Class<T> input) {
this.constraintDescriptions = new ConstraintDescriptions(input);
}
开发者ID:reflectoring,项目名称:infiniboard,代码行数:4,代码来源:ControllerTestTemplate.java
示例11: createJakdukUserTest
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
@Test
@WithMockUser
public void createJakdukUserTest() throws Exception {
this.whenCustomValdation();
UserForm form = UserForm.builder()
.email(jakdukUser.getEmail())
.username(jakdukUser.getUsername())
.password("1111")
.passwordConfirm("1111")
.about(jakdukUser.getAbout())
.footballClub(footballClub.getId())
.userPictureId(userPicture.getId())
.build();
when(userService.createJakdukUser(anyString(), anyString(), anyString(), anyString(), anyString(), anyString()))
.thenReturn(jakdukUser);
ConstraintDescriptions userConstraints = new ConstraintDescriptions(UserForm.class, new ValidatorConstraintResolver(),
new ResourceBundleConstraintDescriptionResolver(ResourceBundle.getBundle("ValidationMessages")));
mvc.perform(post("/api/user")
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.content(ObjectMapperUtils.writeValueAsString(form)))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(ObjectMapperUtils.writeValueAsString(EmptyJsonResponse.newInstance())))
.andDo(
document("create-jakduk-user",
requestFields(
fieldWithPath("email").type(JsonFieldType.STRING).description("이메일 주소. " +
userConstraints.descriptionsForProperty("email")),
fieldWithPath("username").type(JsonFieldType.STRING).description("별명. " +
userConstraints.descriptionsForProperty("username")),
fieldWithPath("password").type(JsonFieldType.STRING).description("비밀번호. " +
userConstraints.descriptionsForProperty("password")),
fieldWithPath("passwordConfirm").type(JsonFieldType.STRING).description("확인 비밀번호. " +
userConstraints.descriptionsForProperty("passwordConfirm")),
fieldWithPath("footballClub").type(JsonFieldType.STRING).description("(optional) 축구단 ID"),
fieldWithPath("about").type(JsonFieldType.STRING).description("(optional) 자기 소개"),
fieldWithPath("userPictureId").type(JsonFieldType.STRING).description("(optional) 프로필 사진 ID")
),
responseHeaders(
headerWithName("Set-Cookie").description("인증 쿠키. value는 JSESSIONID=키값").optional()
)
));
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:50,代码来源:UserMvcTests.java
示例12: createSocialUserTest
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
@Test
@WithMockUser
public void createSocialUserTest() throws Exception {
this.whenCustomValdation();
AttemptSocialUser attemptSocialUser = AttemptSocialUser.builder()
.username("daumUser01")
.providerId(Constants.ACCOUNT_TYPE.DAUM)
.providerUserId("abc123")
.externalSmallPictureUrl("https://img1.daumcdn.net/thumb/R55x55/?fname=http%3A%2F%2Ftwg.tset.daumcdn.net%2Fprofile%2F6enovyMT1pI0&t=1507478752861")
.externalLargePictureUrl("https://img1.daumcdn.net/thumb/R158x158/?fname=http%3A%2F%2Ftwg.tset.daumcdn.net%2Fprofile%2F6enovyMT1pI0&t=1507478752861")
.build();
MockHttpSession mockHttpSession = new MockHttpSession();
mockHttpSession.setAttribute(Constants.PROVIDER_SIGNIN_ATTEMPT_SESSION_ATTRIBUTE, attemptSocialUser);
SocialUserForm form = SocialUserForm.builder()
.email("[email protected]")
.username("SocialUser")
.about("안녕하세요.")
.footballClub(footballClub.getId())
.userPictureId(userPicture.getId())
.externalLargePictureUrl("https://img1.daumcdn.net/thumb/R158x158/?fname=http%3A%2F%2Ftwg.tset.daumcdn.net%2Fprofile%2FSjuNejHmr8o0&t=1488000722876")
.build();
User expectUser = User.builder()
.id("597df86caaf4fc0545d4f3e9")
.email(form.getEmail())
.username(form.getUsername())
.password("841db2bc28e4730906bd82d79e69c80633747570d96ffade7dd77f58270f31a222e129e005cb70d2")
.providerId(attemptSocialUser.getProviderId())
.providerUserId(attemptSocialUser.getProviderUserId())
.about(form.getAbout())
.roles(Arrays.asList(JakdukAuthority.ROLE_USER_02.getCode()))
.supportFC(footballClub)
.lastLogged(LocalDateTime.now())
.build();
when(userService.createSocialUser(anyString(), anyString(), any(Constants.ACCOUNT_TYPE.class), anyString(),
anyString(), anyString(), anyString(), anyString()))
.thenReturn(expectUser);
ConstraintDescriptions userConstraints = new ConstraintDescriptions(SocialUserForm.class, new ValidatorConstraintResolver(),
new ResourceBundleConstraintDescriptionResolver(ResourceBundle.getBundle("ValidationMessages")));
mvc.perform(post("/api/user/social")
.session(mockHttpSession)
.contentType(MediaType.APPLICATION_JSON)
.content(ObjectMapperUtils.writeValueAsString(form)))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(ObjectMapperUtils.writeValueAsString(EmptyJsonResponse.newInstance())))
.andDo(
document("create-sns-user",
requestFields(
fieldWithPath("email").type(JsonFieldType.STRING).description("이메일 주소. " +
userConstraints.descriptionsForProperty("email")),
fieldWithPath("username").type(JsonFieldType.STRING).description("별명. " +
userConstraints.descriptionsForProperty("username")),
fieldWithPath("footballClub").type(JsonFieldType.STRING).description("(optional) 축구단 ID"),
fieldWithPath("about").type(JsonFieldType.STRING).description("(optional) 자기 소개"),
fieldWithPath("userPictureId").type(JsonFieldType.STRING).description("(optional) 프로필 사진 ID"),
fieldWithPath("externalLargePictureUrl").type(JsonFieldType.STRING)
.description("(optional) SNS계정에서 제공하는 회원 큰 사진 URL. userPictureId가 null 이어야 한다.")
),
responseHeaders(
headerWithName("Set-Cookie").description("인증 쿠키. value는 JSESSIONID=키값").optional()
)
));
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:72,代码来源:UserMvcTests.java
示例13: editProfileMeTest
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
@Test
@WithMockJakdukUser
public void editProfileMeTest() throws Exception {
when(userProfileRepository.findByNEIdAndEmail(anyString(), anyString()))
.thenReturn(Optional.empty());
when(userProfileRepository.findByNEIdAndUsername(anyString(), anyString()))
.thenReturn(Optional.empty());
UserProfileEditForm form = UserProfileEditForm.builder()
.email(jakdukUser.getEmail())
.username(jakdukUser.getUsername())
.about(jakdukUser.getAbout())
.footballClub(footballClub.getId())
.userPictureId(userPicture.getId())
.build();
when(userService.editUserProfile(anyString(), anyString(), anyString(), anyString(), anyString(), anyString()))
.thenReturn(jakdukUser);
ConstraintDescriptions userConstraints = new ConstraintDescriptions(UserProfileEditForm.class, new ValidatorConstraintResolver(),
new ResourceBundleConstraintDescriptionResolver(ResourceBundle.getBundle("ValidationMessages")));
mvc.perform(
put("/api/user/profile/me")
.header("Cookie", "JSESSIONID=3F0E029648484BEAEF6B5C3578164E99")
//.cookie(new Cookie("JSESSIONID", "3F0E029648484BEAEF6B5C3578164E99")) TODO 이걸로 바꾸고 싶다.
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.content(ObjectMapperUtils.writeValueAsString(form)))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(ObjectMapperUtils.writeValueAsString(EmptyJsonResponse.newInstance())))
.andDo(
document("user-edit-profile-me",
requestHeaders(
headerWithName("Cookie").description("인증 쿠키. value는 JSESSIONID=키값")
),
requestFields(
fieldWithPath("email").type(JsonFieldType.STRING).description("이메일 주소. " +
userConstraints.descriptionsForProperty("email")),
fieldWithPath("username").type(JsonFieldType.STRING).description("별명. " +
userConstraints.descriptionsForProperty("username")),
fieldWithPath("footballClub").type(JsonFieldType.STRING).description("(optional) 축구단 ID"),
fieldWithPath("about").type(JsonFieldType.STRING).description("(optional) 자기 소개"),
fieldWithPath("userPictureId").type(JsonFieldType.STRING).description("(optional) 프로필 사진 ID")
)
));
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:51,代码来源:UserMvcTests.java
示例14: editPasswordTest
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
@Test
@WithMockJakdukUser
public void editPasswordTest() throws Exception {
when(userService.findUserOnPasswordUpdateById(anyString()))
.thenReturn(new UserOnPasswordUpdate(jakdukUser.getId(), jakdukUser.getPassword()));
UserPasswordForm form = UserPasswordForm.builder()
.password("1111")
.newPassword("1112")
.newPasswordConfirm("1112")
.build();
doNothing().when(userService)
.updateUserPassword(anyString(), anyString());
ConstraintDescriptions userConstraints = new ConstraintDescriptions(UserPasswordForm.class, new ValidatorConstraintResolver(),
new ResourceBundleConstraintDescriptionResolver(ResourceBundle.getBundle("ValidationMessages")));
mvc.perform(
put("/api/user/password")
.header("Cookie", "JSESSIONID=3F0E029648484BEAEF6B5C3578164E99")
//.cookie(new Cookie("JSESSIONID", "3F0E029648484BEAEF6B5C3578164E99")) TODO 이걸로 바꾸고 싶다.
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.content(ObjectMapperUtils.writeValueAsString(form)))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(ObjectMapperUtils.writeValueAsString(EmptyJsonResponse.newInstance())))
.andDo(
document("user-edit-password",
requestHeaders(
headerWithName("Cookie").description("인증 쿠키. value는 JSESSIONID=키값")
),
requestFields(
fieldWithPath("password").type(JsonFieldType.STRING).description("현재 비밀번호. " +
userConstraints.descriptionsForProperty("password")),
fieldWithPath("newPassword").type(JsonFieldType.STRING).description("새 비밀번호. " +
userConstraints.descriptionsForProperty("newPassword")),
fieldWithPath("newPasswordConfirm").type(JsonFieldType.STRING).description("확인 새 비밀번호. " +
userConstraints.descriptionsForProperty("newPasswordConfirm"))
)
));
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:45,代码来源:UserMvcTests.java
示例15: snsLoginTest
import org.springframework.restdocs.constraints.ConstraintDescriptions; //导入依赖的package包/类
@Test
@WithMockUser
public void snsLoginTest() throws Exception {
LoginSocialUserForm requestForm = LoginSocialUserForm.builder()
.accessToken("baada13b7df9af000fa20355bf07b25f808940ab69dd7f32b6c009efdd0f6d29")
.build();
when(authUtils.getDaumProfile(anyString()))
.thenReturn(socialProfile);
Optional<User> optUser = Optional.of(
User.builder()
.id("58b2dbf1d6d83b04bf365277")
.email("[email protected]")
.username("생글이")
.providerId(providerId)
.providerUserId(socialProfile.getId())
.roles(Arrays.asList(JakdukAuthority.ROLE_USER_01.getCode()))
.about("안녕하세요.")
.build()
);
when(userService.findOneByProviderIdAndProviderUserId(any(Constants.ACCOUNT_TYPE.class), anyString()))
.thenReturn(optUser);
ConstraintDescriptions loginSocialUserConstraints = new ConstraintDescriptions(LoginSocialUserForm.class);
mvc.perform(
post("/api/auth/login/{providerId}", providerId)
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.content(ObjectMapperUtils.writeValueAsString(requestForm)))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(ObjectMapperUtils.writeValueAsString(EmptyJsonResponse.newInstance())))
.andDo(
document("login-sns-user",
pathParameters(
parameterWithName("providerId").description("SNS 분류 " +
Stream.of(Constants.ACCOUNT_TYPE.values())
.filter(accountType -> ! accountType.equals(Constants.ACCOUNT_TYPE.JAKDUK))
.map(Enum::name)
.map(String::toLowerCase)
.collect(Collectors.toList())
)
),
requestFields(
fieldWithPath("accessToken").type(JsonFieldType.STRING).description("OAuth의 Access Token " +
loginSocialUserConstraints.descriptionsForProperty("accessToken"))
),
responseHeaders(
headerWithName("Set-Cookie").description("인증 쿠키. value는 JSESSIONID=키값").optional()
)
));
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:57,代码来源:AuthMvcTests.java
注:本文中的org.springframework.restdocs.constraints.ConstraintDescriptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论