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;
});
}
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));
}
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));
}
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)));
}
}
}
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"));
}
}
}
Aggregations