use of io.cdap.cdap.common.http.DefaultHttpRequestConfig 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.cdap.common.http.DefaultHttpRequestConfig 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.cdap.common.http.DefaultHttpRequestConfig 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.cdap.common.http.DefaultHttpRequestConfig 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.cdap.common.http.DefaultHttpRequestConfig in project cdap by caskdata.
the class DatasetOpExecutorServiceTest method testAdminOp.
private void testAdminOp(DatasetId datasetInstanceId, String opName, int expectedStatus, Object expectedResult) throws IOException {
String path = String.format("/namespaces/%s/data/datasets/%s/admin/%s", datasetInstanceId.getNamespace(), datasetInstanceId.getEntityName(), opName);
URL targetUrl = resolve(path);
HttpResponse response = HttpRequests.execute(HttpRequest.post(targetUrl).build(), new DefaultHttpRequestConfig(false));
DatasetAdminOpResponse body = getResponse(response.getResponseBody());
Assert.assertEquals(expectedStatus, response.getResponseCode());
Assert.assertEquals(expectedResult, body.getResult());
}
Aggregations