Replace factory with builder when creating operation requests/responses

Open
#886 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
java

Research direction

Start by locating OperationRequestFactory and OperationResponseFactory and their usages, especially in custom pre-processors. Compare the proposed builders with the existing factory inputs and defaults; done should mean request and response creation can use builders while preserving existing behavior and simplifying those call sites.

Written by the indexing model from the issue text.

Description

status: blocked type: enhancement

Both the OperationRequestFactory and OperationResponseFactory leads to unnecessary code in custom pre-processors:

new OperationRequestFactory().create(
  uri,
  request.getMethod(),
  request.getContent(),
  headers,
  request.getParts(),
  cookies
);

A possible way to simplify the request creation is to use the Builder design pattern:

new OperationRequestBuider(request)
  .withUri(uri)
  .withHeaders(headers)
  .withCookies(cookies)
  .build();

The OperationRequestBuilder will builds the new request using the request argument fields as defaults, like a StringBuilder.

Dominant language
Java
Stars
1.2k
Forks
731
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spring-projects/spring-restdocs

All issues in spring-projects/spring-restdocs

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.