use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class DataPipelineServiceTest method addConnection.
private void addConnection(String connection, ConnectionCreationRequest creationRequest) throws IOException {
URL validatePipelineURL = serviceURI.resolve(String.format("v1/contexts/%s/connections/%s", NamespaceId.DEFAULT.getNamespace(), connection)).toURL();
HttpRequest request = HttpRequest.builder(HttpMethod.PUT, validatePipelineURL).withBody(GSON.toJson(creationRequest)).build();
HttpResponse response = HttpRequests.execute(request, new DefaultHttpRequestConfig(false));
Assert.assertEquals(200, response.getResponseCode());
}
use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class DataPipelineServiceTest method testValidatePipelineBadPipelineArtifact.
@Test
public void testValidatePipelineBadPipelineArtifact() throws IOException {
ETLBatchConfig config = ETLBatchConfig.builder().addStage(new ETLStage("src", MockSource.getPlugin("dummy1"))).addStage(new ETLStage("sink", MockSink.getPlugin("dummy2"))).addConnection("src", "sink").build();
ArtifactSummary badArtifact = new ArtifactSummary("ghost", "1.0.0");
AppRequest<ETLBatchConfig> appRequest = new AppRequest<>(badArtifact, config);
URL validatePipelineURL = serviceURI.resolve(String.format("v1/contexts/%s/validations/pipeline", NamespaceId.DEFAULT.getNamespace())).toURL();
HttpRequest request = HttpRequest.builder(HttpMethod.POST, validatePipelineURL).withBody(GSON.toJson(appRequest)).build();
HttpResponse response = HttpRequests.execute(request, new DefaultHttpRequestConfig(false));
Assert.assertEquals(400, response.getResponseCode());
}
use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class DataPipelineServiceTest method testValidatePipelineChecksNamespaceExistence.
@Test
public void testValidatePipelineChecksNamespaceExistence() throws IOException {
ETLBatchConfig config = ETLBatchConfig.builder().addStage(new ETLStage("src", MockSource.getPlugin("dummy1"))).addStage(new ETLStage("sink", MockSink.getPlugin("dummy2"))).addConnection("src", "sink").build();
ArtifactSummary badArtifact = new ArtifactSummary("ghost", "1.0.0");
AppRequest<ETLBatchConfig> appRequest = new AppRequest<>(badArtifact, config);
URL validatePipelineURL = serviceURI.resolve("v1/contexts/ghost/validations/pipeline").toURL();
HttpRequest request = HttpRequest.builder(HttpMethod.POST, validatePipelineURL).withBody(GSON.toJson(appRequest)).build();
HttpResponse response = HttpRequests.execute(request, new DefaultHttpRequestConfig(false));
Assert.assertEquals(404, response.getResponseCode());
}
use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class DataPipelineServiceTest method sendRequest.
private StageValidationResponse sendRequest(StageValidationRequest requestBody) throws IOException {
URL validatePipelineURL = serviceURI.resolve(String.format("v1/contexts/%s/validations/stage", NamespaceId.DEFAULT.getNamespace())).toURL();
HttpRequest request = HttpRequest.builder(HttpMethod.POST, validatePipelineURL).withBody(GSON.toJson(requestBody)).build();
HttpResponse response = HttpRequests.execute(request, new DefaultHttpRequestConfig(false));
Assert.assertEquals(200, response.getResponseCode());
return GSON.fromJson(response.getResponseBodyAsString(), StageValidationResponse.class);
}
use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class DatasetServiceTestBase method deployModuleBundled.
// creates a bundled jar with moduleClass and list of bundleEmbeddedJar files, moduleName and moduleClassName are
// used to make request for deploying module.
protected int deployModuleBundled(String moduleName, String moduleClassName, Class moduleClass, Location... bundleEmbeddedJars) throws IOException {
Location moduleJar = createModuleJar(moduleClass, bundleEmbeddedJars);
HttpRequest request = HttpRequest.put(getUrl("/data/modules/" + moduleName)).addHeader("X-Class-Name", moduleClassName).withBody((ContentProvider<? extends InputStream>) moduleJar::getInputStream).build();
return HttpRequests.execute(request, REQUEST_CONFIG).getResponseCode();
}
Aggregations