io.pileworx.rebound.client.builder.DefineResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rebound-client-java Show documentation
Show all versions of rebound-client-java Show documentation
Client library for rebound mock server
The newest version!
package io.pileworx.rebound.client.builder;
import io.pileworx.rebound.client.builder.exception.BodyReadException;
import io.pileworx.rebound.client.definition.Header;
import io.pileworx.rebound.client.definition.Response;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
public class DefineResponse {
public int status;
public List headers;
public String body;
public Path bodyFromFile;
public Map values;
public DefineResponse with(Consumer builderFunction) {
builderFunction.accept(this);
return this;
}
public Response build() {
return new Response(status, headers, getBody(), values);
}
private String getBody() {
try {
return null != bodyFromFile ? new String(Files.readAllBytes(bodyFromFile)) : body;
} catch (IOException e) {
throw new BodyReadException("Failed to load body from file.", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy