Search in sources :

Example 1 with AbstractApplication

use of co.cask.cdap.api.app.AbstractApplication in project cdap by caskdata.

the class ScheduleSpecificationCodecTest method testAppConfigurerRoute.

@Test
public void testAppConfigurerRoute() throws Exception {
    Application app = new AbstractApplication() {

        @Override
        public void configure() {
            // intentionally use the deprecated scheduleWorkflow method to for timeSchedule
            // to test TimeSchedule deserialization
            scheduleWorkflow(Schedules.builder("timeSchedule").createTimeSchedule("0 * * * *"), "workflow");
            scheduleWorkflow(Schedules.builder("streamSizeSchedule").createDataSchedule(Schedules.Source.STREAM, "stream", 1), "workflow");
        }
    };
    ApplicationSpecification specification = Specifications.from(app);
    ApplicationSpecificationAdapter gsonAdapater = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
    String jsonStr = gsonAdapater.toJson(specification);
    ApplicationSpecification deserializedSpec = gsonAdapater.fromJson(jsonStr);
    Assert.assertEquals(new TimeSchedule("timeSchedule", "", "0 * * * *"), deserializedSpec.getSchedules().get("timeSchedule").getSchedule());
    Assert.assertEquals(new StreamSizeSchedule("streamSizeSchedule", "", "stream", 1), deserializedSpec.getSchedules().get("streamSizeSchedule").getSchedule());
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) AbstractApplication(co.cask.cdap.api.app.AbstractApplication) TimeSchedule(co.cask.cdap.internal.schedule.TimeSchedule) ReflectionSchemaGenerator(co.cask.cdap.internal.io.ReflectionSchemaGenerator) StreamSizeSchedule(co.cask.cdap.internal.schedule.StreamSizeSchedule) Application(co.cask.cdap.api.app.Application) AbstractApplication(co.cask.cdap.api.app.AbstractApplication) Test(org.junit.Test)

Example 2 with AbstractApplication

use of co.cask.cdap.api.app.AbstractApplication in project cdap by caskdata.

the class DefaultStoreTest method testServiceDeletion.

@Test
public void testServiceDeletion() throws Exception {
    // Store the application specification
    AbstractApplication app = new AppWithServices();
    ApplicationSpecification appSpec = Specifications.from(app);
    ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName());
    store.addApplication(appId, appSpec);
    AbstractApplication newApp = new AppWithNoServices();
    // get the delete program specs after deploying AppWithNoServices
    List<ProgramSpecification> programSpecs = store.getDeletedProgramSpecifications(appId, Specifications.from(newApp));
    // verify the result.
    Assert.assertEquals(1, programSpecs.size());
    Assert.assertEquals("NoOpService", programSpecs.get(0).getName());
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) ProgramSpecification(co.cask.cdap.api.ProgramSpecification) AppWithServices(co.cask.cdap.AppWithServices) AbstractApplication(co.cask.cdap.api.app.AbstractApplication) AppWithNoServices(co.cask.cdap.AppWithNoServices) ApplicationId(co.cask.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 3 with AbstractApplication

use of co.cask.cdap.api.app.AbstractApplication in project cdap by caskdata.

the class SystemMetadataWriterStageTest method createAppWithWorkflow.

@SuppressWarnings("unchecked")
private ApplicationWithPrograms createAppWithWorkflow(ArtifactId artifactId, ApplicationId appId, String workflowName) throws IOException {
    LocationFactory locationFactory = new LocalLocationFactory(TEMP_FOLDER.newFolder());
    AbstractApplication app = new WorkflowAppWithFork();
    ApplicationSpecification appSpec = Specifications.from(app);
    Location workflowJar = AppJarHelper.createDeploymentJar(locationFactory, WorkflowAppWithFork.class);
    ApplicationDeployable appDeployable = new ApplicationDeployable(artifactId, workflowJar, appId, appSpec, null, ApplicationDeployScope.USER);
    return new ApplicationWithPrograms(appDeployable, ImmutableList.of(new ProgramDescriptor(appId.workflow(workflowName), appSpec)));
}
Also used : WorkflowAppWithFork(co.cask.cdap.WorkflowAppWithFork) ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) AbstractApplication(co.cask.cdap.api.app.AbstractApplication) ProgramDescriptor(co.cask.cdap.app.program.ProgramDescriptor) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) Location(org.apache.twill.filesystem.Location)

Aggregations

AbstractApplication (co.cask.cdap.api.app.AbstractApplication)3 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)3 Test (org.junit.Test)2 AppWithNoServices (co.cask.cdap.AppWithNoServices)1 AppWithServices (co.cask.cdap.AppWithServices)1 WorkflowAppWithFork (co.cask.cdap.WorkflowAppWithFork)1 ProgramSpecification (co.cask.cdap.api.ProgramSpecification)1 Application (co.cask.cdap.api.app.Application)1 ProgramDescriptor (co.cask.cdap.app.program.ProgramDescriptor)1 ReflectionSchemaGenerator (co.cask.cdap.internal.io.ReflectionSchemaGenerator)1 StreamSizeSchedule (co.cask.cdap.internal.schedule.StreamSizeSchedule)1 TimeSchedule (co.cask.cdap.internal.schedule.TimeSchedule)1 ApplicationId (co.cask.cdap.proto.id.ApplicationId)1 LocalLocationFactory (org.apache.twill.filesystem.LocalLocationFactory)1 Location (org.apache.twill.filesystem.Location)1 LocationFactory (org.apache.twill.filesystem.LocationFactory)1