Search in sources :

Example 1 with RESTClient

use of co.cask.cdap.client.util.RESTClient in project cdap by caskdata.

the class MetadataHttpHandlerTestRun method testScopeQueryParam.

@Test
public void testScopeQueryParam() throws Exception {
    appClient.deploy(NamespaceId.DEFAULT, createAppJarFile(WordCountApp.class));
    ApplicationId app = NamespaceId.DEFAULT.app(WordCountApp.class.getSimpleName());
    RESTClient restClient = new RESTClient(clientConfig);
    URL url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "apps/WordCountApp/metadata?scope=system");
    Assert.assertEquals(HttpResponseStatus.OK.getCode(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
    url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "datasets/mydataset/metadata/properties?scope=SySTeM");
    Assert.assertEquals(HttpResponseStatus.OK.getCode(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
    url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "apps/WordCountApp/flows/WordCountFlow/metadata/tags?scope=USER");
    Assert.assertEquals(HttpResponseStatus.OK.getCode(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
    url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "streams/text/metadata?scope=user");
    Assert.assertEquals(HttpResponseStatus.OK.getCode(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
    url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "streams/text/metadata?scope=blah");
    Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.getCode(), restClient.execute(HttpRequest.get(url).build(), null, HttpResponseStatus.BAD_REQUEST.getCode()).getResponseCode());
    appClient.delete(app);
    // deleting the app does not delete the dataset and stream, delete them explicitly to clear their system metadata
    datasetClient.delete(NamespaceId.DEFAULT.dataset("mydataset"));
    streamClient.delete(NamespaceId.DEFAULT.stream("text"));
}
Also used : RESTClient(co.cask.cdap.client.util.RESTClient) WordCountApp(co.cask.cdap.WordCountApp) ApplicationId(co.cask.cdap.proto.id.ApplicationId) URL(java.net.URL) Test(org.junit.Test)

Example 2 with RESTClient

use of co.cask.cdap.client.util.RESTClient in project cdap by caskdata.

the class ArtifactClientTestRun method setUp.

@Before
public void setUp() throws Throwable {
    super.setUp();
    artifactClient = new ArtifactClient(clientConfig, new RESTClient(clientConfig));
    for (ArtifactSummary artifactSummary : artifactClient.list(NamespaceId.DEFAULT)) {
        artifactClient.delete(NamespaceId.DEFAULT.artifact(artifactSummary.getName(), artifactSummary.getVersion()));
    }
}
Also used : RESTClient(co.cask.cdap.client.util.RESTClient) ArtifactSummary(co.cask.cdap.api.artifact.ArtifactSummary) Before(org.junit.Before)

Aggregations

RESTClient (co.cask.cdap.client.util.RESTClient)2 WordCountApp (co.cask.cdap.WordCountApp)1 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)1 ApplicationId (co.cask.cdap.proto.id.ApplicationId)1 URL (java.net.URL)1 Before (org.junit.Before)1 Test (org.junit.Test)1