Java Code Examples for org.springframework.test.web.servlet.ResultActions#andDo()

The following examples show how to use org.springframework.test.web.servlet.ResultActions#andDo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventControllerTest.java    From WeBASE-Front with Apache License 2.0 6 votes vote down vote up
/**
	 * need to create exchange and queue with routing key in mq
	 * @throws Exception
	 */
	@Test
	public void testRegisterContractEvent() throws Exception {
		ReqContractEventRegister param = new ReqContractEventRegister();
		param.setGroupId(groupId);
		param.setAppId("app1");
		param.setExchangeName("group001");
		param.setQueueName("user1");
		String abiStr = "[{\"constant\":false,\"inputs\":[{\"name\":\"n\",\"type\":\"string\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"name\",\"type\":\"string\"}],\"name\":\"SetName\",\"type\":\"event\"}]";
		List<Object> abi = JsonUtils.toJavaObjectList(abiStr, Object.class);
		param.setContractAbi(abi);
		param.setFromBlock("latest");
		param.setToBlock("latest");
		param.setContractAddress("0x657201d59ec41d1dc278a67916f751f86ca672f7");
		List<String> topics = new ArrayList<>();
		topics.add("SetName(string)");
		param.setTopicList(topics);
		ResultActions resultActions = mockMvc
				.perform(MockMvcRequestBuilders.post("/event/contractEvent").
						content(JsonUtils.toJSONString(param)).
						contentType(MediaType.APPLICATION_JSON)
				);
		resultActions.
//				andExpect(MockMvcResultMatchers.status().isOk()).
				andDo(MockMvcResultHandlers.print());
	}
 
Example 2
Source File: GroupControllerTest.java    From WeBASE-Node-Manager with Apache License 2.0 6 votes vote down vote up
@Test
    public void testGroupStatusList() throws Exception {
        ReqGroupStatus param = new ReqGroupStatus();
        List<Integer> groupIdList = new ArrayList<>();
        groupIdList.add(2020);
        groupIdList.add(3);
        groupIdList.add(1);
        groupIdList.add(2021);
        groupIdList.add(2023);
        param.setGroupIdList(groupIdList);
        List<String> nodeIdList = new ArrayList<>();
        nodeIdList.add(targetNodeId);
        param.setNodeIdList(nodeIdList);
        ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders
                .post("/group/queryGroupStatus/list")
                .content(JsonTools.toJSONString(param))
                .contentType(MediaType.APPLICATION_JSON_UTF8)
        );
        resultActions.
//                andExpect(MockMvcResultMatchers.status().isOk()).
                andDo(MockMvcResultHandlers.print());
        System.out.println("=================================response:"+resultActions.andReturn().getResponse().getContentAsString());
    }
 
Example 3
Source File: SpeakerControllerTest.java    From springrestdoc with MIT License 6 votes vote down vote up
@Test
public void testGetAllSpeakers() throws Exception {
    //Given
    Speaker josh = given.speaker("Josh Long").company("Pivotal").save();
    Speaker venkat = given.speaker("Venkat Subramaniam").company("Agile").save();

    //When
    ResultActions action = mockMvc.perform(
            get("/speakers").accept(MediaTypes.HAL_JSON));

    //Then
    action.andDo(print()).andExpect(status().isOk());
    action.andDo(document("{class-name}/{method-name}",
            responseFields(
                    fieldWithPath("_embedded").description("'speakers' array with Speakers resources."),
                    fieldWithPath("_embedded.speakers").description("Array with returned Speaker resources."),
                    fieldWithPath("_embedded.speakers[].name").description("Speaker's name."),
                    fieldWithPath("_embedded.speakers[].company").description("Speaker's company."),
                    fieldWithPath("_embedded.speakers[].status").description("Speaker's status name."),
                    fieldWithPath("_embedded.speakers[]._links").description("Link section."),
                    subsectionWithPath("_embedded.speakers[]._links").description("<<resources-tags-links, " +
                            "HATEOAS Links>> to Speaker actions")
            )

    ));
}
 
