Search in sources :

Example 1 with InspectionApp

use of io.cdap.cdap.internal.app.runtime.artifact.app.inspection.InspectionApp in project cdap by caskdata.

the class DefaultArtifactInspectorTest method inspectAppsAndPlugins.

@Test
public void inspectAppsAndPlugins() throws Exception {
    File appFile = getAppFile();
    Id.Artifact artifactId = Id.Artifact.from(Id.Namespace.DEFAULT, "InspectionApp", "1.0.0");
    Location artifactLocation = Locations.toLocation(appFile);
    List<ArtifactDescriptor> parentDescriptor = new ArrayList<>();
    parentDescriptor.add(new ArtifactDescriptor(artifactId.getNamespace().getId(), artifactId.toArtifactId(), artifactLocation));
    ArtifactClasses classes = artifactInspector.inspectArtifact(artifactId, appFile, parentDescriptor, Collections.emptySet()).getArtifactClasses();
    // check app classes
    Set<ApplicationClass> expectedApps = ImmutableSet.of(new ApplicationClass(InspectionApp.class.getName(), "", new ReflectionSchemaGenerator(false).generate(InspectionApp.AConfig.class), new Requirements(Collections.emptySet(), Collections.singleton("cdc"))));
    Assert.assertEquals(expectedApps, classes.getApps());
    // check plugin classes
    PluginClass expectedPlugin = PluginClass.builder().setName(InspectionApp.PLUGIN_NAME).setType(InspectionApp.PLUGIN_TYPE).setDescription(InspectionApp.PLUGIN_DESCRIPTION).setClassName(InspectionApp.AppPlugin.class.getName()).setConfigFieldName("pluginConf").setProperties(ImmutableMap.of("y", new PluginPropertyField("y", "", "double", true, true), "isSomething", new PluginPropertyField("isSomething", "", "boolean", true, false))).build();
    PluginClass multipleRequirementPlugin = PluginClass.builder().setName(InspectionApp.MULTIPLE_REQUIREMENTS_PLUGIN).setType(InspectionApp.PLUGIN_TYPE).setCategory(InspectionApp.PLUGIN_CATEGORY).setClassName(InspectionApp.MultipleRequirementsPlugin.class.getName()).setConfigFieldName("pluginConf").setProperties(ImmutableMap.of("y", new PluginPropertyField("y", "", "double", true, true), "isSomething", new PluginPropertyField("isSomething", "", "boolean", true, false))).setRequirements(new Requirements(ImmutableSet.of(Table.TYPE, KeyValueTable.TYPE))).setDescription(InspectionApp.PLUGIN_DESCRIPTION).build();
    Assert.assertTrue(classes.getPlugins().containsAll(ImmutableSet.of(expectedPlugin, multipleRequirementPlugin)));
}
Also used : ArrayList(java.util.ArrayList) ApplicationClass(io.cdap.cdap.api.artifact.ApplicationClass) ReflectionSchemaGenerator(io.cdap.cdap.internal.io.ReflectionSchemaGenerator) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField) Requirements(io.cdap.cdap.api.plugin.Requirements) ArtifactClasses(io.cdap.cdap.api.artifact.ArtifactClasses) Id(io.cdap.cdap.common.id.Id) PluginClass(io.cdap.cdap.api.plugin.PluginClass) File(java.io.File) Location(org.apache.twill.filesystem.Location) InspectionApp(io.cdap.cdap.internal.app.runtime.artifact.app.inspection.InspectionApp) Test(org.junit.Test)

Aggregations

ApplicationClass (io.cdap.cdap.api.artifact.ApplicationClass)1 ArtifactClasses (io.cdap.cdap.api.artifact.ArtifactClasses)1 PluginClass (io.cdap.cdap.api.plugin.PluginClass)1 PluginPropertyField (io.cdap.cdap.api.plugin.PluginPropertyField)1 Requirements (io.cdap.cdap.api.plugin.Requirements)1 Id (io.cdap.cdap.common.id.Id)1 InspectionApp (io.cdap.cdap.internal.app.runtime.artifact.app.inspection.InspectionApp)1 ReflectionSchemaGenerator (io.cdap.cdap.internal.io.ReflectionSchemaGenerator)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Location (org.apache.twill.filesystem.Location)1 Test (org.junit.Test)1