congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
RestMockResponse.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.castlemock.core.mock.rest.model.project.domain.RestMockResponse
constructor

Best Java code snippets using com.castlemock.core.mock.rest.model.project.domain.RestMockResponse.<init> (Showing top 14 results out of 315)

origin: castlemock/castlemock

  private RestMockResponse createrestMockResponse(String name) {
    RestMockResponse dto = new RestMockResponse();
    dto.setName(name);
    return dto;
  }
}
origin: castlemock/castlemock

/**
 * The method generates a default response.
 * @return The newly generated {@link RestMockResponse}.
 */
protected RestMockResponse generateResponse(){
  RestMockResponse restMockResponse = new RestMockResponse();
  restMockResponse.setName(AUTO_GENERATED_MOCK_RESPONSE_DEFAULT_NAME);
  restMockResponse.setHttpStatusCode(DEFAULT_RESPONSE_CODE);
  restMockResponse.setStatus(RestMockResponseStatus.ENABLED);
  restMockResponse.setUsingExpressions(true);
  return restMockResponse;
}
origin: castlemock/castlemock

@PreAuthorize("hasAuthority('READER') or hasAuthority('MODIFIER') or hasAuthority('ADMIN')")
@RequestMapping(value = "/{restProjectId}/application/{restApplicationId}/resource/{restResourceId}/method/{restMethodId}/create/response", method = RequestMethod.GET)
public ModelAndView displayCreatePage(@PathVariable final String restProjectId,
                   @PathVariable final String restApplicationId,
                   @PathVariable final String restResourceId,
                   @PathVariable final String restMethodId) {
  final ReadRestMethodOutput output = serviceProcessor.process(ReadRestMethodInput.builder()
      .restProjectId(restProjectId)
      .restApplicationId(restApplicationId)
      .restResourceId(restResourceId)
      .restMethodId(restMethodId).build());
  final ReadRestResourceQueryParametersOutput resourceQueryParameters =
      serviceProcessor.process(ReadRestResourceQueryParametersInput.builder()
          .projectId(restProjectId)
          .applicationId(restApplicationId)
          .resourceId(restResourceId)
          .build());
  final RestMockResponse mockResponse = new RestMockResponse();
  mockResponse.setBody(output.getRestMethod().getDefaultBody());
  mockResponse.setHttpStatusCode(DEFAULT_HTTP_STATUS_CODE);
  final ModelAndView model = createPartialModelAndView(PAGE);
  model.addObject(REST_PROJECT_ID, restProjectId);
  model.addObject(REST_APPLICATION_ID, restApplicationId);
  model.addObject(REST_RESOURCE_ID, restResourceId);
  model.addObject(REST_METHOD_ID, restMethodId);
  model.addObject(REST_MOCK_RESPONSE, mockResponse);
  model.addObject(REST_MOCK_RESPONSE_STATUSES, RestMockResponseStatus.values());
  model.addObject(REST_QUERY_PARAMETERS, resourceQueryParameters.getQueries());
  return model;
}
origin: castlemock/castlemock

/**
 * The method generates a mocked response based on the provided {@link Response} and the
 * <code>httpStatusCode</code>.
 * @param httpStatusCode The HTTP status code that the mocked response will have. Please note that
 *                       any mock response with status code different from OK (200), will be
 *                       marked as disabled.
 * @param response The Swagger response that the mocked response will be based on.
 * @return A new {@link RestMockResponse} based on the provided {@link Response}.
 */
private RestMockResponse generateResponse(final int httpStatusCode, final Response response){
  RestMockResponse restMockResponse = new RestMockResponse();
  restMockResponse.setName(response.getDescription());
  restMockResponse.setHttpStatusCode(httpStatusCode);
  restMockResponse.setUsingExpressions(true);
  if(httpStatusCode == DEFAULT_RESPONSE_CODE){
    restMockResponse.setStatus(RestMockResponseStatus.ENABLED);
  } else {
    restMockResponse.setStatus(RestMockResponseStatus.DISABLED);
  }
  if(response.getHeaders() != null){
    for(Map.Entry<String, Property> headerEntry : response.getHeaders().entrySet()){
      String headerName = headerEntry.getKey();
      HttpHeader httpHeader = new HttpHeader();
      httpHeader.setName(headerName);
      // Swagger does not include an example value for the response.
      restMockResponse.getHttpHeaders().add(httpHeader);
    }
  }
  return restMockResponse;
}
origin: castlemock/castlemock