Example 4
Source File: ContentVersioningControllerIntegrationTest.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
private ResultActions postContent(String fileName, String accessToken, ResultMatcher expected, String... replacements) throws Exception {
    InputStream isJsonPostValid = getClass().getResourceAsStream(fileName);
    String jsonPostValid = FileTextReader.getText(isJsonPostValid);
    if (replacements != null) {
        for (int i = replacements.length-1; i >= 0; i--) {
            StringBuilder sb = new StringBuilder(PLACEHOLDER_STRING);
            if (i > 0) {
                sb.append(i+1);
            }
            jsonPostValid = jsonPostValid.replace(sb.toString(), replacements[i]);
        }
    }
    ResultActions result = mockMvc
            .perform(post("/plugins/cms/contents")
                    .content(jsonPostValid)
                    .contentType(MediaType.APPLICATION_JSON_VALUE)
                    .header("Authorization", "Bearer " + accessToken));
    result.andDo(print());
    result.andExpect(expected);
    return result;
}
 
Example 5
Source File: SpeakerControllerTest.java    From springrestdoc with MIT License 6 votes vote down vote up
@Test
public void testCreateSpeaker_conflict() throws Exception {
    //Given
    Speaker josh = given.speaker("Josh Long").company("Pivotal").save();
    String requestBody = given.asJsonString(given.speakerDto("Josh Long").company("Pivotal").build());

    //When
    ResultActions action = mockMvc.perform(post("/speakers").content(requestBody));
    action.andDo(print());

    //Then
    assertEquals(1, speakerRepository.count());
    action.andExpect(status().isConflict());
    action.andExpect(jsonPath("content", is("Entity  Speaker with name 'Josh Long' already present in DB.")));
    action.andDo(document("{class-name}/{method-name}",
            responseFields(
                    fieldWithPath("content").description("Errors that were found during validation."))));
}
 
Example 6
Source File: StoreOperationControllerExceptionIntegrationTest.java    From evernote-rest-webapp with Apache License 2.0 6 votes vote down vote up
@Test
public void testForwardingToError() throws Exception {

	EvernoteException evernoteException = new EvernoteException("MESSAGE", new EDAMUserException());

	MockHttpServletRequest request = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();

	// mimic how exception info is registered in logic
	((HandlerExceptionResolver) errorAttributes).resolveException(request, response, null, evernoteException);
	request.setAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE, HttpStatus.BAD_REQUEST.value()); // return error 400

	MockHttpServletRequestBuilder requestBuilder = post("/error");
	copyRequestAttributes(requestBuilder, request);

	ResultActions result = mockMvc.perform(requestBuilder.contentType(MediaType.APPLICATION_JSON));
	result.andDo(print());
	result.andExpect(status().isBadRequest());
	result.andExpect(jsonPath("$.timestamp").exists());
	result.andExpect(jsonPath("$.status").value(400));
	result.andExpect(jsonPath("$.error").exists());
	result.andExpect(jsonPath("$.exception").exists());
	result.andExpect(jsonPath("$.message").value("MESSAGE"));

}
 
Example 7
Source File: GuiFragmentControllerIntegrationTest.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testGetFragments_1() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    ResultActions result = mockMvc
            .perform(get("/fragments")
                    .header("Authorization", "Bearer " + accessToken));
    result.andDo(print());
    result.andExpect(status().isOk());
    result.andExpect(jsonPath("$.payload", Matchers.hasSize(1)));
    result.andExpect(jsonPath("$.errors", Matchers.hasSize(0)));
    result.andExpect(jsonPath("$.metaData.page", is(1)));
    result.andExpect(jsonPath("$.metaData.pageSize", is(100)));
    result.andExpect(jsonPath("$.metaData.totalItems", is(1)));

    result.andExpect(jsonPath("$.payload[0].widgetType.code", is("login_form")));
    result.andExpect(jsonPath("$.payload[0].widgetType.title", is("Widget di Login")));

    RestListRequest restListReq = new RestListRequest();
    restListReq.setPage(1);
    restListReq.setPageSize(4);
    testCors("/fragments");
}
 
