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);
}
Aggregations