Search in sources :

Example 1 with DatasetDefinition

use of org.talend.components.common.dataset.DatasetDefinition 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)

Aggregations

HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1 DatasetDefinition (org.talend.components.common.dataset.DatasetDefinition)1 DatastoreDefinition (org.talend.components.common.datastore.DatastoreDefinition)1 MockDatasetDefinition (org.talend.components.service.rest.mock.MockDatasetDefinition)1 MockDatasetProperties (org.talend.components.service.rest.mock.MockDatasetProperties)1 MockDatastoreDefinition (org.talend.components.service.rest.mock.MockDatastoreDefinition)1 MockDatastoreProperties (org.talend.components.service.rest.mock.MockDatastoreProperties)1 Definition (org.talend.daikon.definition.Definition)1 Properties (org.talend.daikon.properties.Properties)1