use of org.kie.workbench.common.forms.dynamic.model.config.SelectorData in project kie-wb-common by kiegroup.
the class BeanPropertiesProviderTest method testGetModelProperties.
protected void testGetModelProperties(String... columns) {
field = new MultipleSubFormFieldDefinition();
for (String column : columns) {
field.getColumnMetas().add(new TableColumnMeta(column, column));
}
List<String> bannedColumns = new ArrayList<>(Arrays.asList(columns));
if (!StringUtils.isEmpty(currentEditedMeta.getProperty())) {
bannedColumns.remove(currentEditedMeta.getProperty());
}
field.setStandaloneClassName(TYPE_NAME);
parentContext = new FormEditorRenderingContext(path);
parentContext.setModel(field);
context.setParentContext(parentContext);
expectedFields = DATA_OBJECT_VALID_FIELDS - bannedColumns.size();
SelectorData data = provider.getSelectorData(context);
verify(service).getDataObjectProperties(any(), any());
assertNotNull(data);
assertNotNull(data.getValues());
assertNull(data.getSelectedValue());
assertFalse(data.getValues().isEmpty());
assertEquals(expectedFields, data.getValues().size());
for (String column : bannedColumns) {
assertNull(data.getValues().get(column));
}
assertNull(data.getValues().get(DataObjectFormModelHandler.SERIAL_VERSION_UID));
assertNull(data.getValues().get(PERSISTENCE_ID_PROPERTY));
}
use of org.kie.workbench.common.forms.dynamic.model.config.SelectorData in project kie-wb-common by kiegroup.
the class BeanPropertiesProviderTest method testWithoutParentContext.
@Test
public void testWithoutParentContext() {
SelectorData data = provider.getSelectorData(context);
verify(service, never()).getDataObjectProperties(any(), any());
assertNotNull(data);
assertNotNull(data.getValues());
assertTrue(data.getValues().isEmpty());
assertNull(data.getSelectedValue());
}
use of org.kie.workbench.common.forms.dynamic.model.config.SelectorData in project kie-wb-common by kiegroup.
the class SelectorOptionsProvider method getSelectorData.
@Override
public SelectorData getSelectorData(FormRenderingContext context) {
SelectorData data = new SelectorData<>();
Map<Object, String> values = new HashMap<>();
Object selectedValue = null;
if (context.getModel() instanceof SelectorFieldBaseDefinition) {
SelectorFieldBaseDefinition selector = (SelectorFieldBaseDefinition) context.getModel();
selectedValue = selector.getDefaultValue();
List<SelectorOption> options = selector.getOptions();
options.forEach(option -> values.put(option.getValue(), option.getText()));
if (!values.containsKey(selectedValue)) {
selectedValue = null;
selector.setDefaultValue(null);
}
}
data.setValues(values);
data.setSelectedValue(selectedValue);
return data;
}
use of org.kie.workbench.common.forms.dynamic.model.config.SelectorData in project kie-wb-common by kiegroup.
the class AbstractProcessFilteredNodeProviderBaseTest method testGetSelectorDataWithNoValues.
@Test
public void testGetSelectorDataWithNoValues() {
@SuppressWarnings("unchecked") Iterable<Element> nodes = mock(Iterable.class);
when(graph.nodes()).thenReturn(nodes);
when(nodes.spliterator()).thenReturn(Spliterators.emptySpliterator());
SelectorData selectorData = provider.getSelectorData(renderingContext);
Map values = selectorData.getValues();
assertTrue(values.isEmpty());
}
use of org.kie.workbench.common.forms.dynamic.model.config.SelectorData in project kie-wb-common by kiegroup.
the class DefaultRouteFormProviderTest method testGetSelectorDataWithValues.
@Test
public void testGetSelectorDataWithValues() {
List<Element> nodes = mockModes();
when(graph.nodes()).thenReturn(nodes);
// add the desired edges to the selected node.
when(selectedNode.getOutEdges()).thenReturn(outEdges);
SelectorData selectorData = provider.getSelectorData(renderingContext);
Map values = selectorData.getValues();
verifyValues(values);
}
Aggregations