Search in sources :

Example 6 with WordCountApp

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));
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) WordCountApp(co.cask.cdap.WordCountApp) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ApplicationId(co.cask.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 7 with WordCountApp

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));
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) WordCountApp(co.cask.cdap.WordCountApp) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ApplicationId(co.cask.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 8 with WordCountApp

use of co.cask.cdap.WordCountApp in project cdap by caskdata.

the class PreferencesHttpHandlerTest method testApplication.

@Test
public void testApplication() throws Exception {
    addApplication(TEST_NAMESPACE1, new WordCountApp());
    Map<String, String> propMap = Maps.newHashMap();
    Assert.assertEquals(propMap, getProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), false, 200));
    Assert.assertEquals(propMap, getProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), true, 200));
    getProperty(getURI(TEST_NAMESPACE1, "InvalidAppName"), false, 404);
    setProperty(getURI(), ImmutableMap.of("k1", "instance"), 200);
    setProperty(getURI(TEST_NAMESPACE1), ImmutableMap.of("k1", "namespace"), 200);
    setProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), ImmutableMap.of("k1", "application"), 200);
    Assert.assertEquals("application", getProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), false, 200).get("k1"));
    Assert.assertEquals("application", getProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), true, 200).get("k1"));
    Assert.assertEquals("namespace", getProperty(getURI(TEST_NAMESPACE1), false, 200).get("k1"));
    Assert.assertEquals("namespace", getProperty(getURI(TEST_NAMESPACE1), true, 200).get("k1"));
    Assert.assertEquals("instance", getProperty(getURI(), true, 200).get("k1"));
    Assert.assertEquals("instance", getProperty(getURI(), false, 200).get("k1"));
    deleteProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), 200);
    Assert.assertEquals("namespace", getProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), true, 200).get("k1"));
    Assert.assertNull(getProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), false, 200).get("k1"));
    deleteProperty(getURI(TEST_NAMESPACE1), 200);
    Assert.assertEquals("instance", getProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), true, 200).get("k1"));
    Assert.assertEquals("instance", getProperty(getURI(TEST_NAMESPACE1), true, 200).get("k1"));
    Assert.assertNull(getProperty(getURI(TEST_NAMESPACE1), false, 200).get("k1"));
    deleteProperty(getURI(), 200);
    Assert.assertNull(getProperty(getURI(), true, 200).get("k1"));
    Assert.assertNull(getProperty(getURI(TEST_NAMESPACE1), true, 200).get("k1"));
    Assert.assertNull(getProperty(getURI(TEST_NAMESPACE1, "WordCountApp"), true, 200).get("k1"));
}
Also used : WordCountApp(co.cask.cdap.WordCountApp) Test(org.junit.Test)

Example 9 with WordCountApp

use of co.cask.cdap.WordCountApp in project cdap by caskdata.

the class PreferencesHttpHandlerTest method testProgram.

@Test
public void testProgram() throws Exception {
    addApplication(TEST_NAMESPACE2, new WordCountApp());
    Map<String, String> propMap = Maps.newHashMap();
    Assert.assertEquals(propMap, getProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "WordCountFlow"), false, 200));
    getProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "invalidType", "somename"), false, 400);
    getProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "somename"), false, 404);
    propMap.put("k1", "k349*&#$");
    setProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "WordCountFlow"), propMap, 200);
    Assert.assertEquals(propMap, getProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "WordCountFlow"), false, 200));
    propMap.put("k1", "instance");
    setProperty(getURI(), propMap, 200);
    Assert.assertEquals(propMap, getProperty(getURI(), true, 200));
    propMap.put("k1", "k349*&#$");
    Assert.assertEquals(propMap, getProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "WordCountFlow"), false, 200));
    deleteProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "WordCountFlow"), 200);
    propMap.put("k1", "instance");
    Assert.assertEquals(0, getProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "WordCountFlow"), false, 200).size());
    Assert.assertEquals(propMap, getProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "WordCountFlow"), true, 200));
    deleteProperty(getURI(), 200);
    propMap.clear();
    Assert.assertEquals(propMap, getProperty(getURI(TEST_NAMESPACE2, "WordCountApp", "flows", "WordCountFlow"), false, 200));
    Assert.assertEquals(propMap, getProperty(getURI(), false, 200));
}
Also used : WordCountApp(co.cask.cdap.WordCountApp) Test(org.junit.Test)

Example 10 with WordCountApp

use of co.cask.cdap.WordCountApp in project cdap by caskdata.

the class DefaultStoreTest method testAddApplication.

@Test
public void testAddApplication() throws Exception {
    ApplicationSpecification spec = Specifications.from(new WordCountApp());
    ApplicationId appId = new ApplicationId("account1", "application1");
    store.addApplication(appId, spec);
    ApplicationSpecification stored = store.getApplication(appId);
    assertWordCountAppSpecAndInMetadataStore(stored);
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) WordCountApp(co.cask.cdap.WordCountApp) ApplicationId(co.cask.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Aggregations

WordCountApp (co.cask.cdap.WordCountApp)15 Test (org.junit.Test)15 ApplicationId (co.cask.cdap.proto.id.ApplicationId)9 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)8 NamespaceId (co.cask.cdap.proto.id.NamespaceId)6 ProgramId (co.cask.cdap.proto.id.ProgramId)6 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)3 FormatSpecification (co.cask.cdap.api.data.format.FormatSpecification)2 ApplicationSpecificationAdapter (co.cask.cdap.internal.app.ApplicationSpecificationAdapter)2 ReflectionSchemaGenerator (co.cask.cdap.internal.io.ReflectionSchemaGenerator)2 ViewSpecification (co.cask.cdap.proto.ViewSpecification)2 ArtifactId (co.cask.cdap.proto.id.ArtifactId)2 DatasetId (co.cask.cdap.proto.id.DatasetId)2 StreamId (co.cask.cdap.proto.id.StreamId)2 StreamViewId (co.cask.cdap.proto.id.StreamViewId)2 MetadataSearchResultRecord (co.cask.cdap.proto.metadata.MetadataSearchResultRecord)2 AllProgramsApp (co.cask.cdap.AllProgramsApp)1 WordCountMinusFlowApp (co.cask.cdap.WordCountMinusFlowApp)1 CloseableClassLoader (co.cask.cdap.api.artifact.CloseableClassLoader)1 ConfigResponse (co.cask.cdap.app.deploy.ConfigResponse)1