use of org.talend.components.api.component.ComponentDefinition in project components by Talend.
the class DefinitionsControllerTest method shouldFilterComponentsByTypology.
public void shouldFilterComponentsByTypology(ConnectorTypology wantedTypology, int expectedResults) throws IOException {
// given
Map<String, ComponentDefinition> definitions = getComponentsDefinitions();
//
BDDMockito.given(delegate.getDefinitionsMapByType(ComponentDefinition.class)).willReturn(definitions);
// when
final Response response = when().get(getVersionPrefix() + "/definitions/components?typology=" + wantedTypology.name()).andReturn();
// then
assertEquals(OK.value(), response.getStatusCode());
List<DefinitionDTO> actual = objectMapper.readValue(response.asInputStream(), new TypeReference<List<DefinitionDTO>>() {
});
assertEquals(expectedResults, actual.size());
assertEquals(expectedResults, // it's
actual.stream().filter(dto -> dto.getTypologies().contains(wantedTypology.name())).count());
}
use of org.talend.components.api.component.ComponentDefinition in project components by Talend.
the class DefinitionsControllerTest method getComponentsDefinitions.
private Map<String, ComponentDefinition> getComponentsDefinitions() {
Map<String, ComponentDefinition> definitions = new HashMap<>();
definitions.put("source_1", new MockComponentDefinition("source_1", "icon_key_source_1", INCOMING));
definitions.put("source_2", new MockComponentDefinition("source_2", INCOMING));
definitions.put("source_3", new MockComponentDefinition("source_2", ExecutionEngine.BEAM, INCOMING));
definitions.put("sink_1", new MockComponentDefinition("sink_1", "icon_key_sink_1", OUTGOING));
definitions.put("sink_2", new MockComponentDefinition("sink_2", ExecutionEngine.DI_SPARK_BATCH, OUTGOING));
definitions.put("sink_3", new MockComponentDefinition("sink_3", ExecutionEngine.DI_SPARK_BATCH, OUTGOING));
definitions.put("transformer_1", new MockComponentDefinition("transformer_1", "icon_key_transformer_1", ExecutionEngine.DI_SPARK_STREAMING, INCOMING_AND_OUTGOING));
definitions.put("transformer_2", new MockComponentDefinition("transformer_2", ExecutionEngine.DI_SPARK_STREAMING, INCOMING_AND_OUTGOING));
definitions.put("transformer_3", new MockComponentDefinition("transformer_3", ExecutionEngine.DI_SPARK_STREAMING, INCOMING_AND_OUTGOING));
definitions.put("config_1", new MockComponentDefinition("config_1", "icon_key_config_1", NONE));
definitions.put("config_2", new MockComponentDefinition("config_2", NONE));
definitions.put("config_3", new MockComponentDefinition("config_3", NONE));
definitions.put("s&s_1", new MockComponentDefinition("ss_1", "icon_key_ss_1", INCOMING, OUTGOING));
definitions.put("s&s_2", new MockComponentDefinition("ss_2", INCOMING, OUTGOING));
return definitions;
}
use of org.talend.components.api.component.ComponentDefinition in project components by Talend.
the class ComponentTestUtils method testAllImages.
/**
* check that all Components and Wizards have theirs images properly set.
*
* @param componentService service to get the components to be checked.
*
* @deprecated, use {@link #assertAllComponentImagesAreSet(DefinitionRegistryService)}
*/
@Deprecated
public static void testAllImages(ComponentService componentService) {
// check components
Set<ComponentDefinition> allComponents = componentService.getAllComponents();
for (ComponentDefinition compDef : allComponents) {
assertComponentImagesAreSet(compDef);
}
// check wizards
Set<ComponentWizardDefinition> allWizards = componentService.getTopLevelComponentWizards();
for (ComponentWizardDefinition wizDef : allWizards) {
assertWizardImagesAreSet(wizDef);
}
}
use of org.talend.components.api.component.ComponentDefinition in project components by Talend.
the class DefintitionRegistryTest method testAddComponentDefinition.
@Test
public void testAddComponentDefinition() {
DefinitionRegistry registry = new DefinitionRegistry();
ComponentDefinition def = new TestComponentDefinition();
registry.registerDefinition(Arrays.asList(def));
assertThat(registry.getIterableDefinitions(), contains((Definition) def));
assertThat(registry.getDefinitionsByType(ComponentDefinition.class), contains(def));
}
use of org.talend.components.api.component.ComponentDefinition in project components by Talend.
the class ComponentServiceImpl method getComponentDefinition.
@Override
public ComponentDefinition getComponentDefinition(String name) {
Map<String, ComponentDefinition> compDefMap = definitionRegistry.getDefinitionsMapByType(ComponentDefinition.class);
if (compDefMap.isEmpty()) {
throw TalendRuntimeException.createUnexpectedException("fails to retrieve any Component definitions.");
}
ComponentDefinition componentDefinition = definitionRegistry.getDefinitionsMapByType(ComponentDefinition.class).get(name);
if (componentDefinition == null) {
// The component was not found.
throw ComponentException.build(ComponentsApiErrorCode.WRONG_COMPONENT_NAME).set(name);
}
return componentDefinition;
}
Aggregations