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