當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。