@Test public void testDefaultBuild() { Date before=new Date(); HttpRequest build=sut().build(); Date after=new Date(); assertDateIsInRange(before, after, build.serverDate()); assertThat(build.clientDate(),nullValue()); verifyDefaultValues(build); }
public HttpRequest build() { return new ImmutableHttpRequest( checkNotNull(this.method,"Http method cannot be null"), Optional.fromNullable(this.protocolVersion).or(ProtocolVersion.HTTP_1_1), checkNotNull(this.absolutePath,"Absolute path cannot be null"), checkNotNull(this.host,"Host cannot be null"), this.headers, this.body, Optional.fromNullable(this.serverDate).or(new Date()), this.clientDate); }
HttpRequestBuilder { public HttpRequest build() { return new ImmutableHttpRequest( checkNotNull(this.method,"Http method cannot be null"), Optional.fromNullable(this.protocolVersion).or(ProtocolVersion.HTTP_1_1), checkNotNull(this.absolutePath,"Absolute path cannot be null"), checkNotNull(this.host,"Host cannot be null"), this.headers, this.body, Optional.fromNullable(this.serverDate).or(new Date()), this.clientDate); } }
HttpRequestBuilder { public HttpRequest build() { return new ImmutableHttpRequest( checkNotNull(this.method,"Http method cannot be null"), Optional.fromNullable(this.protocolVersion).or(ProtocolVersion.HTTP_1_1), checkNotNull(this.absolutePath,"Absolute path cannot be null"), checkNotNull(this.host,"Host cannot be null"), this.headers, this.body, Optional.fromNullable(this.serverDate).or(new Date()), this.clientDate); } private  HttpRequestBuilder(); }
HttpRequestBuilder { public HttpRequest build() { return new ImmutableHttpRequest( checkNotNull(this.method,"Http method cannot be null"), Optional.fromNullable(this.protocolVersion).or(ProtocolVersion.HTTP_1_1), checkNotNull(this.absolutePath,"Absolute path cannot be null"), checkNotNull(this.host,"Host cannot be null"), this.headers, this.body, Optional.fromNullable(this.serverDate).or(new Date()), this.clientDate); } private  HttpRequestBuilder(); HttpRequestBuilder withMethod(HttpMethod method); HttpRequestBuilder withProtocolVersion(ProtocolVersion version); HttpRequestBuilder withHost(String host); HttpRequestBuilder withAbsolutePath(String absolutePath); HttpRequestBuilder withBody(String entity); HttpRequestBuilder withHeader(String name, String rawValue); HttpRequestBuilder withServerDate(Date date); HttpRequestBuilder withClientDate(Date date); HttpRequest build(); static HttpRequestBuilder newInstance(); }
HttpRequestBuilder { public HttpRequest build() { return new ImmutableHttpRequest( checkNotNull(this.method,"Http method cannot be null"), Optional.fromNullable(this.protocolVersion).or(ProtocolVersion.HTTP_1_1), checkNotNull(this.absolutePath,"Absolute path cannot be null"), checkNotNull(this.host,"Host cannot be null"), this.headers, this.body, Optional.fromNullable(this.serverDate).or(new Date()), this.clientDate); } private  HttpRequestBuilder(); HttpRequestBuilder withMethod(HttpMethod method); HttpRequestBuilder withProtocolVersion(ProtocolVersion version); HttpRequestBuilder withHost(String host); HttpRequestBuilder withAbsolutePath(String absolutePath); HttpRequestBuilder withBody(String entity); HttpRequestBuilder withHeader(String name, String rawValue); HttpRequestBuilder withServerDate(Date date); HttpRequestBuilder withClientDate(Date date); HttpRequest build(); static HttpRequestBuilder newInstance();  }