Search in sources :

Example 1 with DraftNotFoundException

use of io.cdap.cdap.datapipeline.draft.DraftNotFoundException in project cdap by caskdata.

the class DraftServiceTest method testGetDraftError.

@Test
public void testGetDraftError() throws IOException {
    // Attempt to fetch an invalid draft from a valid namespace
    NamespaceSummary namespace = new NamespaceSummary(NamespaceId.DEFAULT.getNamespace(), "", 0);
    DraftId invalidId = new DraftId(namespace, "non-existent", "");
    HttpResponse response = fetchDraft(invalidId);
    DraftNotFoundException draftError = new DraftNotFoundException(invalidId);
    Assert.assertEquals(404, response.getResponseCode());
    Assert.assertEquals(draftError.getMessage(), response.getResponseBodyAsString());
    // Attempt to fetch a valid draft but invalid namespace
    DraftId draftId = new DraftId(namespace, "test-draft", "");
    createBatchPipelineDraft(draftId, "TestPipeline1", "This is a test pipeline.");
    NamespaceSummary invalidNamespace = new NamespaceSummary("non-existent", "", 0);
    response = fetchDraft(new DraftId(invalidNamespace, "test-draft", ""));
    Assert.assertEquals(500, response.getResponseCode());
    // Sanity check, get the draft we just created
    getDraft(draftId);
    // Clean up
    deleteDraftAndCheck(draftId);
}
Also used : DraftNotFoundException(io.cdap.cdap.datapipeline.draft.DraftNotFoundException) HttpResponse(io.cdap.common.http.HttpResponse) NamespaceSummary(io.cdap.cdap.api.NamespaceSummary) DraftId(io.cdap.cdap.datapipeline.draft.DraftId) Test(org.junit.Test)

Aggregations

NamespaceSummary (io.cdap.cdap.api.NamespaceSummary)1 DraftId (io.cdap.cdap.datapipeline.draft.DraftId)1 DraftNotFoundException (io.cdap.cdap.datapipeline.draft.DraftNotFoundException)1 HttpResponse (io.cdap.common.http.HttpResponse)1 Test (org.junit.Test)1