use of org.talend.daikon.definition.Definition in project components by Talend.
the class ServiceSpiFactoryTest method testGetComponentService.
@Test
public void testGetComponentService() throws Exception {
ComponentService cs = ServiceSpiFactory.getComponentService();
assertThat(cs, not(nullValue()));
DefinitionRegistry defReg = ServiceSpiFactory.getDefinitionRegistry();
assertThat(cs, not(nullValue()));
Map<String, ComponentFamilyDefinition> families = defReg.getComponentFamilies();
assertThat(families, hasEntry(is("LocalIO"), isA((Class) LocalIOComponentFamilyDefinition.class)));
assertThat(families, hasEntry(is("SimpleFileIo"), isA((Class) SimpleFileIOComponentFamilyDefinition.class)));
Map<String, Definition> definitions = defReg.getDefinitions();
assertThat(definitions, hasEntry(is("FixedFlowInput"), isA((Class) FixedFlowInputDefinition.class)));
assertThat(definitions, hasEntry(is("SimpleFileIoDatastore"), isA((Class) SimpleFileIODatastoreDefinition.class)));
assertThat(definitions, hasEntry(is("SimpleFileIoDataset"), isA((Class) SimpleFileIODatasetDefinition.class)));
assertThat(definitions, hasEntry(is("SimpleFileIoInput"), isA((Class) SimpleFileIOInputDefinition.class)));
assertThat(definitions, hasEntry(is("SimpleFileIoOutput"), isA((Class) SimpleFileIOOutputDefinition.class)));
}
use of org.talend.daikon.definition.Definition in project components by Talend.
the class DefinitionsControllerImpl method listDefinitions.
/**
* Return all known definitions that match the given type.
*
* @param type the wanted definition type.
* @return all known definitions that match the given type.
* @returnWrapped java.lang.Iterable<org.talend.components.service.rest.dto.DefinitionDTO>
*/
@Override
public List<DefinitionDTO> listDefinitions(DefinitionType type, String tag) {
logger.debug("listing definitions for {} ", type);
//
Iterable<? extends Definition> definitionsByType = definitionServiceDelegate.getDefinitionsMapByType(type.getTargetClass()).values();
Stream<? extends Definition> stream = stream(definitionsByType.spliterator(), false);
if (tag != null) {
stream = //
stream.filter(c -> HasTags.class.isAssignableFrom(c.getClass())).filter(c -> {
for (Tag defTag : ((HasTags) c).getTags()) {
if (TagUtils.hasTag(defTag, tag)) {
return true;
}
}
return false;
});
}
return stream.map(c -> {
if (type == DefinitionType.COMPONENT) {
return new DefinitionDTO((ComponentDefinition) c);
} else {
return new DefinitionDTO((DatastoreDefinition) c);
}
}).collect(Collectors.toList());
}
use of org.talend.daikon.definition.Definition in project components by Talend.
the class MarkLogicFamilyDefinitionTest method testAllComponentsDefinitionsCreated.
@Test
public void testAllComponentsDefinitionsCreated() {
List<Class> expectedDefinitions = new ArrayList<>();
expectedDefinitions.add(MarkLogicInputDefinition.class);
expectedDefinitions.add(MarkLogicOutputDefinition.class);
expectedDefinitions.add(MarkLogicConnectionDefinition.class);
expectedDefinitions.add(MarkLogicCloseDefinition.class);
expectedDefinitions.add(MarkLogicBulkLoadDefinition.class);
expectedDefinitions.add(MarkLogicWizardDefinition.class);
expectedDefinitions.add(MarkLogicEditWizardDefinition.class);
expectedDefinitions.add(MarkLogicDatasetDefinition.class);
expectedDefinitions.add(MarkLogicDatastoreDefinition.class);
List<Class> actualDefinitionsNames = new ArrayList<>();
for (Definition d : familyDefinition.getDefinitions()) {
actualDefinitionsNames.add(d.getClass());
}
assertEquals(expectedDefinitions, actualDefinitionsNames);
}
use of org.talend.daikon.definition.Definition in project components by Talend.
the class DefinitionRegistry method registerDefinition.
@Override
public void registerDefinition(Iterable<? extends Definition> defs) {
for (Definition def : defs) {
String name = def.getName();
if (name == null) {
throw TalendRuntimeException.createUnexpectedException("The definition [" + def.getClass().getName() + "] name cannot be null.");
}
// else we are fine keep going
Definition previousValue = definitions.put(name, def);
if (previousValue != null) {
// we cannot have 2 definiions with the same name
throw TalendRuntimeException.createUnexpectedException("2 definitions have the same name [" + previousValue.getName() + "] but their name must be unique.");
}
LOGGER.info("Talend Definition registered :" + name);
}
}
use of org.talend.daikon.definition.Definition in project components by Talend.
the class DefintitionRegistryTest method testAddComponentFamilyDefinition.
@SuppressWarnings("rawtypes")
@Test
public void testAddComponentFamilyDefinition() {
DefinitionRegistry registry = new DefinitionRegistry();
ComponentFamilyDefinition def = new TestComponentFamilyDefinition();
registry.registerComponentFamilyDefinition(def);
assertThat(registry.getComponentFamilies().keySet(), hasSize(1));
assertThat(registry.getComponentFamilies(), hasEntry(def.getName(), def));
// All of the nested definitions were added.
Iterator<? extends Definition> iterator = def.getDefinitions().iterator();
assertThat(registry.getDefinitionsMapByType(ComponentDefinition.class).values(), contains((Definition) iterator.next()));
assertThat(registry.getDefinitionsMapByType(ComponentWizardDefinition.class).values(), contains((ComponentWizardDefinition) iterator.next()));
}
Aggregations