• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JsonFieldType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.restdocs.payload.JsonFieldType的典型用法代码示例。如果您正苦于以下问题:Java JsonFieldType类的具体用法?Java JsonFieldType怎么用?Java JsonFieldType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonFieldType类属于org.springframework.restdocs.payload包,在下文中一共展示了JsonFieldType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: toFieldDescriptor

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
private static FieldDescriptor toFieldDescriptor(LinkDescriptor linkDescriptor) {
    FieldDescriptor descriptor = fieldWithPath("_links." + linkDescriptor.getRel()) //change to subsectionWithPath on spring-rest-docs 1.2
            .description(linkDescriptor.getDescription())
            .type(JsonFieldType.OBJECT)
            .attributes(linkDescriptor.getAttributes().entrySet().stream()
                    .map(e -> new Attribute(e.getKey(), e.getValue()))
                    .toArray(Attribute[]::new));

    if (linkDescriptor.isOptional()) {
        descriptor = descriptor.optional();
    }
    if (linkDescriptor.isIgnored()) {
        descriptor = descriptor.ignored();
    }

    return descriptor;
}
 
开发者ID:ePages-de,项目名称:restdocs-raml,代码行数:18,代码来源:RamlResourceSnippetParameters.java


示例2: getMetaInformation

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
public void getMetaInformation() throws Exception {
	this.mockMvc.perform(get("/about").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
			.andDo(this.documentationHandler.document(responseFields(
					fieldWithPath("_links.self").description("Link to the runtime environment resource"),
					fieldWithPath("featureInfo").type(JsonFieldType.OBJECT)
							.description("Details which features are enabled."),

					fieldWithPath("versionInfo").type(JsonFieldType.OBJECT).description(
							"Provides details of the Spring Cloud Data Flow Server " + "dependencies."),

					fieldWithPath("securityInfo").type(JsonFieldType.OBJECT)
							.description("Provides security configuration information."),

					fieldWithPath("runtimeEnvironment").type(JsonFieldType.OBJECT)
							.description("Provides details of the runtime environment."))));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:18,代码来源:AboutDocumentation.java


示例3: getArticleCommentsDescriptor

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
private List<FieldDescriptor> getArticleCommentsDescriptor(FieldDescriptor... descriptors) {
    List<FieldDescriptor> fieldDescriptors = new ArrayList<>(
            Arrays.asList(
                    fieldWithPath("comments").type(JsonFieldType.ARRAY).description("댓글 목록"),
                    fieldWithPath("comments.[].id").type(JsonFieldType.STRING).description("댓글 ID"),
                    fieldWithPath("comments.[].article").type(JsonFieldType.OBJECT).description("연동 글"),
                    fieldWithPath("comments.[].writer").type(JsonFieldType.OBJECT).description("글쓴이"),
                    fieldWithPath("comments.[].status").type(JsonFieldType.OBJECT).description("댓글 상태"),
                    fieldWithPath("comments.[].content").type(JsonFieldType.STRING).description("댓글 내용"),
                    fieldWithPath("comments.[].numberOfLike").type(JsonFieldType.NUMBER).description("좋아요 수"),
                    fieldWithPath("comments.[].numberOfDislike").type(JsonFieldType.NUMBER).description("싫어요 수"),
                    fieldWithPath("comments.[].myFeeling").type(JsonFieldType.STRING).description("나의 감정 상태. 인증 쿠키가 있고, 감정 표현을 한 경우 포함 된다."),
                    fieldWithPath("comments.[].galleries").type(JsonFieldType.ARRAY).description("그림 목록"),
                    fieldWithPath("comments.[].logs").type(JsonFieldType.ARRAY).description("로그 기록 목록")
            )
    );

    CollectionUtils.mergeArrayIntoCollection(descriptors, fieldDescriptors);

    return fieldDescriptors;
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:22,代码来源:ArticleCommentMvcTests.java


示例4: getWriteArticleCommentDescriptor

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
private FieldDescriptor[] getWriteArticleCommentDescriptor() {
    return new FieldDescriptor[] {
            fieldWithPath("id").type(JsonFieldType.STRING).description("댓글 ID"),
            fieldWithPath("article").type(JsonFieldType.OBJECT).description("연동 글"),
            fieldWithPath("article.id").type(JsonFieldType.STRING).description("글 ID"),
            fieldWithPath("article.seq").type(JsonFieldType.NUMBER).description("글 번호"),
            fieldWithPath("article.board").type(JsonFieldType.STRING).description("게시판"),
            fieldWithPath("status").type(JsonFieldType.OBJECT).description("댓글 상태"),
            fieldWithPath("status.device").type(JsonFieldType.STRING).description("디바이스 종류 " +
                    Stream.of(Constants.DEVICE_TYPE.values()).map(Enum::name).collect(Collectors.toList())),
            fieldWithPath("writer").type(JsonFieldType.OBJECT).description("글쓴이"),
            fieldWithPath("content").type(JsonFieldType.STRING).description("댓글 내용"),
            fieldWithPath("usersLiking").type(JsonFieldType.ARRAY).description("좋아요를 한 회원 목록"),
            fieldWithPath("usersDisliking").type(JsonFieldType.ARRAY).description("싫어요를 한 회원 목록"),
            fieldWithPath("linkedGallery").type(JsonFieldType.BOOLEAN).description("연동 그림 존재 여부"),
            fieldWithPath("logs").type(JsonFieldType.ARRAY).description("로그 기록 목록")
    };
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:19,代码来源:ArticleCommentMvcTests.java


示例5: getBoardCategories

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
@WithMockUser
public void getBoardCategories() throws Exception {
    mvc.perform(
            get("/api/board/{board}/categories", article.getBoard().toLowerCase())
                    .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
            .andDo(
                    document("getBoardCategories",
                            pathParameters(
                                    parameterWithName("board").description("게시판 " +
                                            Stream.of(Constants.BOARD_TYPE.values()).map(Enum::name).map(String::toLowerCase).collect(Collectors.toList()))
                            ),
                            responseFields(
                                    fieldWithPath("categories").type(JsonFieldType.ARRAY).description("말머리 목록"),
                                    fieldWithPath("categories.[].code").type(JsonFieldType.STRING).description("말머리 코드"),
                                    fieldWithPath("categories.[].names").type(JsonFieldType.ARRAY).description("말머리 이름 목록(Locale 지원)"),
                                    fieldWithPath("categories.[].names.[].language").type(JsonFieldType.STRING).description("언어"),
                                    fieldWithPath("categories.[].names.[].name").type(JsonFieldType.STRING).description("이름")
                            )
                    ));
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:24,代码来源:ArticleMvcTests.java


示例6: noteUpdateExample

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
public void noteUpdateExample() throws Exception {
	givenNote();
	this.mockMvc
		.perform(get(noteLocation))
		.andExpect(status().isOk())
		.andExpect(jsonPath("title", is(note.get("title"))))
		.andExpect(jsonPath("body", is(note.get("body"))))
		.andExpect(jsonPath("_links.self.href", is(noteLocation)))
		.andExpect(jsonPath("_links.note-tags", is(notNullValue())));

	givenTag();

	Map<String, Object> noteUpdate = new HashMap<>();
	noteUpdate.put("tags", singletonList(tagLocation));

	whenNoteUpdated(noteUpdate);

	resultActions.andDo(document("notes-patch",
			ramlResource(RamlResourceSnippetParameters.builder()
					.description("Partially update a note")
					.requestFields(
							fieldWithPath("title")
									.description("The title of the note")
									.type(JsonFieldType.STRING)
									.optional(),
							fieldWithPath("body")
									.description("The body of the note")
									.type(JsonFieldType.STRING)
									.optional(),
							fieldWithPath("tags")
									.description("An array of tag resource URIs"))
					.build()))
	);
}
 
开发者ID:ePages-de,项目名称:restdocs-raml,代码行数:36,代码来源:ApiDocumentation.java


示例7: handleEndOfPath

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
private void handleEndOfPath(ObjectSchema.Builder builder, String propertyName, FieldDescriptor fieldDescriptor) {
    if (fieldDescriptor.isIgnored()) {
        // We don't need to render anything
    } else if (fieldDescriptor.getType().equals(JsonFieldType.NULL) || fieldDescriptor.getType().equals(JsonFieldType.VARIES)) {
        builder.addPropertySchema(propertyName, NullSchema.builder()
                .description((String) fieldDescriptor.getDescription())
                .build());
    } else if (fieldDescriptor.getType().equals(JsonFieldType.OBJECT)) {
        builder.addPropertySchema(propertyName, ObjectSchema.builder()
                .description((String) fieldDescriptor.getDescription())
                .build());
    } else if (fieldDescriptor.getType().equals(JsonFieldType.ARRAY)) {
        builder.addPropertySchema(propertyName, ArraySchema.builder()
                .description((String) fieldDescriptor.getDescription())
                .build());
    } else if (fieldDescriptor.getType().equals(JsonFieldType.BOOLEAN)) {
        builder.addPropertySchema(propertyName, BooleanSchema.builder()
                .description((String) fieldDescriptor.getDescription())
                .build());
    } else if (fieldDescriptor.getType().equals(JsonFieldType.NUMBER)) {
        builder.addPropertySchema(propertyName, NumberSchema.builder()
                .description((String) fieldDescriptor.getDescription())
                .build());
    } else if (fieldDescriptor.getType().equals(JsonFieldType.STRING)) {
        builder.addPropertySchema(propertyName, StringSchema.builder()
                .description((String) fieldDescriptor.getDescription())
                .build());
    } else {
        throw new IllegalArgumentException("unknown field type " + fieldDescriptor.getType());
    }
}
 
开发者ID:ePages-de,项目名称:restdocs-raml,代码行数:32,代码来源:JsonSchemaFromFieldDescriptorsGenerator.java


示例8: getBook

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
public void getBook() throws Exception {
	
	// prepare objects returned by the bookservice
	List<Author> authors = Arrays.asList(buildAuthor(1L, toDate("1978-09-25"), null));
	Long bookId = 1L;
	Book book = buildBook(bookId, Currency.EUR, 10.0, authors);
	
	// program bookService mock to return the book with id bookId
	when(bookService.getById(bookId)).thenReturn(book);
	
	
	this.document.document(responseFields( 
    		fieldWithPath("id").description("The book's id").type(JsonFieldType.NUMBER), 
            fieldWithPath("title").description("The book's title").type(JsonFieldType.STRING),
    		fieldWithPath("isbn").description("The book's ISBN code").type(JsonFieldType.STRING),
    		fieldWithPath("description").description("The book's short description").type(JsonFieldType.STRING),
    		fieldWithPath("price").description("The book's price").type(JsonFieldType.NUMBER),
    		fieldWithPath("releaseDate").description("The book's release date").type(JsonFieldType.NUMBER),
    		fieldWithPath("currency").description("The book's currency").type(JsonFieldType.STRING),
    		fieldWithPath("authors").description("The book's author list").type(JsonFieldType.OBJECT),
    		fieldWithPath("authors[].id").description("The author's id").type(JsonFieldType.NUMBER),
    		fieldWithPath("authors[].name").description("The author's first name").type(JsonFieldType.STRING),
    		fieldWithPath("authors[].surname").description("The author's last name").type(JsonFieldType.STRING),
    		fieldWithPath("authors[].birthplace").description("The author's birthplace").type(JsonFieldType.STRING),
    		fieldWithPath("authors[].born").description("The author's ISBN birthdate").type(JsonFieldType.NUMBER)
    ));
	
	this.mockMvc.perform(get("/api/books/1")
		.accept(MediaType.APPLICATION_JSON))
		.andDo(print())
    	.andExpect(status().isOk()); 
	
	assertEquals(true, true);
    
}
 
开发者ID:lucamartellucci,项目名称:bookshop-api,代码行数:37,代码来源:BookControllerDocumentation.java


示例9: getArticleDetailCommentsTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
@WithMockJakdukUser
public void getArticleDetailCommentsTest() throws Exception {

    GetArticleDetailCommentsResponse expectResponse = GetArticleDetailCommentsResponse.builder()
            .comments(articleComments)
            .count(articleComments.size())
            .build();

    when(articleService.getArticleDetailComments(any(CommonWriter.class), any(Constants.BOARD_TYPE.class), anyInt(), anyString()))
            .thenReturn(expectResponse);

    mvc.perform(
            get("/api/board/{board}/{seq}/comments", Constants.BOARD_TYPE.FOOTBALL.name().toLowerCase(), article.getSeq())
                    .header("Cookie", "JSESSIONID=3F0E029648484BEAEF6B5C3578164E99")
                    .param("commentId", "59c2ec0fbe3eb62dfca3ed9c")
                    .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
            .andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectResponse)))
            .andDo(
                    document("getArticleDetailComments",
                            requestHeaders(
                                    headerWithName("Cookie").description("(optional) 인증 쿠키. value는 JSESSIONID=키값")
                            ),
                            pathParameters(
                                    parameterWithName("board").description("게시판 " +
                                            Stream.of(Constants.BOARD_TYPE.values()).map(Enum::name).map(String::toLowerCase).collect(Collectors.toList())),
                                    parameterWithName("seq").description("글 번호")
                            ),
                            requestParameters(
                                    parameterWithName("commentId").description("(optional) commentId 이후부터 목록 가져옴")
                            ),
                            responseFields(
                                    this.getArticleCommentsDescriptor(fieldWithPath("count").type(JsonFieldType.NUMBER).description("댓글 수"))
                                    )
                            )
                    );
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:40,代码来源:ArticleCommentMvcTests.java


示例10: getWriteArticleCommentFormDescriptor

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的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


示例11: deleteArticleTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
@WithMockJakdukUser
public void deleteArticleTest() throws Exception {

    Constants.ARTICLE_DELETE_TYPE expectDeleteType = Constants.ARTICLE_DELETE_TYPE.ALL;

    when(articleService.deleteArticle(any(CommonWriter.class), any(Constants.BOARD_TYPE.class), anyInt()))
            .thenReturn(expectDeleteType);

    DeleteArticleResponse expectResponse = DeleteArticleResponse.builder()
            .result(expectDeleteType)
            .build();

    mvc.perform(
            delete("/api/board/{board}/{seq}", article.getBoard().toLowerCase(), article.getSeq())
                    .header("Cookie", "JSESSIONID=3F0E029648484BEAEF6B5C3578164E99")
                    //.cookie(new Cookie("JSESSIONID", "3F0E029648484BEAEF6B5C3578164E99")) TODO 이걸로 바꾸고 싶다.
                    .contentType(MediaType.APPLICATION_JSON)
                    .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
            .andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectResponse)))
            .andDo(
                    document("deleteArticle",
                            requestHeaders(
                                    headerWithName("Cookie").description("인증 쿠키. value는 JSESSIONID=키값")
                            ),
                            pathParameters(
                                    parameterWithName("board").description("게시판 " +
                                            Stream.of(Constants.BOARD_TYPE.values()).map(Enum::name).map(String::toLowerCase).collect(Collectors.toList())),
                                    parameterWithName("seq").description("글번호")
                            ),
                            responseFields(
                                    fieldWithPath("result").type(JsonFieldType.STRING).description("결과 타입. [ALL : 모두 지움, CONTENT : 글 본문만 지움(댓글 유지)]")
                            )
                    ));
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:38,代码来源:ArticleMvcTests.java


示例12: getArticleFeelingUsersTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
@WithMockUser
public void getArticleFeelingUsersTest() throws Exception {

    when(articleService.findOneBySeq(any(Constants.BOARD_TYPE.class), anyInt()))
            .thenReturn(article);

    GetArticleFeelingUsersResponse expectResponse = GetArticleFeelingUsersResponse.builder()
            .seq(article.getSeq())
            .usersLiking(article.getUsersLiking())
            .usersDisliking(article.getUsersDisliking())
            .build();

    mvc.perform(
            get("/api/board/{board}/{seq}/feeling/users",
                    Constants.BOARD_TYPE.FOOTBALL.name().toLowerCase(), article.getSeq())
                    .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
            .andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectResponse)))
            .andDo(
                    document("getArticleFeelingUsers",
                            pathParameters(
                                    parameterWithName("board").description("게시판 " +
                                            Stream.of(Constants.BOARD_TYPE.values()).map(Enum::name).map(String::toLowerCase).collect(Collectors.toList())),
                                    parameterWithName("seq").description("글번호")
                            ),
                            responseFields(
                                    fieldWithPath("seq").type(JsonFieldType.NUMBER).description("글번호"),
                                    fieldWithPath("usersLiking").type(JsonFieldType.ARRAY).description("좋아요 회원 목록"),
                                    fieldWithPath("usersDisliking").type(JsonFieldType.ARRAY).description("싫어요 회원 목록")
                            )
                    ));
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:35,代码来源:ArticleMvcTests.java


示例13: getWriteArticleFormDescriptor

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的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


示例14: getEncyclopediaWithRandomTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
@WithMockUser
public void getEncyclopediaWithRandomTest() throws Exception {

    Encyclopedia expectEncyclopedia = Encyclopedia.builder()
            .id("5427972b31d4c583498c19bf")
            .seq(2)
            .kind("player")
            .language("ko")
            .subject("박성화")
            .content("슈퍼리그 출범 원년의 MVP이다. 수비수임에도 탁월한 득점력을 갖췄던 박성화는 후기리그부터 주장을 맡아 팀 분위기를 쇄신했다. 넓은 시야를 바탕으로 공수에서 맹활약한 박성화는 할렐루야 우승의 견인차 역할을 했다.")
            .build();

    when(homeService.getEncyclopediaWithRandom(anyString()))
            .thenReturn(expectEncyclopedia);

    mvc.perform(
            get("/api/home/encyclopedia")
                    .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
            .andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectEncyclopedia)))
            .andDo(
                    document("get-random-encyclopedia",
                            responseFields(
                                    fieldWithPath("id").type(JsonFieldType.STRING).description("백과사전 ID"),
                                    fieldWithPath("seq").type(JsonFieldType.NUMBER).description("백과사전 번호"),
                                    fieldWithPath("kind").type(JsonFieldType.STRING).description("종류 [player,book]"),
                                    fieldWithPath("language").type(JsonFieldType.STRING).description("언어 [ko,en]"),
                                    fieldWithPath("subject").type(JsonFieldType.STRING).description("제목"),
                                    fieldWithPath("content").type(JsonFieldType.STRING).description("내용")
                            )
                    ));
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:35,代码来源:HomeMvcTests.java


示例15: searchPopularWordsTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
@WithMockUser
public void searchPopularWordsTest() throws Exception {

    PopularSearchWordResult expectResponse = PopularSearchWordResult.builder()
            .took(18L)
            .popularSearchWords(
                    Arrays.asList(
                            new EsTermsBucket("제목입니다", 33L),
                            new EsTermsBucket("test", 10L),
                            new EsTermsBucket("축구", 21L)
                    ))
            .build();

    when(searchService.aggregateSearchWord(any(LocalDate.class), anyInt()))
            .thenReturn(expectResponse);

    mvc.perform(
            get("/api/search/popular-words")
                    .param("size", "5")
                    .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
            .andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectResponse)))
            .andDo(
                    document("search-popular-words",
                            requestParameters(
                                    parameterWithName("size").description("(default 5) 반환 개수")
                            ),
                            responseFields(
                                    fieldWithPath("took").type(JsonFieldType.NUMBER).description("찾는데 걸린 시간(ms)"),
                                    fieldWithPath("popularSearchWords").type(JsonFieldType.ARRAY).description("인기 검색어 목록"),
                                    fieldWithPath("popularSearchWords.[].key").type(JsonFieldType.STRING).description("검색어"),
                                    fieldWithPath("popularSearchWords.[].count").type(JsonFieldType.NUMBER).description("검색수")
                            )
                    ));
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:38,代码来源:SearchMvcTests.java


示例16: uploadUserPictureTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
@WithMockUser
public void uploadUserPictureTest() throws Exception {

    UserPicture expectUserPicture = UserPicture.builder()
            .id(userPicture.getId())
            .status(Constants.GALLERY_STATUS_TYPE.TEMP)
            .contentType(userPicture.getContentType())
            .build();

    when(userService.uploadUserPicture(anyString(), anyLong(), anyObject()))
            .thenReturn(expectUserPicture);

    byte[] ballBytes = new byte[]{
            (byte) 0x89, (byte) 0x50, (byte) 0x4e, (byte) 0x47, (byte) 0x0d, (byte) 0x0a, (byte) 0x1a, (byte) 0x0a, (byte) 0x00,
            (byte) 0x00, (byte) 0x00, (byte) 0x0d, (byte) 0x49, (byte) 0x48, (byte) 0x44, (byte) 0x52, (byte) 0x00, (byte) 0x00
    };

    MockMultipartFile mockMultipartFile = new MockMultipartFile("file", "sample.png", MediaType.IMAGE_PNG_VALUE, ballBytes);

    mvc.perform(fileUpload("/api/user/picture")
            .file(mockMultipartFile))
            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
            .andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectUserPicture)))
            .andDo(
                    document("user-upload-picture",
                            requestParts(
                                    partWithName("file").description("멀티 파트 객체")
                            ),
                            responseFields(
                                    fieldWithPath("id").type(JsonFieldType.STRING).description("그림 ID"),
                                    fieldWithPath("status").type(JsonFieldType.STRING).description("그림 상태. " +
                                            Stream.of(Constants.GALLERY_STATUS_TYPE.values()).map(Enum::name).collect(Collectors.toList())),
                                    fieldWithPath("contentType").type(JsonFieldType.STRING).description("Content-Type. image/* 만 가능하다.")
                            )
                    ));
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:39,代码来源:UserMvcTests.java


