Search in sources :

Example 1 with ApplicationSpecificationAdapter

use of io.cdap.cdap.internal.app.ApplicationSpecificationAdapter in project cdap by caskdata.

the class ApplicationVerificationTest method testGoodApplication.

/**
 * Good test
 */
@Test
public void testGoodApplication() {
    ApplicationSpecification appSpec = Specifications.from(new AllProgramsApp());
    ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create();
    ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
    ApplicationVerification app = new ApplicationVerification();
    VerifyResult result = app.verify(new ApplicationId("test", newSpec.getName()), newSpec);
    Assert.assertSame(result.getMessage(), result.getStatus(), VerifyResult.Status.SUCCESS);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationSpecificationAdapter(io.cdap.cdap.internal.app.ApplicationSpecificationAdapter) AllProgramsApp(io.cdap.cdap.AllProgramsApp) VerifyResult(io.cdap.cdap.app.verification.VerifyResult) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 2 with ApplicationSpecificationAdapter

use of io.cdap.cdap.internal.app.ApplicationSpecificationAdapter in project cdap by caskdata.

the class WorkflowVerificationTest method testGoodWorkflow.

@Test
public void testGoodWorkflow() throws Exception {
    ApplicationSpecification appSpec = Specifications.from(new GoodWorkflowApp());
    verifyGoodWorkflowSpecifications(appSpec);
    verifyAnotherGoodWorkflowSpecification(appSpec);
    verifyWorkflowWithLocalDatasetSpecification(appSpec);
    ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create();
    ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
    verifyGoodWorkflowSpecifications(newSpec);
    verifyAnotherGoodWorkflowSpecification(newSpec);
    verifyWorkflowWithLocalDatasetSpecification(newSpec);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationSpecificationAdapter(io.cdap.cdap.internal.app.ApplicationSpecificationAdapter) GoodWorkflowApp(io.cdap.cdap.GoodWorkflowApp) Test(org.junit.Test)

Example 3 with ApplicationSpecificationAdapter

use of io.cdap.cdap.internal.app.ApplicationSpecificationAdapter in project cdap by caskdata.

the class ProgramGenerationStageTest method testProgramGeneration.

@Test
public void testProgramGeneration() throws Exception {
    cConf.set(Constants.AppFabric.OUTPUT_DIR, "programs");
    LocationFactory lf = new LocalLocationFactory(TEMP_FOLDER.newFolder());
    // have to do this since we are not going through the route of create namespace -> deploy application
    // in real scenarios, the namespace directory would already be created
    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));
    ApplicationClass applicationClass = new ApplicationClass(AllProgramsApp.class.getName(), "", null);
    ProgramGenerationStage pgmStage = new ProgramGenerationStage();
    // Can do better here - fixed right now to run the test.
    pgmStage.process(new StageContext(Object.class));
    pgmStage.process(new ApplicationDeployable(NamespaceId.DEFAULT.artifact("AllProgramApp", "1.0"), appArchive, DefaultId.APPLICATION, newSpec, null, ApplicationDeployScope.USER, applicationClass));
    Assert.assertTrue(true);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationSpecificationAdapter(io.cdap.cdap.internal.app.ApplicationSpecificationAdapter) ApplicationClass(io.cdap.cdap.api.artifact.ApplicationClass) AllProgramsApp(io.cdap.cdap.AllProgramsApp) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) StageContext(io.cdap.cdap.internal.pipeline.StageContext) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) Location(org.apache.twill.filesystem.Location) Test(org.junit.Test)

Aggregations

ApplicationSpecification (io.cdap.cdap.api.app.ApplicationSpecification)3 ApplicationSpecificationAdapter (io.cdap.cdap.internal.app.ApplicationSpecificationAdapter)3 Test (org.junit.Test)3 AllProgramsApp (io.cdap.cdap.AllProgramsApp)2 GoodWorkflowApp (io.cdap.cdap.GoodWorkflowApp)1 ApplicationClass (io.cdap.cdap.api.artifact.ApplicationClass)1 VerifyResult (io.cdap.cdap.app.verification.VerifyResult)1 StageContext (io.cdap.cdap.internal.pipeline.StageContext)1 ApplicationId (io.cdap.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