Example 8
Source File: VersioningConfigurationControllerIntegrationTest.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ResultActions putVersioningConfiguration(String fileName,String accessToken, ResultMatcher expected) throws Exception {
    InputStream jsonStream = getClass().getResourceAsStream(fileName);
    String json = FileTextReader.getText(jsonStream);
    ResultActions result = mockMvc
            .perform(put("/plugins/versioning/configuration")
                    .content(json)
                    .contentType(MediaType.APPLICATION_JSON_VALUE)
                    .header("Authorization", "Bearer " + accessToken));
    result.andDo(print());
    result.andExpect(expected);
    return result;
}
 
Example 9
Source File: ContentVersioningControllerIntegrationTest.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ResultActions putContent(String fileName, String contentId,String accessToken, ResultMatcher expected) throws Exception {
    InputStream jsonStream = getClass().getResourceAsStream(fileName);
    String json = FileTextReader.getText(jsonStream).replaceAll("CONTENT_ID", contentId);;
    ResultActions result = mockMvc
            .perform(put("/plugins/cms/contents")
                    .content(json)
                    .contentType(MediaType.APPLICATION_JSON_VALUE)
                    .header("Authorization", "Bearer " + accessToken));
    result.andDo(print());
    result.andExpect(expected);
    return result;
}
 
Example 10
Source File: VisitsViewTests.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindVisitsInXmlFormat() throws Exception {
    ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.TEXT_XML));
    actions.andDo(print()); // action is logged into the console
    
    // TODO: there seems to be a conflict between this code and the new namespace <mvc:content-negotiation />
    // actions.andExpect(status().isOk());
    //actions.andExpect(content().contentType("application/xml"));
    // actions.andExpect(xpath("/vets/vetList[id=1]/firstName").string(containsString("James")));

}
 
Example 11
Source File: VisitsViewTests.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
@Test
public void shouldFindVisitsInXmlFormat() throws Exception {
    ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.TEXT_XML));
    actions.andDo(print()); // action is logged into the console
    
    // TODO: there seems to be a conflict between this code and the new namespace <mvc:content-negotiation />
    // actions.andExpect(status().isOk());
    //actions.andExpect(content().contentType("application/xml"));
    // actions.andExpect(xpath("/vets/vetList[id=1]/firstName").string(containsString("James")));

}
 
Example 12
Source File: SpeakerControllerTest.java    From springrestdoc with MIT License 5 votes vote down vote up
@Test
public void testAllSpeakers() throws Exception {
    //Given-When
    ResultActions actions = mockMvc.perform(get("/speakers/{id}", 1L))
            .andDo(print());
    actions.andExpect(jsonPath("$.name", CoreMatchers.is("Name1")))
            .andExpect(jsonPath("$.age", CoreMatchers.is("1")))
            .andExpect(jsonPath("$.company", CoreMatchers.is("company")));

    //Then
    actions.andDo(document("{class-name}/{method-name}",
            responseFields(fieldWithPath("name").description("Speakers name"),
                    fieldWithPath("age").description("Age"),
                    fieldWithPath("company").description("The company that speaker is working on."))));
}
 
Example 13
Source File: SpeakerControllerTest.java    From springrestdoc with MIT License 5 votes vote down vote up
@Test
public void testGetSpeakerTopics() throws Exception {
    // Given
    Topic[] topics = {given.topic("Java9").description("Comming soon.").build(),
            given.topic("Spring").description("Pivotal").build()};

    Speaker savedSpeaker = given.speaker("SpeakerName").company("Company")
            .topics(topics).save();

    // When
    ResultActions actions = mockMvc.perform(get("/speakers/{id}/topics", savedSpeaker.getId()))
            .andDo(print());

    // Then
    assertEquals(1, speakerRepository.count());
    assertEquals(2, topicRepository.count());
    actions.andExpect(status().isOk())
            .andExpect(jsonPath("$._embedded.topics.length()", is(topics.length)))
            .andExpect(jsonPath("$._embedded.topics[1].name").value(is("Spring")))
            .andExpect(jsonPath("$._embedded.topics[*].name",
                    containsInAnyOrder("Spring", "Java9")))
            .andExpect(jsonPath("$._embedded.topics[*].description",
                    containsInAnyOrder("Comming soon.", "Pivotal"))
            );
    actions.andDo(document("{class-name}/{method-name}",
            responseFields(
                    fieldWithPath("_embedded").description("'topics' array with Topic resources"),
                    fieldWithPath("_embedded.topics").description("Array of topics that are associated with " +
                            "speaker"),
                    fieldWithPath("_embedded.topics[].name").description("Topic name"),
                    fieldWithPath("_embedded.topics[].description").description("Topic description"),
                    fieldWithPath("_embedded.topics[]._links").description("Link section"),
                    subsectionWithPath("_embedded.topics[]._links").description("HATEOAS links")

            )));
}
 
Example 14
Source File: SpeakerControllerTest.java    From springrestdoc with MIT License 5 votes vote down vote up
@Test
public void testCreateSpeaker_validationFails() throws Exception {
    //Given
    Speaker josh = given.speaker("Josh Long").company("Pivotal").save();
    String requestBody = given.asJsonString(given.speakerDto("Josh Long").build());

    //When
    ResultActions action = mockMvc.perform(post("/speakers").content(requestBody));
    action.andDo(print());

    //Then
    assertEquals(1, speakerRepository.count());
    action.andExpect(status().isUnprocessableEntity())
            .andExpect(jsonPath("$._embedded.length()", is(1)))
            .andExpect(jsonPath("$._embedded.validationErrors[0].property", is("company")))
            .andExpect(jsonPath("$._embedded.validationErrors[0].message", is("may not be empty")))
            .andExpect(jsonPath("$._embedded.validationErrors[0].invalidValue", is("null")));

    action.andDo(document("{class-name}/{method-name}",
            responseFields(
                    fieldWithPath("_embedded.validationErrors").description("Errors that were found during " +
                            "validation."),
                    fieldWithPath("_embedded.validationErrors[].property").description("Invalid property name of " +
                            "posted json entity."),
                    fieldWithPath("_embedded.validationErrors[].message").description("The message, extracted " +
                            "from validation provider exception."),
                    fieldWithPath("_embedded.validationErrors[].invalidValue").description("Invalid value that " +
                            "had not passed validation"))));
}
 
Example 15
Source File: SpeakerControllerTest.java    From springrestdoc with MIT License 5 votes vote down vote up
@Test
public void testCreateSpeaker_created() throws Exception {
    // Given
    SpeakerDto requestDto = given.speakerDto("Josh Long").company("Pivotal").build();
    String requestBody = given.asJsonString(requestDto);

    // When
    ResultActions action = mockMvc.perform(RestDocumentationRequestBuilders.post("/speakers")
            .content(requestBody))
            .andDo(print());

    // Then
    assertEquals(1, speakerRepository.count());
    Speaker savedSpeaker = speakerRepository.findByName("Josh Long").get();

    assertEquals(requestDto.getName(), savedSpeaker.getName());
    assertEquals(requestDto.getCompany(), savedSpeaker.getCompany());

    action.andExpect(status().isCreated())
            .andExpect(header().string("Location", endsWith("/speakers/" + savedSpeaker.getId())));

    ConstrainedFields constrainedFields = new ConstrainedFields(SpeakerDto.class);

    action.andDo(document("{class-name}/{method-name}",
            requestFields(
                    attributes(key("title").value("SpeakerDTO Constrains")),
                    constrainedFields.name("name").description("The speaker's name."),
                    constrainedFields.name("company").description("The company speaker is working on.")
            ),
            responseHeaders(
                    headerWithName("Location").description("URI path to created resource."))));
}
 
Example 16
Source File: SpeakerControllerTest.java    From springrestdoc with MIT License 5 votes vote down vote up
@Test
public void testDeleteSpeaker() throws Exception {
    //Given
    Speaker speakerToDelete = given.speaker("TO_DELETE").company("COMPANY").save();

    //When
    ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders.delete("/speakers/{id}", speakerToDelete.getId()))
            .andDo(print());

    //Then
    actions.andExpect(status().isNoContent());
    actions.andDo(document("{class-name}/{method-name}"));
    assertEquals(0, speakerRepository.count());
}
 
Example 17
Source File: SpeakerControllerTest.java    From springrestdoc with MIT License 5 votes vote down vote up
@Test
public void testGetSpeaker() throws Exception {
    //Given
    Speaker josh = given.speaker("Josh Long").company("Pivotal").save();
    Speaker noiseData = given.speaker("Noise").company("Noise").save();

    //When
    ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders.get("/speakers/{id}", josh.getId()))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.name", is("Josh Long")))
            .andExpect(jsonPath("$.company", is("Pivotal")))
            .andDo(print());

    actions.andDo(document("{class-name}/{method-name}",
            responseFields(
                    fieldWithPath("name").description("Speaker's name"),
                    fieldWithPath("status").description("Speaker's name"),
                    fieldWithPath("company").description("Speaker's name"),
                    subsectionWithPath("_links").description("<<resources-tags-links, Links>> to Speakers HATEOAS")
            ),
            links(halLinks(),
                    linkWithRel("self").description("Link to self"),
                    linkWithRel("topics").description("Link to speaker's topics.")),
            pathParameters(
                    parameterWithName("id").description("Required identifier of Speaker")
            )
    ));
}
 
Example 18
Source File: AdsHttpApiWithDocsTests.java    From spring-rest-black-market with MIT License 4 votes vote down vote up
@Test
public void createAd() throws Exception {
    Ad ad = ad();
    String requestBody = saveRequestJsonString(ad);

    ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders
            .post("/ads")
            .accept(MediaTypes.HAL_JSON)
            .content(requestBody)
            .contentType(MediaType.APPLICATION_JSON)
            .with(user(userDetailsService.loadUserByUsername(Admin.HONTAREVA))));

    final Ad createdBooking = findCreatedBooking();
    resultActions.andExpect(status().isCreated())
            .andExpect(header().string(HttpHeaders.LOCATION, "http://localhost:8080/ads/" + createdBooking.getId()))
            .andExpect(jsonPath("$.id", is(createdBooking.getId().intValue())))
            .andExpect(jsonPath("$.type", is(createdBooking.getType().name())))
            .andExpect(jsonPath("$.amount", is(createdBooking.getAmount().intValue())))
            .andExpect(jsonPath("$.currency", is(createdBooking.getCurrency().name())))
            .andExpect(jsonPath("$.rate", is(createdBooking.getRate().doubleValue())))
            .andExpect(jsonPath("$.location.city", is(createdBooking.getLocation().getCity())))
            .andExpect(jsonPath("$.location.area", is(createdBooking.getLocation().getArea())))
            .andExpect(jsonPath("$.comment", is(createdBooking.getComment())))
            .andExpect(jsonPath("$.publishedAt", is(nullValue())))
            .andExpect(jsonPath("$.status", is(createdBooking.getStatus().name())));

    resultActions.andDo(document("create-ad",
            links(halLinks(),
                    linkWithRel("curies").description("CUR-ies"),
                    linkWithRel("self").description("This ad"),
                    linkWithRel("black-market:ad").description("This <<ads, ad>>"),
                    linkWithRel("black-market:user").description("Author of this ad"),
                    linkWithRel("black-market:update").description("Updates this ad via PATCH"),
                    linkWithRel("black-market:deletion").description("Deletes this ad via DELETE"),
                    linkWithRel("black-market:publishing").description("Publishes this ad via POST with empty body")
            ),
            responseFields(
                    fieldWithPath("_links").type(JsonFieldType.OBJECT).description("Links"),
                    fieldWithPath("id").type(JsonFieldType.NUMBER).description("Unique ad id"),
                    fieldWithPath("type").type(JsonFieldType.STRING).description("Type of the ad, one of: " +
                            Stream.of(Ad.Type.values()).map(Enum::name).collect(Collectors.joining(", "))),
                    fieldWithPath("amount").type(JsonFieldType.NUMBER).description("Amount to buy or sell"),
                    fieldWithPath("currency").type(JsonFieldType.STRING).description("Type of the currency"),
                    fieldWithPath("rate").type(JsonFieldType.NUMBER).description("Suggested exchange rate"),
                    fieldWithPath("location.city").type(JsonFieldType.STRING).description("City"),
                    fieldWithPath("location.area").type(JsonFieldType.STRING).description("Area of the city to meet"),
                    fieldWithPath("comment").type(JsonFieldType.STRING).description("Arbitrary comment"),
                    fieldWithPath("publishedAt").description("Publishing time"),
                    fieldWithPath("status").type(JsonFieldType.STRING).description("Formal ad status, one of " +
                            Stream.of(Ad.Status.values()).map(Enum::name).collect(Collectors.joining(", ")))
            )));
}
 
Example 19
Source File: AdsHttpApiWithDocsTests.java    From spring-rest-black-market with MIT License 4 votes vote down vote up
@Test
public void publishAd() throws Exception {
    final Ad ad = adRepository.save(ad());

    ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders
            .put("/ads/" + ad.getId() + "/publishing")
            .accept(MediaTypes.HAL_JSON)
            .with(user(userDetailsService.loadUserByUsername(Admin.HONTAREVA))));

    final Ad publishedBooking = adRepository.findOne(ad.getId());
    resultActions.andExpect(status().is2xxSuccessful())
            .andExpect(jsonPath("$.id", is(publishedBooking.getId().intValue())))
            .andExpect(jsonPath("$.type", is(publishedBooking.getType().name())))
            .andExpect(jsonPath("$.amount", is(publishedBooking.getAmount().intValue())))
            .andExpect(jsonPath("$.currency", is(publishedBooking.getCurrency().name())))
            .andExpect(jsonPath("$.rate", is(publishedBooking.getRate().doubleValue())))
            .andExpect(jsonPath("$.location.city", is(publishedBooking.getLocation().getCity())))
            .andExpect(jsonPath("$.location.area", is(publishedBooking.getLocation().getArea())))
            .andExpect(jsonPath("$.comment", is(publishedBooking.getComment())))
            .andExpect(jsonPath("$.publishedAt", is(not(nullValue()))))
            .andExpect(jsonPath("$.status", is(publishedBooking.getStatus().name())));

    resultActions.andDo(document("publish-ad",
            links(halLinks(),
                    linkWithRel("curies").description("CUR-ies"),
                    linkWithRel("self").description("This ad"),
                    linkWithRel("black-market:ad").description("This <<ads, ad>>"),
                    linkWithRel("black-market:user").description("Author of this ad"),
                    linkWithRel("black-market:expiration").description("Expires this ad via POST")
            ),
            responseFields(
                    fieldWithPath("_links").type(JsonFieldType.OBJECT).description("Links"),
                    fieldWithPath("id").type(JsonFieldType.NUMBER).description("Unique ad id"),
                    fieldWithPath("type").type(JsonFieldType.STRING).description("Type of the ad, one of: " +
                            Stream.of(Ad.Type.values()).map(Enum::name).collect(Collectors.joining(", "))),
                    fieldWithPath("amount").type(JsonFieldType.NUMBER).description("Amount to buy or sell"),
                    fieldWithPath("currency").type(JsonFieldType.STRING).description("Type of the currency"),
                    fieldWithPath("rate").type(JsonFieldType.NUMBER).description("Suggested exchange rate"),
                    fieldWithPath("location.city").type(JsonFieldType.STRING).description("City"),
                    fieldWithPath("location.area").type(JsonFieldType.STRING).description("Area of the city to meet"),
                    fieldWithPath("comment").type(JsonFieldType.STRING).description("Arbitrary comment"),
                    fieldWithPath("publishedAt").description("Publishing time"),
                    fieldWithPath("status").type(JsonFieldType.STRING).description("Formal ad status, one of " +
                            Stream.of(Ad.Status.values()).map(Enum::name).collect(Collectors.joining(", ")))
            )));
}