Skip to content

Commit

Permalink
DROOLS-5067: Show checkmark for 'expression </>' property
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Marko committed Mar 3, 2020
1 parent bc2e325 commit 7d0e5d1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public void showAll() {

@Override
public void selectProperty(String factName, List<String> propertyParts) {
final ListGroupItemView listGroupItemView = listGroupItemViewMap.get(factName);
if (!listGroupItemView.isShown()) {
onToggleRowExpansion(listGroupItemView, false);
final ListGroupItemView instanceListGroupItemView = listGroupItemViewMap.get(factName);
if (!instanceListGroupItemView.isShown()) {
onToggleRowExpansion(instanceListGroupItemView, false);
}
String key;
for (int i = 1; i < propertyParts.size(); i++) {
Expand All @@ -87,6 +87,8 @@ public void selectProperty(String factName, List<String> propertyParts) {
key = factName + "." + String.join(".", propertyParts);
if (fieldItemPresenter.fieldItemMap.containsKey(key)) {
fieldItemPresenter.fieldItemMap.get(key).onFieldElementSelected();
} else {
instanceListGroupItemView.showCheck(true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.drools.workbench.screens.scenariosimulation.client.rightpanel;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -26,6 +27,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Spy;

import static org.drools.workbench.screens.scenariosimulation.client.TestProperties.FACT_NAME;
import static org.drools.workbench.screens.scenariosimulation.client.TestProperties.FULL_PACKAGE;
Expand Down Expand Up @@ -54,8 +56,8 @@ public class ListGroupItemPresenterTest extends AbstractTestToolsTest {
@Mock
private DivElement divElementMock;

@Mock
private FieldItemPresenter fieldItemPresenterMock;
@Spy
private FieldItemPresenter fieldItemPresenterSpy;

@Mock
private Map<String, ListGroupItemView> listGroupItemViewMapMock;
Expand All @@ -76,7 +78,7 @@ public void setup() {
this.listGroupItemPresenter = spy(new ListGroupItemPresenter() {
{
listGroupItemViewMap = listGroupItemViewMapMock;
fieldItemPresenter = fieldItemPresenterMock;
fieldItemPresenter = fieldItemPresenterSpy;
viewsProvider = viewsProviderMock;
testToolsPresenter = testToolsPresenterMock;
}
Expand Down Expand Up @@ -163,7 +165,7 @@ public void populateListGroupItemView() {
Map<String, String> simpleProperties = FACT_MODEL_TREE.getSimpleProperties();
for (String key : simpleProperties.keySet()) {
String value = simpleProperties.get(key);
verify(fieldItemPresenterMock, times(1)).getLIElement(eq(FACT_MODEL_TREE.getFactName()), eq(FACT_MODEL_TREE.getFactName()), eq(key), eq(value));
verify(fieldItemPresenterSpy, times(1)).getLIElement(eq(FACT_MODEL_TREE.getFactName()), eq(FACT_MODEL_TREE.getFactName()), eq(key), eq(value));
}
verify(listGroupItemViewMock, times(simpleProperties.size())).addFactField(anyObject());
reset(listGroupItemViewMock);
Expand All @@ -179,6 +181,19 @@ public void populateListGroupItemView() {
public void resetTest() {
listGroupItemPresenter.reset();
verify(listGroupItemViewMapMock, times(1)).clear();
verify(fieldItemPresenterMock, times(1)).reset();
verify(fieldItemPresenterSpy, times(1)).reset();
}

@Test
public void testSelectPropertyNoFieldAvailableJustExpression() {
final String instance = "Applicant";
final String property = "expression";

when(listGroupItemViewMapMock.get(instance)).thenReturn(listGroupItemViewMock);
fieldItemPresenterSpy.fieldItemMap = Collections.emptyMap();

listGroupItemPresenter.selectProperty(instance, Collections.singletonList(property));

verify(listGroupItemViewMock).showCheck(true);
}
}

0 comments on commit 7d0e5d1

Please sign in to comment.