Search in sources :

Example 21 with VetoException

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenter method doAppendColumn.

private void doAppendColumn(final BaseColumn column, final VetoableColumnCommand append, final Command callback) {
    if (isReadOnly()) {
        return;
    }
    try {
        append.execute();
        refreshView();
        // Log addition of column
        model.getAuditLog().add(new InsertColumnAuditLogEntry(identity.getIdentifier(), column));
        callback.execute();
    } catch (VetoException e) {
        getModellerPresenter().getView().showGenericVetoMessage();
    }
}
Also used : VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) InsertColumnAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.InsertColumnAuditLogEntry)

Example 22 with VetoException

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenter method deleteRow.

private void deleteRow(final int rowIndex) {
    try {
        synchronizer.deleteRow(rowIndex);
        refreshView();
        // Log deletion of column
        model.getAuditLog().add(new DeleteRowAuditLogEntry(identity.getIdentifier(), rowIndex));
    } catch (VetoException e) {
        getModellerPresenter().getView().showGenericVetoMessage();
    }
}
Also used : VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) DeleteRowAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.DeleteRowAuditLogEntry)

Example 23 with VetoException

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.

the class ColumnManagementViewTest method testRemoveConditionCanNotBeDeleted.

@Test
public void testRemoveConditionCanNotBeDeleted() throws Exception {
    Stream.of(ConditionCol52.class, BRLConditionColumn.class).map(Mockito::mock).forEach(column -> {
        final String columnHeader = "column header";
        final ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
        doReturn(Optional.of(decisionTablePresenter)).when(modellerPresenter).getActiveDecisionTable();
        doReturn(columnHeader).when(column).getHeader();
        doNothing().when(modellerView).showUnableToDeleteColumnMessage(column);
        try {
            doThrow(VetoDeletePatternInUseException.class).when(decisionTablePresenter).deleteColumn(eq(column));
            view.removeCondition(column);
            verify(view).deleteAnchor(eq("column header"), commandCaptor.capture());
            commandCaptor.getValue().execute();
            verify(modellerView).showUnableToDeleteColumnMessage(eq(column));
        } catch (VetoException veto) {
        }
        reset(view);
    });
}
Also used : VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) Command(com.google.gwt.user.client.Command) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 24 with VetoException

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.

the class ColumnManagementViewTest method testRemoveCondition.

@Test
public void testRemoveCondition() throws Exception {
    Stream.of(ConditionCol52.class, BRLConditionColumn.class).map(Mockito::mock).forEach(column -> {
        final String columnHeader = "column header";
        final ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
        doReturn(Optional.of(decisionTablePresenter)).when(modellerPresenter).getActiveDecisionTable();
        doReturn(columnHeader).when(column).getHeader();
        view.removeCondition(column);
        verify(view).deleteAnchor(eq("column header"), commandCaptor.capture());
        commandCaptor.getValue().execute();
        try {
            verify(decisionTablePresenter).deleteColumn(column);
        } catch (VetoException veto) {
            fail("Deletion should have succeeded.");
        }
        reset(view);
    });
}
Also used : VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) Command(com.google.gwt.user.client.Command) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

VetoException (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException)24 Test (org.junit.Test)14 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)13 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)13 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)13 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)8 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)7 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)7 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)6 Dependent (javax.enterprise.context.Dependent)5 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)5 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)5 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)5 VetoDeletePatternInUseException (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoDeletePatternInUseException)5 List (java.util.List)4 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)4 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)4 Command (com.google.gwt.user.client.Command)3 Collections (java.util.Collections)3 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)3