Search in sources :

Example 1 with StringProperty

use of org.talend.daikon.properties.property.StringProperty in project tdi-studio-se by Talend.

the class TestComponentDefinition method getReturnProperties.

@Override
public Property[] getReturnProperties() {
    StringProperty return1 = newProperty("return1");
    setupI18N(new Property<?>[] { return1 });
    return new Property[] { return1, RETURN_ERROR_MESSAGE_PROP, RETURN_TOTAL_RECORD_COUNT_PROP, RETURN_SUCCESS_RECORD_COUNT_PROP, RETURN_REJECT_RECORD_COUNT_PROP };
}
Also used : StringProperty(org.talend.daikon.properties.property.StringProperty) StringProperty(org.talend.daikon.properties.property.StringProperty) Property(org.talend.daikon.properties.property.Property)

Example 2 with StringProperty

use of org.talend.daikon.properties.property.StringProperty in project components by Talend.

the class TestComponentDefinition method getReturnProperties.

@Override
public Property[] getReturnProperties() {
    StringProperty return1 = newProperty("return1");
    return1.setI18nMessageFormatter(getI18nMessageFormatter());
    return new Property[] { return1, RETURN_ERROR_MESSAGE_PROP, RETURN_TOTAL_RECORD_COUNT_PROP, RETURN_SUCCESS_RECORD_COUNT_PROP, RETURN_REJECT_RECORD_COUNT_PROP };
}
Also used : StringProperty(org.talend.daikon.properties.property.StringProperty) Property(org.talend.daikon.properties.property.Property) PropertyFactory.newProperty(org.talend.daikon.properties.property.PropertyFactory.newProperty) StringProperty(org.talend.daikon.properties.property.StringProperty)

Example 3 with StringProperty

use of org.talend.daikon.properties.property.StringProperty in project components by Talend.

the class AzureStorageRuntimeTest method testInitializeValidReferencedConnection.

@Test
public void testInitializeValidReferencedConnection() {
    // Init the referenced connection
    TAzureStorageConnectionProperties referenced = new TAzureStorageConnectionProperties("sharedConnection");
    referenced.setupProperties();
    referenced.accountName.setValue("fakeAccountName");
    referenced.accountKey.setValue("fakeAccountKey=ANBHFYRJJFHRIKKJFU");
    // Add referenced connection to the runtime container
    runtimeContainer.setComponentData("shared-connection", AzureStorageRuntime.KEY_CONNECTION_PROPERTIES, referenced);
    // reference connection by id
    properties.referencedComponent.componentInstanceId = new StringProperty("connection").setValue("shared-connection");
    // init and test
    ValidationResult validationResult = this.azureStorageRuntime.initialize(runtimeContainer, properties);
    assertEquals(ValidationResult.OK.getStatus(), validationResult.getStatus());
    assertNotNull(azureStorageRuntime.getConnectionProperties());
}
Also used : StringProperty(org.talend.daikon.properties.property.StringProperty) TAzureStorageConnectionProperties(org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) Test(org.junit.Test)

Example 4 with StringProperty

use of org.talend.daikon.properties.property.StringProperty in project components by Talend.

the class CommonUtilsTest method testUpdatePossibleValues.

@Test
public void testUpdatePossibleValues() {
    StringProperty property = new StringProperty("names");
    property.setPossibleValues(Arrays.asList("a", "b", "c"));
    property.setStoredValue("a");
    List<String> newPossibleValues = Arrays.asList("a1", "b1", "c1");
    CommonUtils.updatePossibleValues(property, newPossibleValues);
    Assert.assertEquals("a1", property.getValue());
    Assert.assertEquals(newPossibleValues, property.getPossibleValues());
    newPossibleValues = Arrays.asList("b1", "a1", "c1", "d1", "e1", "f1");
    CommonUtils.updatePossibleValues(property, newPossibleValues);
    Assert.assertEquals("a1", property.getValue());
    Assert.assertEquals(newPossibleValues, property.getPossibleValues());
}
Also used : StringProperty(org.talend.daikon.properties.property.StringProperty) Test(org.junit.Test)

Example 5 with StringProperty

use of org.talend.daikon.properties.property.StringProperty in project tdi-studio-se by Talend.

the class ComponentsUtilsTest method testGetFormalPossibleValues.