String responseCode = response.code().value();
int httpStatusCode = super.extractHttpStatusCode(responseCode);
RestMockResponse restMockResponse = new RestMockResponse();
restMockResponse.setName(RESPONSE_NAME_PREFIX + (index + 1));
restMockResponse.setHttpStatusCode(httpStatusCode);
origin: castlemock/castlemock

String responseCode = response.code().value();
int httpStatusCode = super.extractHttpStatusCode(responseCode);
RestMockResponse restMockResponse = new RestMockResponse();
restMockResponse.setName(RESPONSE_NAME_PREFIX + (index + 1));
restMockResponse.setHttpStatusCode(httpStatusCode);
origin: castlemock/castlemock

  public static RestMockResponse generateRestMockResponse(){
    final RestParameterQuery parameterQuery = new RestParameterQuery();
    parameterQuery.setParameter("Parameter");
    parameterQuery.setQuery("Query");
    parameterQuery.setMatchAny(false);
    parameterQuery.setMatchCase(false);
    parameterQuery.setMatchRegex(false);

    final RestMockResponse restMockResponse = new RestMockResponse();
    restMockResponse.setName("Rest mock response name");
    restMockResponse.setBody("Rest mock response body");
    restMockResponse.setId("REST MOCK RESPONSE");
    restMockResponse.setStatus(RestMockResponseStatus.ENABLED);
    restMockResponse.setHttpStatusCode(200);
    restMockResponse.setParameterQueries(ImmutableList.of(parameterQuery));
    return restMockResponse;
  }
}
origin: castlemock/castlemock

/**
 * The method provides the functionality to forward a request to another endpoint. The response
 * will be recorded and can later be used as a mocked response
 * @param restRequest The incoming request
 * @param restMethod The REST method which the incoming request belongs to
 * @return The response received from the external endpoint
 */
protected RestResponse forwardRequestAndRecordResponse(final RestRequest restRequest,
                            final String projectId,
                            final String applicationId,
                            final String resourceId,
                            final RestMethod restMethod,
                            final Map<String, String> pathParameters){
  final RestResponse response = forwardRequest(restRequest, projectId, applicationId, resourceId, restMethod, pathParameters);
  final RestMockResponse mockResponse = new RestMockResponse();
  final Date date = new Date();
  mockResponse.setBody(response.getBody());
  mockResponse.setStatus(RestMockResponseStatus.ENABLED);
  mockResponse.setHttpHeaders(response.getHttpHeaders());
  mockResponse.setName(RECORDED_RESPONSE_NAME + SPACE + DATE_FORMAT.format(date));
  mockResponse.setHttpStatusCode(response.getHttpStatusCode());
  serviceProcessor.processAsync(CreateRestMockResponseInput.builder()
      .projectId(projectId)
      .applicationId(applicationId)
      .resourceId(resourceId)
      .methodId(restMethod.getId())
      .mockResponse(mockResponse)
      .build());
  return response;
}
origin: castlemock/castlemock

@Test
public void projectFunctionalityUpdate() throws Exception {
  final String projectId = "projectId";
  final String applicationId = "applicationId";
  final String resourceId = "resourceId";
  final String methodId = "methjodId";
  final String[] mockResponses = {"restMethod1", "restMethod2"};
  final RestMockResponse restMockResponse1 = new RestMockResponse();
  restMockResponse1.setName("restMockResponse1");
  final RestMockResponse restMockResponse2 = new RestMockResponse();
  restMockResponse2.setName("restMockResponse2");
  Mockito.when(serviceProcessor.process(Mockito.any(ReadRestMockResponseInput.class)))
      .thenReturn(ReadRestMockResponseOutput.builder().restMockResponse(restMockResponse1).build())
      .thenReturn(ReadRestMockResponseOutput.builder().restMockResponse(restMockResponse2).build());
  final RestMockResponseModifierCommand command = new RestMockResponseModifierCommand();
  command.setRestMockResponseIds(mockResponses);
  command.setRestMockResponseStatus("ENABLED");
  final MockHttpServletRequestBuilder message =
      MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH + APPLICATION + SLASH + applicationId + SLASH + RESOURCE + SLASH + resourceId + SLASH + METHOD + SLASH + methodId)
          .param("action", "update").flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.model().size(1))
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/rest/project/" + projectId + "/application/" + applicationId + "/resource/" + resourceId + "/method/" + methodId));
  Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.isA(ReadRestMockResponseInput.class));
  Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.isA(UpdateRestMockResponseInput.class));
}
origin: castlemock/castlemock

