use of org.talend.components.common.datastore.DatastoreDefinition in project components by Talend.
the class DataStoreServiceImplTest method getDatastoreDefinition.
@Test
@Ignore
public void getDatastoreDefinition() throws Exception {
// Given
ArrayList<DatastoreDefinition> definitions = new ArrayList<>();
DatastoreDefinition dsd1 = mock(DatastoreDefinition.class);
when(dsd1.getName()).thenReturn("toto");
definitions.add(dsd1);
DatastoreDefinition dsd2 = mock(DatastoreDefinition.class);
String datastoreName = "datastore name";
when(dsd2.getName()).thenReturn(datastoreName);
definitions.add(dsd2);
when(defRegistryDelegate.getDefinitionsMapByType(DatastoreDefinition.class).values()).thenReturn(definitions);
// When
// DatastoreDefinition datastoreDefinition = dataStoreController.getDataStoreProperties(datastoreName);
//
// // Then
// assertEquals(dsd2, datastoreDefinition);
// verify(componentServiceDelegate, times(1)).getDefinitionsByType(DatastoreDefinition.class);
// verify(dsd1, times(1)).getName();
// verify(dsd2, times(1)).getName();
}
use of org.talend.components.common.datastore.DatastoreDefinition in project components by Talend.
the class DefinitionsControllerImpl method listDefinitions.
/**
* Return all known definitions that match the given type.
*
* @param type the wanted definition type.
* @return all known definitions that match the given type.
* @returnWrapped java.lang.Iterable<org.talend.components.service.rest.dto.DefinitionDTO>
*/
@Override
public List<DefinitionDTO> listDefinitions(DefinitionType type, String tag) {
logger.debug("listing definitions for {} ", type);
//
Iterable<? extends Definition> definitionsByType = definitionServiceDelegate.getDefinitionsMapByType(type.getTargetClass()).values();
Stream<? extends Definition> stream = stream(definitionsByType.spliterator(), false);
if (tag != null) {
stream = //
stream.filter(c -> HasTags.class.isAssignableFrom(c.getClass())).filter(c -> {
for (Tag defTag : ((HasTags) c).getTags()) {
if (TagUtils.hasTag(defTag, tag)) {
return true;
}
}
return false;
});
}
return stream.map(c -> {
if (type == DefinitionType.COMPONENT) {
return new DefinitionDTO((ComponentDefinition) c);
} else {
return new DefinitionDTO((DatastoreDefinition) c);
}
}).collect(Collectors.toList());
}
use of org.talend.components.common.datastore.DatastoreDefinition 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