Search in sources :

Example 6 with Definition

use of org.talend.daikon.definition.Definition in project components by Talend.

the class AbstractSpringIntegrationTests method setUp.

@Before
public void setUp() {
    // ensure any call from restassured goes to our server isntance
    RestAssured.port = localServerPort;
    // Init the mock delegate to return our data store mock on demand
    MockDatastoreDefinition datastoreDefinition = new MockDatastoreDefinition(DATA_STORE_DEFINITION_NAME);
    MockDatasetDefinition datasetDefinition = new MockDatasetDefinition(DATA_SET_DEFINITION_NAME);
    Map<String, DatastoreDefinition> datastoresMap = singletonMap(DATA_STORE_DEFINITION_NAME, datastoreDefinition);
    // 
    when(delegate.getDefinitionsMapByType(DatastoreDefinition.class)).thenReturn(datastoresMap);
    Map<String, DatasetDefinition> datasetMap = singletonMap(DATA_SET_DEFINITION_NAME, datasetDefinition);
    // 
    when(delegate.getDefinitionsMapByType(DatasetDefinition.class)).thenReturn(datasetMap);
    Map<String, Definition> runtimablesMap = new HashMap<>();
    runtimablesMap.putAll(datastoresMap);
    runtimablesMap.putAll(datasetMap);
    // 
    when(delegate.getDefinitionsMapByType(Definition.class)).thenReturn(runtimablesMap);
    // 
    when(delegate.getDefinitionsMapByType(Definition.class)).thenReturn(runtimablesMap);
    // TODO: map the dataset definition on the correct name
    when(delegate.getDefinitionForPropertiesType(MockDatasetProperties.class)).thenReturn(singletonList(datasetDefinition));
    when(delegate.getDefinitionForPropertiesType(MockDatastoreProperties.class)).thenReturn(singletonList(datastoreDefinition));
    when(delegate.createProperties(any(Definition.class), anyString())).thenAnswer(i -> {
        Properties properties = PropertiesImpl.createNewInstance(((Definition<Properties>) i.getArguments()[0]).getPropertiesClass(), (String) i.getArguments()[1]);
        properties.init();
        return properties;
    });
}
Also used : MockDatasetDefinition(org.talend.components.service.rest.mock.MockDatasetDefinition) HashMap(java.util.HashMap) Definition(org.talend.daikon.definition.Definition) MockDatasetDefinition(org.talend.components.service.rest.mock.MockDatasetDefinition) DatasetDefinition(org.talend.components.common.dataset.DatasetDefinition) DatastoreDefinition(org.talend.components.common.datastore.DatastoreDefinition) MockDatastoreDefinition(org.talend.components.service.rest.mock.MockDatastoreDefinition) MockDatastoreDefinition(org.talend.components.service.rest.mock.MockDatastoreDefinition) Matchers.anyString(org.mockito.Matchers.anyString) MockDatasetDefinition(org.talend.components.service.rest.mock.MockDatasetDefinition) DatasetDefinition(org.talend.components.common.dataset.DatasetDefinition) MockDatastoreProperties(org.talend.components.service.rest.mock.MockDatastoreProperties) Properties(org.talend.daikon.properties.Properties) MockDatasetProperties(org.talend.components.service.rest.mock.MockDatasetProperties) DatastoreDefinition(org.talend.components.common.datastore.DatastoreDefinition) MockDatastoreDefinition(org.talend.components.service.rest.mock.MockDatastoreDefinition) Before(org.junit.Before)

Example 7 with Definition

use of org.talend.daikon.definition.Definition in project components by Talend.

the class DefintitionRegistryTest method testGetDefinitionForPropertiesType.

@Test
public void testGetDefinitionForPropertiesType() {
    // we'll check that 2 derived Properties have thier definition returned.
    SimpleComponentDefinition compDef = new SimpleComponentDefinition("def", ExecutionEngine.DI);
    compDef.setPropertyClass(NestedComponentProperties.class);
    SimpleComponentDefinition inheritedDef = new SimpleComponentDefinition("DefOfinherited", ExecutionEngine.DI);
    inheritedDef.setPropertyClass(InheritedComponentProperties.class);
    DefinitionRegistry definitionRegistry = new DefinitionRegistry();
    definitionRegistry.registerDefinition(Arrays.asList(compDef, inheritedDef, new TestComponentDefinition()));
    Iterable<Definition> definitionForPropertiesType = definitionRegistry.getDefinitionForPropertiesType(NestedComponentProperties.class);
    assertThat(definitionForPropertiesType, contains((Definition) compDef, inheritedDef));
}
Also used : SimpleComponentDefinition(org.talend.components.api.test.SimpleComponentDefinition) 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) Test(org.junit.Test)

Example 8 with Definition

use of org.talend.daikon.definition.Definition 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 9 with Definition

use of org.talend.daikon.definition.Definition in project components by Talend.

the class SalesforceFamilyDefinitionTest method testTags.

@Test
public void testTags() {
    List<? extends Definition> definitions = Lists.newArrayList(familyDefinition.getDefinitions());
    for (Definition definition : definitions) {
        if (definition instanceof SalesforceDefinition) {
            SalesforceDefinition d = (SalesforceDefinition) definition;
            assertThat(d.doGetTags(), containsInAnyOrder(new TagImpl("salesforce", CommonTags.CLOUD_TAG), new TagImpl("salesforce", CommonTags.BUSINESS_TAG)));
        }
    }
}
Also used : TagImpl(org.talend.daikon.i18n.tag.TagImpl) SalesforceDatasetDefinition(org.talend.components.salesforce.dataset.SalesforceDatasetDefinition) TSalesforceGetDeletedDefinition(org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedDefinition) TSalesforceOutputDefinition(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition) Definition(org.talend.daikon.definition.Definition) TSalesforceOutputBulkDefinition(org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkDefinition) TSalesforceInputDefinition(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputDefinition) SalesforceInputDefinition(org.talend.components.salesforce.dataprep.SalesforceInputDefinition) TSalesforceGetServerTimestampDefinition(org.talend.components.salesforce.tsalesforcegetservertimestamp.TSalesforceGetServerTimestampDefinition) TSalesforceOutputBulkExecDefinition(org.talend.components.salesforce.tsalesforceoutputbulkexec.TSalesforceOutputBulkExecDefinition) TSalesforceBulkExecDefinition(org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecDefinition) SalesforceDatastoreDefinition(org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition) TSalesforceGetUpdatedDefinition(org.talend.components.salesforce.tsalesforcegetupdated.TSalesforceGetUpdatedDefinition) TSalesforceConnectionDefinition(org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition) Test(org.junit.Test)

Example 10 with Definition

use of org.talend.daikon.definition.Definition in project components by Talend.

the class SalesforceFamilyDefinitionTest method testFamilies.

@Test
public void testFamilies() {
    List<? extends Definition> definitions = Lists.newArrayList(familyDefinition.getDefinitions());
    for (Definition definition : definitions) {
        if (definition instanceof SalesforceDefinition) {
            SalesforceDefinition d = (SalesforceDefinition) definition;
            assertThat(d.getFamilies(), arrayContainingInAnyOrder("Business/Salesforce", "Cloud/Salesforce"));
        }
    }
}
Also used : SalesforceDatasetDefinition(org.talend.components.salesforce.dataset.SalesforceDatasetDefinition) TSalesforceGetDeletedDefinition(org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedDefinition) TSalesforceOutputDefinition(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition) Definition(org.talend.daikon.definition.Definition) TSalesforceOutputBulkDefinition(org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkDefinition) TSalesforceInputDefinition(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputDefinition) SalesforceInputDefinition(org.talend.components.salesforce.dataprep.SalesforceInputDefinition) TSalesforceGetServerTimestampDefinition(org.talend.components.salesforce.tsalesforcegetservertimestamp.TSalesforceGetServerTimestampDefinition) TSalesforceOutputBulkExecDefinition(org.talend.components.salesforce.tsalesforceoutputbulkexec.TSalesforceOutputBulkExecDefinition) TSalesforceBulkExecDefinition(org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecDefinition) SalesforceDatastoreDefinition(org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition) TSalesforceGetUpdatedDefinition(org.talend.components.salesforce.tsalesforcegetupdated.TSalesforceGetUpdatedDefinition) TSalesforceConnectionDefinition(org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition) Test(org.junit.Test)

Aggregations

Definition (org.talend.daikon.definition.Definition)10 Test (org.junit.Test)7 ComponentFamilyDefinition (org.talend.components.api.ComponentFamilyDefinition)5 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)5 ComponentWizardDefinition (org.talend.components.api.wizard.ComponentWizardDefinition)4 TestComponentDefinition (org.talend.components.api.service.common.testcomponent.TestComponentDefinition)3 TestComponentFamilyDefinition (org.talend.components.api.service.common.testcomponent.TestComponentFamilyDefinition)3 TestComponentWizardDefinition (org.talend.components.api.service.common.testcomponent.TestComponentWizardDefinition)3 TestInjectComponentDefinition (org.talend.components.api.service.common.testcomponent.inject.TestInjectComponentDefinition)3 TestNestedInjectComponentDefinition (org.talend.components.api.service.common.testcomponent.inject.TestNestedInjectComponentDefinition)3 SimpleComponentDefinition (org.talend.components.api.test.SimpleComponentDefinition)3 DatastoreDefinition (org.talend.components.common.datastore.DatastoreDefinition)2 SalesforceInputDefinition (org.talend.components.salesforce.dataprep.SalesforceInputDefinition)2 SalesforceDatasetDefinition (org.talend.components.salesforce.dataset.SalesforceDatasetDefinition)2 SalesforceDatastoreDefinition (org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition)2 TSalesforceBulkExecDefinition (org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecDefinition)2 TSalesforceConnectionDefinition (org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition)2 TSalesforceGetDeletedDefinition (org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedDefinition)2 TSalesforceGetServerTimestampDefinition (org.talend.components.salesforce.tsalesforcegetservertimestamp.TSalesforceGetServerTimestampDefinition)2 TSalesforceGetUpdatedDefinition (org.talend.components.salesforce.tsalesforcegetupdated.TSalesforceGetUpdatedDefinition)2