### Question:
ProgramGenerationStage extends AbstractStage<ApplicationDeployable> { @Override public void process(final ApplicationDeployable input) throws Exception { List<ProgramDescriptor> programDescriptors = new ArrayList<>(); final ApplicationSpecification appSpec = input.getSpecification(); Iterable<ProgramSpecification> specifications = Iterables.concat( appSpec.getMapReduce().values(), appSpec.getWorkflows().values(), appSpec.getServices().values(), appSpec.getSpark().values(), appSpec.getWorkers().values() ); for (ProgramSpecification spec: specifications) { ProgramType type = ProgramTypes.fromSpecification(spec); ProgramId programId = input.getApplicationId().program(type, spec.getName()); programDescriptors.add(new ProgramDescriptor(programId, appSpec)); } emit(new ApplicationWithPrograms(input, programDescriptors)); } ProgramGenerationStage(); @Override void process(final ApplicationDeployable input);  }### Answer:
@Test public void testProgramGeneration() throws Exception { cConf.set(Constants.AppFabric.OUTPUT_DIR, "programs"); LocationFactory lf = new LocalLocationFactory(TEMP_FOLDER.newFolder()); Location namespaceLocation = lf.create(DefaultId.APPLICATION.getNamespace()); Locations.mkdirsIfNotExists(namespaceLocation); LocationFactory jarLf = new LocalLocationFactory(TEMP_FOLDER.newFolder()); Location appArchive = AppJarHelper.createDeploymentJar(jarLf, AllProgramsApp.class); ApplicationSpecification appSpec = Specifications.from(new AllProgramsApp()); ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(); ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec)); ProgramGenerationStage pgmStage = new ProgramGenerationStage(); pgmStage.process(new StageContext(Object.class)); pgmStage.process(new ApplicationDeployable(NamespaceId.DEFAULT.artifact("AllProgramApp", "1.0"), appArchive, DefaultId.APPLICATION, newSpec, null, ApplicationDeployScope.USER)); Assert.assertTrue(true); }