Search in sources :

Example 1 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField 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)

Example 2 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.

the class FilterErrorTransform method getPluginClass.

private static PluginClass getPluginClass() {
    Map<String, PluginPropertyField> properties = new HashMap<>();
    properties.put("code", new PluginPropertyField("code", "", "int", true, false));
    return PluginClass.builder().setName("Filter").setType(ErrorTransform.PLUGIN_TYPE).setDescription("").setClassName(FilterErrorTransform.class.getName()).setProperties(properties).setConfigFieldName("config").build();
}
Also used : HashMap(java.util.HashMap) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField)

Example 3 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.

the class NullFieldSplitterTransform method getPluginClass.

private static PluginClass getPluginClass() {
    Map<String, PluginPropertyField> properties = new HashMap<>();
    properties.put("field", new PluginPropertyField("field", "", "string", true, true));
    return PluginClass.builder().setName("NullFieldSplitter").setType(SplitterTransform.PLUGIN_TYPE).setDescription("").setClassName(NullFieldSplitterTransform.class.getName()).setProperties(properties).setConfigFieldName("config").build();
}
Also used : HashMap(java.util.HashMap) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField)

Example 4 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.

the class SleepTransform method getPluginClass.

private static PluginClass getPluginClass() {
    Map<String, PluginPropertyField> properties = new HashMap<>();
    properties.put("millis", new PluginPropertyField("millis", "", "long", false, false));
    return PluginClass.builder().setName("Sleep").setType(Transform.PLUGIN_TYPE).setDescription("").setClassName(SleepTransform.class.getName()).setProperties(properties).setConfigFieldName("config").build();
}
Also used : HashMap(java.util.HashMap) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField)

Example 5 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.

the class MockSource method getPluginClass.

private static PluginClass getPluginClass() {
    Map<String, PluginPropertyField> properties = new HashMap<>();
    properties.put("schema", new PluginPropertyField("schema", "", "string", true, false));
    properties.put("records", new PluginPropertyField("records", "", "string", true, false));
    properties.put("intervalMillis", new PluginPropertyField("intervalMillis", "", "long", false, false));
    properties.put("referenceName", new PluginPropertyField("referenceName", "", "string", false, false));
    return PluginClass.builder().setName("Mock").setType(StreamingSource.PLUGIN_TYPE).setDescription("").setClassName(MockSource.class.getName()).setProperties(properties).setConfigFieldName("conf").build();
}
Also used : HashMap(java.util.HashMap) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField)

Aggregations

PluginPropertyField (io.cdap.cdap.api.plugin.PluginPropertyField)54 HashMap (java.util.HashMap)43 PluginClass (io.cdap.cdap.api.plugin.PluginClass)11 Test (org.junit.Test)8 ArtifactRange (io.cdap.cdap.api.artifact.ArtifactRange)6 ArtifactVersion (io.cdap.cdap.api.artifact.ArtifactVersion)6 Id (io.cdap.cdap.common.id.Id)6 File (java.io.File)5 ArtifactClasses (io.cdap.cdap.api.artifact.ArtifactClasses)4 ArtifactId (io.cdap.cdap.proto.id.ArtifactId)4 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)4 Location (org.apache.twill.filesystem.Location)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 ApplicationClass (io.cdap.cdap.api.artifact.ApplicationClass)3 ArtifactId (io.cdap.cdap.api.artifact.ArtifactId)3 Requirements (io.cdap.cdap.api.plugin.Requirements)3 ArtifactNotFoundException (io.cdap.cdap.common.ArtifactNotFoundException)3 ReflectionSchemaGenerator (io.cdap.cdap.internal.io.ReflectionSchemaGenerator)3 ArrayList (java.util.ArrayList)3