made blobmetadata parser name accessible for testing

This commit is contained in:
Adrian Cole 2011-02-26 21:48:51 -08:00
parent 00d172ce2f
commit 897dc000d5
1 changed files with 9 additions and 9 deletions

View File

@ -53,7 +53,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
private final DateService dateParser;
private final Provider<MutableBlobMetadata> metadataFactory;
private String key;
private String name;
@Inject
public ParseSystemAndUserMetadataFromHeaders(Provider<MutableBlobMetadata> metadataFactory, DateService dateParser,
@ -65,10 +65,11 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
public MutableBlobMetadata apply(HttpResponse from) {
checkNotNull(from, "request");
checkState(key != null, "key must be initialized by now");
checkState(name != null, "name must be initialized by now");
MutableBlobMetadata to = metadataFactory.get();
to.setName(key);
to.setName(name);
if (from.getPayload() != null)
HttpUtils.copy(from.getPayload().getContentMetadata(), to.getContentMetadata());
addETagTo(from, to);
parseLastModifiedOrThrowException(from, to);
@ -115,12 +116,11 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
public ParseSystemAndUserMetadataFromHeaders setContext(HttpRequest request) {
checkArgument(request instanceof GeneratedHttpRequest<?>, "note this handler requires a GeneratedHttpRequest");
setName(getNameFor(GeneratedHttpRequest.class.cast(request)));
return this;
return setName(getNameFor(GeneratedHttpRequest.class.cast(request)));
}
@VisibleForTesting
void setName(String key) {
this.key = checkNotNull(key, "key");
public ParseSystemAndUserMetadataFromHeaders setName(String name) {
this.name = checkNotNull(name, "name");
return this;
}
}