use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenterTest method getEnumLookupsWithQueryExpressionDefinition.
@Test
@SuppressWarnings("unchecked")
public void getEnumLookupsWithQueryExpressionDefinition() {
final DependentEnumsUtilities.Context context = mock(DependentEnumsUtilities.Context.class);
final Callback<Map<String, String>> callback = mock(Callback.class);
final DropDownData dd = DropDownData.create("query", new String[] { "one", "two" });
when(oracle.getEnums(eq("FactType"), eq("field"), any(Map.class))).thenReturn(dd);
when(enumDropdownService.loadDropDownExpression(any(Path.class), any(String[].class), any(String.class))).thenReturn(new String[] { "three", "four" });
dtPresenter.getEnumLookups("FactType", "field", context, callback);
verify(callback, times(1)).callback(callbackValueCaptor.capture());
final Map<String, String> callbackValue = callbackValueCaptor.getValue();
assertNotNull(callbackValue);
assertFalse(callbackValue.isEmpty());
assertTrue(callbackValue.containsKey("three"));
assertTrue(callbackValue.containsKey("four"));
}
use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.
the class EnumLoaderUtilitiesTest method checkQueryExpressionDefinitionWithCaching.
@Test
public void checkQueryExpressionDefinitionWithCaching() {
final Callback<Map<String, String>> callback = (result) -> {
assertFalse(result.isEmpty());
assertEquals(2, result.size());
assertTrue(result.containsKey("one"));
assertTrue(result.containsKey("two"));
};
final String[] fixedList = { "one", "two" };
final String[] valuePairs = { "param1=a", "param2=b" };
final DropDownData enumDefinition = DropDownData.create("expression", valuePairs);
when(enumDropdownService.loadDropDownExpression(any(Path.class), any(String[].class), any(String.class))).thenReturn(fixedList);
// Call twice to check caching
enumLoaderUtilities.getEnums(enumDefinition, callback, presenter, onFetchCommand, onFetchCompleteCommand);
enumLoaderUtilities.getEnums(enumDefinition, callback, presenter, onFetchCommand, onFetchCompleteCommand);
verify(enumDropdownService, times(1)).loadDropDownExpression(any(Path.class), any(String[].class), any(String.class));
verify(onFetchCommand, times(1)).execute();
verify(onFetchCompleteCommand, times(1)).execute();
verify(enumLoaderUtilities, times(1)).convertDropDownData(any(String[].class));
verify(view, times(1)).batch();
}
use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.
the class EnumLoaderUtilitiesTest method checkFixedListDefinitionWithCaching.
@Test
public void checkFixedListDefinitionWithCaching() {
final Callback<Map<String, String>> callback = (result) -> {
assertFalse(result.isEmpty());
assertEquals(2, result.size());
assertTrue(result.containsKey("one"));
assertTrue(result.containsKey("two"));
};
final String[] fixedList = { "one", "two" };
final DropDownData enumDefinition = DropDownData.create(fixedList);
// Call twice to check caching
enumLoaderUtilities.getEnums(enumDefinition, callback, presenter, onFetchCommand, onFetchCompleteCommand);
enumLoaderUtilities.getEnums(enumDefinition, callback, presenter, onFetchCommand, onFetchCompleteCommand);
verify(enumDropdownService, never()).loadDropDownExpression(any(Path.class), any(String[].class), any(String.class));
verify(onFetchCommand, never()).execute();
verify(onFetchCompleteCommand, never()).execute();
verify(enumLoaderUtilities, times(1)).convertDropDownData(any(String[].class));
}
use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.
the class ConstraintValueEditorHelperTest method isEnumEquivalentDifferentLength.
@Test
public void isEnumEquivalentDifferentLength() throws Exception {
final DropDownData dropDownData = mock(DropDownData.class);
doReturn(new String[0]).when(dropDownData).getFixedList();
Assertions.assertThat(ConstraintValueEditorHelper.isEnumEquivalent(new String[1], dropDownData)).isFalse();
}
use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.
the class ConstraintValueEditorHelperTest method isEnumEquivalentDifferentContent.
@Test
public void isEnumEquivalentDifferentContent() throws Exception {
final DropDownData dropDownData = mock(DropDownData.class);
doReturn(new String[] { "a" }).when(dropDownData).getFixedList();
Assertions.assertThat(ConstraintValueEditorHelper.isEnumEquivalent(new String[] { "b" }, dropDownData)).isFalse();
}
Aggregations