use of org.talend.daikon.properties.Properties 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.properties.Properties in project components by Talend.
the class ComponentPropertiesImpl method updateNestedProperties.
/**
* this will look for all authorized nested properties that shall be compatible with the nestedValues and copy all
* nestedValues properties into this.<br>
* This default implementation will look for all nested properties that matches the type of nestedValues and copy
* all nestedValues properties into it. This way of course be overriden if some component want to prevent the copy
* of a given type into it.
*
* @param nestedValues values to be used update this current ComponentProperties nested Properties.
* @return true if the copy was done and false if the targetProperties does not accept the nestedValues type.
*/
@Override
public boolean updateNestedProperties(final Properties nestedValues) {
if (nestedValues == null) {
return false;
}
// else not null so perfect
final AtomicBoolean isCopied = new AtomicBoolean(false);
accept(new PropertiesVisitor() {
@Override
public void visit(Properties properties, Properties parent) {
if (properties.getClass().isAssignableFrom(nestedValues.getClass())) {
properties.copyValuesFrom(nestedValues);
isCopied.set(true);
}
// else not a compatible nestedValues so keep going
}
}, this);
return isCopied.get();
}
use of org.talend.daikon.properties.Properties in project components by Talend.
the class FullExamplePropertiesTest method testAllCallBacksAreCalled.
@Test
public void testAllCallBacksAreCalled() throws Throwable {
interactWithAllWidgets();
Properties validateProperty = getComponentService().validateProperty(cp.validateAllCallbackCalled.getName(), cp);
assertEquals(validateProperty.getValidationResult().getMessage(), Result.OK, validateProperty.getValidationResult().getStatus());
}
use of org.talend.daikon.properties.Properties in project components by Talend.
the class FullExamplePropertiesTest method testHiddingAField.
@Test
public void testHiddingAField() throws Throwable {
assertFalse(cp.getForm(Form.MAIN).getWidget(cp.stringProp.getName()).isHidden());
cp.hideStringPropProp.setValue(true);
Properties resultCP = getComponentService().afterProperty(cp.hideStringPropProp.getName(), cp);
assertTrue(resultCP.getForm(Form.MAIN).getWidget(cp.stringProp.getName()).isHidden());
}
Aggregations