use of co.cask.cdap.WordCountApp in project cdap by caskdata.
the class DefaultStoreTest method testRemoveAll.
@Test
public void testRemoveAll() throws Exception {
ApplicationSpecification spec = Specifications.from(new WordCountApp());
NamespaceId namespaceId = new NamespaceId("account1");
ApplicationId appId = namespaceId.app("application1");
store.addApplication(appId, spec);
Assert.assertNotNull(store.getApplication(appId));
// removing flow
store.removeAll(namespaceId);
Assert.assertNull(store.getApplication(appId));
}
use of co.cask.cdap.WordCountApp in project cdap by caskdata.
the class DefaultStoreTest method testRemoveApplication.
@Test
public void testRemoveApplication() throws Exception {
ApplicationSpecification spec = Specifications.from(new WordCountApp());
NamespaceId namespaceId = new NamespaceId("account1");
ApplicationId appId = namespaceId.app(spec.getName());
store.addApplication(appId, spec);
Assert.assertNotNull(store.getApplication(appId));
// removing application
store.removeApplication(appId);
Assert.assertNull(store.getApplication(appId));
}
use of co.cask.cdap.WordCountApp in project cdap by caskdata.
the class MetadataHttpHandlerTestRun method testDeletedProgramHandlerStage.
@Test
public void testDeletedProgramHandlerStage() throws Exception {
appClient.deploy(TEST_NAMESPACE1, createAppJarFile(WordCountApp.class));
ProgramId program = TEST_NAMESPACE1.app("WordCountApp").flow("WordCountFlow");
// Set some properties metadata
Map<String, String> flowProperties = ImmutableMap.of("sKey", "sValue", "sK", "sV");
addProperties(program, flowProperties);
// Get properties
Map<String, String> properties = getProperties(program, MetadataScope.USER);
Assert.assertEquals(2, properties.size());
// Deploy WordCount App without Flow program. No need to start/stop the flow.
appClient.deploy(TEST_NAMESPACE1, createAppJarFile(WordCountMinusFlowApp.class));
// Get properties from deleted (flow) program - should return 404
getPropertiesFromInvalidEntity(program);
// Delete the App after stopping the flow
appClient.delete(TEST_NAMESPACE1.app("WordCountApp"));
}
use of co.cask.cdap.WordCountApp 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.code(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "datasets/mydataset/metadata/properties?scope=SySTeM");
Assert.assertEquals(HttpResponseStatus.OK.code(), 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.code(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "streams/text/metadata?scope=user");
Assert.assertEquals(HttpResponseStatus.OK.code(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "streams/text/metadata?scope=blah");
Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.code(), restClient.execute(HttpRequest.get(url).build(), null, HttpResponseStatus.BAD_REQUEST.code()).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.WordCountApp in project cdap by caskdata.
the class MetadataHttpHandlerTestRun method testSearchMetadataDelete.
@Test
public void testSearchMetadataDelete() throws Exception {
NamespaceId namespace = new NamespaceId("ns1");
namespaceClient.create(new NamespaceMeta.Builder().setName(namespace).build());
// Deploy app
appClient.deploy(namespace, createAppJarFile(WordCountApp.class, WordCountApp.class.getSimpleName(), "1.0"));
Set<String> tags = ImmutableSet.of("tag1", "tag2");
ArtifactId artifact = namespace.artifact("WordCountApp", "1.0");
ApplicationId app = namespace.app("WordCountApp");
ProgramId flow = app.flow("WordCountFlow");
ProgramId service = app.service("WordFrequencyService");
StreamId stream = namespace.stream("text");
DatasetId datasetInstance = namespace.dataset("mydataset");
StreamViewId view = stream.view("view");
streamViewClient.createOrUpdate(view, new ViewSpecification(new FormatSpecification("csv", null, null)));
// Add metadata
addTags(app, tags);
addTags(flow, tags);
addTags(stream, tags);
addTags(datasetInstance, tags);
addTags(view, tags);
// Assert metadata
Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(stream), new MetadataSearchResultRecord(view)), searchMetadata(namespace, "text"));
Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(datasetInstance)), searchMetadata(namespace, "mydataset"));
Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(app), new MetadataSearchResultRecord(flow), new MetadataSearchResultRecord(artifact), new MetadataSearchResultRecord(service)), searchMetadata(namespace, "word*"));
Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(app), new MetadataSearchResultRecord(flow), new MetadataSearchResultRecord(stream), new MetadataSearchResultRecord(datasetInstance), new MetadataSearchResultRecord(view)), searchMetadata(namespace, "tag1"));
// Delete entities
appClient.delete(app);
streamViewClient.delete(view);
streamClient.delete(stream);
datasetClient.delete(datasetInstance);
artifactClient.delete(artifact);
// Assert no metadata
Assert.assertEquals(ImmutableSet.of(), searchMetadata(namespace, "text"));
Assert.assertEquals(ImmutableSet.of(), searchMetadata(namespace, "mydataset"));
Assert.assertEquals(ImmutableSet.of(), searchMetadata(namespace, "word*"));
Assert.assertEquals(ImmutableSet.of(), searchMetadata(namespace, "tag1"));
}
Aggregations