use of org.talend.components.service.rest.mock.MockDatasetDefinition 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;
});
}
Aggregations