@Test
public void testGetFormalPossibleValues() {
    ComponentService componentService = ComponentsUtils.getComponentService();
    //$NON-NLS-1$
    ComponentProperties props = (ComponentProperties) new TestProperties("test").init();
    Form form = props.getForm(Form.MAIN);
    Element element = new FakeElement(form.getName());
    Widget testWidget = null;
    Property testProperty = null;
    Collection<Widget> widgets = form.getWidgets();
    Iterator<Widget> widgetsIterator = widgets.iterator();
    while (widgetsIterator.hasNext()) {
        Widget widget = widgetsIterator.next();
        NamedThing content = widget.getContent();
        if (content instanceof Property) {
            testWidget = widget;
            testProperty = (Property) content;
            break;
        }
    }
    assertNotNull(testWidget);
    assertNotNull(testProperty);
    // Test NamedThing type
    List<NamedThing> namedThings = new ArrayList<>();
    namedThings.add(new SimpleNamedThing("p1", "Test P1"));
    namedThings.add(new SimpleNamedThing("p2", "Test P2"));
    namedThings.add(new SimpleNamedThing("p3", "Test P3"));
    testProperty.setPossibleValues(namedThings);
    GenericElementParameter param = new GenericElementParameter(element, props, form, testWidget, componentService);
    param.setPossibleValues(testProperty.getPossibleValues());
    List<NamedThing> possibleValues = ComponentsUtils.getFormalPossibleValues(param);
    assertEquals(3, possibleValues.size());
    namedThings.retainAll(possibleValues);
    assertEquals(3, namedThings.size());
    // Test Integer type which is not support yet
    List<Integer> ints = new ArrayList<>();
    ints.add(1);
    ints.add(2);
    ints.add(3);
    testProperty.setPossibleValues(ints);
    param = new GenericElementParameter(element, props, form, testWidget, componentService);
    param.setPossibleValues(testProperty.getPossibleValues());
    possibleValues = ComponentsUtils.getFormalPossibleValues(param);
    assertEquals(0, possibleValues.size());
    // Test StringProperty
    testWidget = null;
    StringProperty testStringProperty = null;
    widgetsIterator = widgets.iterator();
    while (widgetsIterator.hasNext()) {
        Widget widget = widgetsIterator.next();
        NamedThing content = widget.getContent();
        if (content instanceof StringProperty) {
            testWidget = widget;
            testStringProperty = (StringProperty) content;
            break;
        }
    }
    assertNotNull(testWidget);
    assertNotNull(testStringProperty);
    testStringProperty.setPossibleNamedThingValues(namedThings);
    param = new GenericElementParameter(element, props, form, testWidget, componentService);
    param.setPossibleValues(testStringProperty.getPossibleValues());
    possibleValues = ComponentsUtils.getFormalPossibleValues(param);
    assertEquals(3, possibleValues.size());
    List<String> pvNames = new ArrayList<>();
    for (NamedThing pv : possibleValues) {
        pvNames.add(pv.getName());
    }
    for (NamedThing nt : namedThings) {
        assertTrue(pvNames.contains(nt.getName()));
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form) Element(org.talend.core.model.process.Element) FakeElement(org.talend.designer.core.model.FakeElement) Widget(org.talend.daikon.properties.presentation.Widget) ArrayList(java.util.ArrayList) StringProperty(org.talend.daikon.properties.property.StringProperty) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) FakeElement(org.talend.designer.core.model.FakeElement) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ComponentService(org.talend.components.api.service.ComponentService) StringProperty(org.talend.daikon.properties.property.StringProperty) Property(org.talend.daikon.properties.property.Property) Test(org.junit.Test)

Aggregations

StringProperty (org.talend.daikon.properties.property.StringProperty)6 Property (org.talend.daikon.properties.property.Property)4 Test (org.junit.Test)3 PropertyFactory.newProperty (org.talend.daikon.properties.property.PropertyFactory.newProperty)2 ArrayList (java.util.ArrayList)1 ComponentProperties (org.talend.components.api.properties.ComponentProperties)1 ComponentService (org.talend.components.api.service.ComponentService)1 TAzureStorageConnectionProperties (org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties)1 Element (org.talend.core.model.process.Element)1 NamedThing (org.talend.daikon.NamedThing)1 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1 Form (org.talend.daikon.properties.presentation.Form)1 Widget (org.talend.daikon.properties.presentation.Widget)1 GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)1 FakeElement (org.talend.designer.core.model.FakeElement)1