@Test
public void testServiceFunctionalityDuplicate() throws Exception {
  final String projectId = "projectId";
  final String applicationId = "applicationId";
  final String resourceId = "resourceId";
  final String methodId = "resourceId";
  final String[] restMockResponseIds = {"MockResponse1", "MockResponse2"};
  final RestMockResponse restMockResponse1 = new RestMockResponse();
  restMockResponse1.setId("MockResponseId1");
  final RestMockResponse restMockResponse2 = new RestMockResponse();
  restMockResponse2.setId("MockResponseId2");
  Mockito.when(serviceProcessor.process(Mockito.any(ReadRestMockResponseInput.class)))
      .thenReturn(ReadRestMockResponseOutput.builder().restMockResponse(restMockResponse1).build())
      .thenReturn(ReadRestMockResponseOutput.builder().restMockResponse(restMockResponse2).build());
  final RestMockResponseModifierCommand command = new RestMockResponseModifierCommand();
  command.setRestMockResponseIds(restMockResponseIds);
  final MockHttpServletRequestBuilder message =
      MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH + APPLICATION
          + SLASH + applicationId + SLASH + RESOURCE + SLASH + resourceId + SLASH + METHOD + SLASH + methodId)
          .param("action", "duplicate").flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.model().size(1))
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/rest/project/" + projectId
          + "/application/" + applicationId + "/resource/" + resourceId
          + "/method/" + methodId));
  Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.isA(ReadRestMockResponseInput.class));
  Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.isA(CreateRestMockResponseInput.class));
}
origin: castlemock/castlemock

final RestMockResponse restMockResponse1 = new RestMockResponse();
restMockResponse1.setName("restMockResponse1");
final RestMockResponse restMockResponse2 = new RestMockResponse();
restMockResponse2.setName("restMockResponse2");
origin: castlemock/castlemock

final RestMockResponse restMockResponse1 = new RestMockResponse();
restMockResponse1.setBody(XML_RESPONSE_BODY);
restMockResponse1.setContentEncodings(new ArrayList<>());
restMockResponse1.setParameterQueries(ImmutableList.of(parameterQuery));
final RestMockResponse restMockResponse2 = new RestMockResponse();
restMockResponse2.setBody(QUERY_DEFAULT_RESPONSE_BODY);
restMockResponse2.setContentEncodings(new ArrayList<>());
origin: castlemock/castlemock

final RestMockResponse restMockResponse = new RestMockResponse();
restMockResponse.setBody(XML_RESPONSE_BODY);
restMockResponse.setContentEncodings(new ArrayList<>());
origin: castlemock/castlemock

RestMockResponse mockResponse = new RestMockResponse();
mockResponse.setId(mockResponseV1.getId());
mockResponse.setName(mockResponseV1.getName());
com.castlemock.core.mock.rest.model.project.domainRestMockResponse<init>

Popular methods of RestMockResponse

  • setName
  • setBody
  • setHttpStatusCode
  • setId
  • setStatus
  • getId
  • getName
  • setHttpHeaders
  • setParameterQueries
  • setUsingExpressions
  • getBody
  • getContentEncodings
  • getBody,
  • getContentEncodings,
  • getHttpHeaders,
  • getHttpStatusCode,
  • getJsonPathExpressions,
  • getMethodId,
  • getStatus,
  • getXpathExpressions,
  • isUsingExpressions

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • getContentResolver (Context)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now