Search in sources :

Example 31 with ComponentDefinition

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());
}
Also used : Response(com.jayway.restassured.response.Response) DefinitionDTO(org.talend.components.service.rest.dto.DefinitionDTO) Arrays.asList(java.util.Arrays.asList) List(java.util.List) MockComponentDefinition(org.talend.components.service.rest.mock.MockComponentDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 32 with ComponentDefinition

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;
}
Also used : MockComponentDefinition(org.talend.components.service.rest.mock.MockComponentDefinition) HashMap(java.util.HashMap) MockComponentDefinition(org.talend.components.service.rest.mock.MockComponentDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 33 with ComponentDefinition

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);
    }
}
Also used : ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 34 with ComponentDefinition

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));
}
Also used : ComponentFamilyDefinition(org.talend.components.api.ComponentFamilyDefinition) TestComponentDefinition(org.talend.components.api.service.common.testcomponent.TestComponentDefinition) TestComponentFamilyDefinition(org.talend.components.api.service.common.testcomponent.TestComponentFamilyDefinition) Definition(org.talend.daikon.definition.Definition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) TestInjectComponentDefinition(org.talend.components.api.service.common.testcomponent.inject.TestInjectComponentDefinition) SimpleComponentDefinition(org.talend.components.api.test.SimpleComponentDefinition) TestComponentWizardDefinition(org.talend.components.api.service.common.testcomponent.TestComponentWizardDefinition) TestNestedInjectComponentDefinition(org.talend.components.api.service.common.testcomponent.inject.TestNestedInjectComponentDefinition) ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition) TestComponentDefinition(org.talend.components.api.service.common.testcomponent.TestComponentDefinition) TestComponentDefinition(org.talend.components.api.service.common.testcomponent.TestComponentDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) TestInjectComponentDefinition(org.talend.components.api.service.common.testcomponent.inject.TestInjectComponentDefinition) SimpleComponentDefinition(org.talend.components.api.test.SimpleComponentDefinition) TestNestedInjectComponentDefinition(org.talend.components.api.service.common.testcomponent.inject.TestNestedInjectComponentDefinition) Test(org.junit.Test)

Example 35 with ComponentDefinition

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;
}
Also used : ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Aggregations

ComponentDefinition (org.talend.components.api.component.ComponentDefinition)47 Test (org.junit.Test)28 IndexedRecord (org.apache.avro.generic.IndexedRecord)16 TSalesforceOutputProperties (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)14 TSalesforceOutputDefinition (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition)12 ArrayList (java.util.ArrayList)11 Result (org.talend.components.api.component.runtime.Result)11 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)10 List (java.util.List)9 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)8 ComponentProperties (org.talend.components.api.properties.ComponentProperties)7 Schema (org.apache.avro.Schema)6 DefinitionDTO (org.talend.components.service.rest.dto.DefinitionDTO)6 MockComponentDefinition (org.talend.components.service.rest.mock.MockComponentDefinition)6 Response (com.jayway.restassured.response.Response)5 Arrays.asList (java.util.Arrays.asList)5 GenericData (org.apache.avro.generic.GenericData)3 ExecutionEngine (org.talend.components.api.component.runtime.ExecutionEngine)3 IComponent (org.talend.core.model.components.IComponent)3 File (java.io.File)2