示例17: findPasswordTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的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


示例18: resetPasswordTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的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


示例19: getMySessionProfileTest

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
@WithMockJakdukUser
public void getMySessionProfileTest() throws Exception {

    SessionUser expectResponse = AuthUtils.getAuthUserProfile();

    mvc.perform(
            get("/api/auth/user")
                    .header("Cookie", "JSESSIONID=3F0E029648484BEAEF6B5C3578164E99")
                    .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
            .andExpect(content().json(ObjectMapperUtils.writeValueAsString(expectResponse)))
            .andDo(
                    document("get-my-session-user",
                            requestHeaders(
                                    headerWithName("Cookie").description("인증 쿠키. value는 JSESSIONID=키값")
                            ),
                            responseFields(
                                    fieldWithPath("id").type(JsonFieldType.STRING).description("회원 ID"),
                                    fieldWithPath("email").type(JsonFieldType.STRING).description("이메일 주소"),
                                    fieldWithPath("username").type(JsonFieldType.STRING).description("별명"),
                                    fieldWithPath("providerId").type(JsonFieldType.STRING).description("계정 분류 " +
                                            Stream.of(Constants.ACCOUNT_TYPE.values()).map(Enum::name).collect(Collectors.toList())),
                                    fieldWithPath("roles").type(JsonFieldType.ARRAY).description("권한 목록 " +
                                            Stream.of(JakdukAuthority.values()).map(Enum::name).collect(Collectors.toList())),
                                    fieldWithPath("picture").type(JsonFieldType.OBJECT).description("회원 사진"),
                                    fieldWithPath("picture.id").type(JsonFieldType.STRING).description("회원 사진 ID"),
                                    fieldWithPath("picture.smallPictureUrl").type(JsonFieldType.STRING).description("회원 작은 사진 URL"),
                                    fieldWithPath("picture.largePictureUrl").type(JsonFieldType.STRING).description("회원 큰 사진 URL")
                            )
                    ));
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:34,代码来源:AuthMvcTests.java


示例20: noteUpdateExample

import org.springframework.restdocs.payload.JsonFieldType; //导入依赖的package包/类
@Test
public void noteUpdateExample() throws Exception {
	Map<String, Object> note = new HashMap<String, Object>();
	note.put("title", "REST maturity model");
	note.put("body", "http://martinfowler.com/articles/richardsonMaturityModel.html");

	String noteLocation = this.mockMvc
		.perform(post("/notes")
			.contentType(MediaTypes.HAL_JSON)
			.content(this.objectMapper.writeValueAsString(note)))
		.andExpect(status().isCreated())
		.andReturn().getResponse().getHeader("Location");

	this.mockMvc
		.perform(get(noteLocation))
		.andExpect(status().isOk())
		.andExpect(jsonPath("title", is(note.get("title"))))
		.andExpect(jsonPath("body", is(note.get("body"))))
		.andExpect(jsonPath("_links.self.href", is(noteLocation)))
		.andExpect(jsonPath("_links.note-tags", is(notNullValue())));

	Map<String, String> tag = new HashMap<String, String>();
	tag.put("name", "REST");

	String tagLocation = this.mockMvc
		.perform(post("/tags")
			.contentType(MediaTypes.HAL_JSON)
			.content(this.objectMapper.writeValueAsString(tag)))
		.andExpect(status().isCreated())
		.andReturn().getResponse().getHeader("Location");

	Map<String, 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PrimaryKey类代码示例发布时间:2022-05-23
下一篇:
Java MutationEventImpl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap