当前位置: 首页>>代码示例>>Java>>正文


Java ResultActions.andDo方法代码示例

本文整理汇总了Java中org.springframework.test.web.servlet.ResultActions.andDo方法的典型用法代码示例。如果您正苦于以下问题:Java ResultActions.andDo方法的具体用法?Java ResultActions.andDo怎么用?Java ResultActions.andDo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.test.web.servlet.ResultActions的用法示例。


在下文中一共展示了ResultActions.andDo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSaveAndGetTrackDataGA4GH

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Ignore
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testSaveAndGetTrackDataGA4GH() throws Exception {

    FileRegistrationRequest request;
    ResultActions actions;
    // 1. tries to save a genome with all parameters
    request = new FileRegistrationRequest();
    request.setPath(REFERENCE_SET_ID);
    request.setType(BiologicalDataItemResourceType.GA4GH);
    request.setName(PLAIN_GENOME_NAME);

    actions = mvc()
            .perform(post(REGISTER_GENOME_IN_FASTA_FORMAT).content(getObjectMapper().writeValueAsString(request))
                    .contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andExpect(MockMvcResultMatchers.content().contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(MockMvcResultMatchers.jsonPath(JPATH_PAYLOAD).exists())
            .andExpect(MockMvcResultMatchers.jsonPath(JPATH_STATUS).value(ResultStatus.OK.name()));
    final Reference ref2 = parseReference(actions.andReturn().getResponse().getContentAsByteArray()).getPayload();
    Assert.assertNotNull("Genome ID shouldn't be null.", ref2.getId());
    Assert.assertEquals("Unexpected auto-generated name for a genome.", PLAIN_GENOME_NAME, ref2.getName());
    actions.andDo(print());
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:26,代码来源:ReferenceControllerTest.java

示例2: test1_2

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test1_2() throws Exception {


    ResultActions actions = mockMvc.perform((post("/jsonp-fastjsonview/test1?callback=fnUpdateSome").characterEncoding(
            "UTF-8").contentType(MediaType.APPLICATION_JSON)));
    actions.andDo(print());
    actions.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/fnUpdateSome({\"id\":100,\"name\":\"测试\"})"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:FastJsonHttpMessageConverterJSONPCaseTest.java

示例3: test2_2

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test2_2() throws Exception {


    ResultActions actions = mockMvc.perform((post("/jsonp-fastjsonview/test2?callback=fnUpdateSome").characterEncoding("UTF-8")
            .contentType(MediaType.APPLICATION_JSON)));
    actions.andDo(print());
    actions.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/fnUpdateSome({\"description\":\"fastjsonview注解测试\",\"stock\":\"haha\"})"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:FastJsonHttpMessageConverterJSONPCaseTest.java

示例4: test4_2

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test4_2() throws Exception {


    ResultActions actions = mockMvc.perform((post("/jsonp-fastjsonview/test4?callback=myUpdate").characterEncoding("UTF-8")
            .contentType(MediaType.APPLICATION_JSON)));
    actions.andDo(print());
    actions.andExpect(status().isOk())
            .andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/myUpdate({\"id\":100,\"name\":\"测试\",\"rootDepartment\":{\"id\":1,\"members\":[],\"name\":\"部门1\"}})"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:FastJsonHttpMessageConverterJSONPCaseTest.java

示例5: test5_2

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test5_2() throws Exception {

    String jsonStr = "{\"packet\":{\"smsType\":\"USER_LOGIN\"}}";

    ResultActions actions = mockMvc.perform((post("/jsonp-fastjsonview/test5?callback=myUpdate").characterEncoding("UTF-8")
            .content(jsonStr).contentType(MediaType.APPLICATION_JSON)));
    actions.andDo(print());
    actions.andExpect(status().isOk())
            .andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/myUpdate(\"{\\\"packet\\\":{\\\"smsType\\\":\\\"USER_LOGIN\\\"}}\")"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:FastJsonHttpMessageConverterJSONPCaseTest.java

示例6: test7

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test7() throws Exception {
    ResultActions actions = this.mockMvc.perform(post("/jsonp-fastjsonview/test7?customizedCallbackParamName=fnUpdateSome"));
    actions.andDo(print());
    actions.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JAVASCRIPT))

            .andExpect(content().string("/**/fnUpdateSome({})"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:FastJsonHttpMessageConverterJSONPCaseTest.java

示例7: test8

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test8() throws Exception {
    String invalidMethodName = "--methodName";
    ResultActions actions = this.mockMvc.perform(post("/jsonp-fastjsonview/test7?customizedCallbackParamName=" + invalidMethodName));
    actions.andDo(print());
    actions.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/null({})"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:FastJsonHttpMessageConverterJSONPCaseTest.java

示例8: testGetSpeakerTopics

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@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")

            )));
}
 
开发者ID:tsypuk,项目名称:springrestdoc,代码行数:37,代码来源:SpeakerControllerTest.java

示例9: testCreateSpeaker_validationFails

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@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"))));
}
 
开发者ID:tsypuk,项目名称:springrestdoc,代码行数:30,代码来源:SpeakerControllerTest.java

示例10: test4_2

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test4_2() throws Exception {

    String jsonStr = "{\"t\":{\"id\":123,\"name\":\"哈哈哈\"}}";

    ResultActions actions = mockMvc.perform((post("/fastjson/test4?callback=myUpdate").characterEncoding("UTF-8")
            .content(jsonStr).contentType(MediaType.APPLICATION_JSON)));
    actions.andDo(print());
    actions.andExpect(status().isOk())
            .andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/myUpdate(\"{\\\"t\\\":{\\\"id\\\":123,\\\"name\\\":\\\"哈哈哈\\\"}}\")"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:FastJsonpHttpMessageConverter4Case1Test.java

示例11: test3_2

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test3_2() throws Exception {
    ResultActions actions = this.mockMvc.perform(post("/fastjson/test3?jsonp=fnUpdateSome"));
    actions.andDo(print());
    actions.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/fnUpdateSome({})"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:FastJsonpHttpMessageConverter4Case1Test.java

示例12: test1_2

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test1_2() throws Exception {

    JSONObject json = new JSONObject();

    json.put("id", 123);

    json.put("name", "哈哈哈");

    ResultActions actions = mockMvc.perform((post("/fastjson/test1?callback=fnUpdateSome").characterEncoding(
            "UTF-8").content(json.toJSONString()).contentType(MediaType.APPLICATION_JSON)));
    actions.andDo(print());
    actions.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/fnUpdateSome({\"name\":\"哈哈哈\",\"id\":123})"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:FastJsonpHttpMessageConverter4Case1Test.java

示例13: test2_2

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test2_2() throws Exception {

    String jsonStr = "[{\"name\":\"p1\",\"sonList\":[{\"name\":\"s1\"}]},{\"name\":\"p2\",\"sonList\":[{\"name\":\"s2\"},{\"name\":\"s3\"}]}]";

    ResultActions actions = mockMvc.perform((post("/fastjson/test2?jsonp=fnUpdateSome").characterEncoding("UTF-8")
            .content(jsonStr).contentType(MediaType.APPLICATION_JSON)));
    actions.andDo(print());
    actions.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JAVASCRIPT))
            .andExpect(content().string("/**/fnUpdateSome({\"p1\":1,\"p2\":2})"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:FastJsonpHttpMessageConverter4Case1Test.java

示例14: test30_AddModuleThenRestart

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void test30_AddModuleThenRestart() throws Exception {
    logger.info("Create an application, add a " + module + " modules, restart");

    // verify if app exists
    ResultActions resultats = mockMvc.perform(get("/application/" + applicationName).session(session).contentType(MediaType.APPLICATION_JSON));
    resultats.andExpect(jsonPath("name").value(applicationName.toLowerCase()));

    // add a first module
    String jsonString = "{\"applicationName\":\"" + applicationName + "\", \"imageName\":\"" + module + "\"}";
    resultats = mockMvc.perform(post("/module")
            .session(session)
            .contentType(MediaType.APPLICATION_JSON)
            .content(jsonString));
    resultats.andDo(print());
    resultats.andExpect(status().isOk());

    // Expected values
    String module1 = NamingUtils.getContainerName(applicationName, module, "johndoe");

    // Stop the application
    jsonString = "{\"applicationName\":\"" + applicationName + "\"}";
    resultats = mockMvc.perform(post("/application/stop").session(session).contentType(MediaType.APPLICATION_JSON).content(jsonString));
    resultats.andDo(print());
    resultats.andExpect(status().isOk());

    // Start the application
    jsonString = "{\"applicationName\":\"" + applicationName + "\"}";
    resultats = mockMvc.perform(post("/application/start").session(session).contentType(MediaType.APPLICATION_JSON).content(jsonString));
    resultats.andDo(print());
    resultats.andExpect(status().isOk());

    // get the detail of the applications to verify modules addition
    resultats = mockMvc.perform(get("/application/" + applicationName)
            .session(session).contentType(MediaType.APPLICATION_JSON)).andDo(print());
    resultats.andDo(print());
    resultats
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.modules[0].status").value("START"))
            .andExpect(jsonPath("$.modules[0].name").value(module1));
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:42,代码来源:AbstractModuleControllerTestIT.java

示例15: testSearchFeature

import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testSearchFeature() throws Exception {
    GeneFile file = addGeneFile(TEST_VCF_FILE_NAME1, TEST_GENE_FILE_PATH);
    BiologicalDataItem item = new BiologicalDataItem();
    item.setId(file.getBioDataItemId());
    ProjectItem projectItem = new ProjectItem();
    projectItem.setBioDataItem(item);

    referenceGenomeManager.updateReferenceGeneFileId(testReference.getId(), file.getId());

    Project project = new Project();
    project.setName(TEST_PROJECT_NAME);
    project.setItems(Arrays.asList(projectItem, new ProjectItem(testReference)));

    ProjectVO projectVO = ProjectConverter.convertTo(project);

    // save project
    ResultActions actions = mvc()
            .perform(post(URL_SAVE_PROJECT).content(getObjectMapper().writeValueAsString(projectVO))
                    .contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andExpect(MockMvcResultMatchers.content().contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(MockMvcResultMatchers.jsonPath(JPATH_PAYLOAD).exists())
            .andExpect(MockMvcResultMatchers.jsonPath(JPATH_STATUS).value(ResultStatus.OK.name()));
    actions.andDo(MockMvcResultHandlers.print());

    ResponseResult<ProjectVO> res = getObjectMapper()
            .readValue(actions.andReturn().getResponse().getContentAsByteArray(),
                    getTypeFactory().constructParametrizedType(ResponseResult.class, ResponseResult.class,
                            ProjectVO.class));

    ProjectVO loadedProject = res.getPayload();
    Assert.assertNotNull(loadedProject);
    Assert.assertFalse(loadedProject.getItems().isEmpty());

    // search by feature "ENSFCAG00000031108"
    actions = mvc()
            .perform(get(String.format(URL_SEARCH_FEATURE, loadedProject.getId()))
                    .param("featureId", TEST_FEATURE_ID)
                    .contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andExpect(MockMvcResultMatchers.content().contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(MockMvcResultMatchers.jsonPath(JPATH_PAYLOAD).exists())
            .andExpect(MockMvcResultMatchers.jsonPath(JPATH_STATUS).value(ResultStatus.OK.name()));
    actions.andDo(MockMvcResultHandlers.print());

    ResponseResult<IndexSearchResult<FeatureIndexEntry>> indexEntriesRes = getObjectMapper()
            .readValue(actions.andReturn().getResponse().getContentAsByteArray(),
                    getTypeFactory().constructParametrizedType(ResponseResult.class, ResponseResult.class,
                            IndexSearchResult.class));

    Assert.assertFalse(indexEntriesRes.getPayload().getEntries().isEmpty());
    Assert.assertTrue(TEST_FEATURE_ID.equalsIgnoreCase(indexEntriesRes.getPayload().getEntries()
            .get(0).getFeatureId()));
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:57,代码来源:ProjectControllerTest.java


注:本文中的org.springframework.test.web.servlet.ResultActions.andDo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。