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