예제 #1
0
  @Before
  @SuppressWarnings("unchecked")
  public void setup() {
    model = new GuidedDecisionTable52();
    uiModel = new GuidedDecisionTableUiModel(mock(ModelSynchronizer.class));
    clipboard = new DefaultClipboard();

    when(dtPresenter.getView()).thenReturn(dtPresenterView);
    when(dtPresenter.getModel()).thenReturn(model);
    when(dtPresenter.getAccess()).thenReturn(access);
    when(dtPresenterView.getModel()).thenReturn(uiModel);

    uiModel.appendColumn(
        new BaseGridColumn<String>(
            mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
    uiModel.appendColumn(
        new BaseGridColumn<String>(
            mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
    uiModel.appendColumn(
        new BaseGridColumn<String>(
            mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
    uiModel.appendRow(new BaseGridRow());

    menu = new RowContextMenu(view, clipboard);
    menu.setup();
  }
예제 #2
0
  @Test
  public void testOnDecisionTableSelectionsChangedEventWithSelectionsWithClipboardPopulated() {
    model.getMetadataCols().add(new MetadataCol52());
    model
        .getData()
        .add(
            new ArrayList<DTCellValue52>() {
              {
                add(new DTCellValue52(1));
                add(new DTCellValue52("descr"));
                add(new DTCellValue52("md"));
              }
            });

    uiModel.selectCell(0, 2);
    clipboard.setData(
        new HashSet<Clipboard.ClipboardData>() {
          {
            add(new DefaultClipboard.ClipboardDataImpl(0, 2, model.getData().get(0).get(2)));
          }
        });

    menu.onDecisionTableSelectionsChangedEvent(
        new DecisionTableSelectionsChangedEvent(dtPresenter));

    verify(view, times(1)).enableCutMenuItem(eq(true));
    verify(view, times(1)).enableCopyMenuItem(eq(true));
    verify(view, times(1)).enablePasteMenuItem(eq(true));
    verify(view, times(1)).enableInsertRowAboveMenuItem(eq(true));
    verify(view, times(1)).enableInsertRowBelowMenuItem(eq(true));
    verify(view, times(1)).enableDeleteRowMenuItem(eq(true));
  }
예제 #3
0
  @Test
  public void testOnDecisionTableSelectionsChangedEventWithSelections() {
    model.getMetadataCols().add(new MetadataCol52());
    model
        .getData()
        .add(
            new ArrayList<DTCellValue52>() {
              {
                add(new DTCellValue52(1));
                add(new DTCellValue52("descr"));
                add(new DTCellValue52("md"));
              }
            });

    uiModel.selectCell(0, 2);

    menu.onDecisionTableSelectionsChangedEvent(
        new DecisionTableSelectionsChangedEvent(dtPresenter));

    verify(view, times(1)).enableCutMenuItem(eq(true));
    verify(view, times(1)).enableCopyMenuItem(eq(true));
    verify(view, times(1)).enablePasteMenuItem(eq(false));
    verify(view, times(1)).enableInsertRowAboveMenuItem(eq(true));
    verify(view, times(1)).enableInsertRowBelowMenuItem(eq(true));
    verify(view, times(1)).enableDeleteRowMenuItem(eq(true));
  }
예제 #4
0
  @Test
  public void testOnDecisionTableSelectedEventWithNoSelections() {
    menu.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter));

    verify(view, times(1)).enableCutMenuItem(eq(false));
    verify(view, times(1)).enableCopyMenuItem(eq(false));
    verify(view, times(1)).enablePasteMenuItem(eq(false));
    verify(view, times(1)).enableInsertRowAboveMenuItem(eq(false));
    verify(view, times(1)).enableInsertRowBelowMenuItem(eq(false));
    verify(view, times(1)).enableDeleteRowMenuItem(eq(false));
  }
예제 #5
0
  @Test
  public void testOnDecisionTableSelectedEventReadOnly() {
    dtPresenter.getAccess().setReadOnly(true);
    menu.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter));

    verify(view, times(1)).enableCutMenuItem(eq(false));
    verify(view, times(1)).enableCopyMenuItem(eq(false));
    verify(view, times(1)).enablePasteMenuItem(eq(false));
    verify(view, times(1)).enableInsertRowAboveMenuItem(eq(false));
    verify(view, times(1)).enableInsertRowBelowMenuItem(eq(false));
    verify(view, times(1)).enableDeleteRowMenuItem(eq(false));
  }
예제 #6
0
  @Test
  public void testOnDecisionTableSelectionsChangedEventWithMultipleRowsSelected() {
    model
        .getConditions()
        .add(
            new Pattern52() {
              {
                setFactType("Fact");
                getChildColumns()
                    .add(
                        new ConditionCol52() {
                          {
                            setFactType("Fact");
                            setFactField("field1");
                            setFieldType(DataType.TYPE_STRING);
                            setOperator("==");
                          }
                        });
              }
            });
    model
        .getData()
        .add(
            new ArrayList<DTCellValue52>() {
              {
                add(new DTCellValue52(1));
                add(new DTCellValue52("descr"));
                add(new DTCellValue52("md"));
              }
            });
    model
        .getData()
        .add(
            new ArrayList<DTCellValue52>() {
              {
                add(new DTCellValue52(1));
                add(new DTCellValue52("descr"));
                add(new DTCellValue52("md"));
              }
            });

    uiModel.selectCells(0, 2, 1, 2);

    menu.onDecisionTableSelectionsChangedEvent(
        new DecisionTableSelectionsChangedEvent(dtPresenter));

    verify(view, times(1)).enableCutMenuItem(eq(true));
    verify(view, times(1)).enableCopyMenuItem(eq(true));
    verify(view, times(1)).enablePasteMenuItem(eq(false));
    verify(view, times(1)).enableInsertRowAboveMenuItem(eq(false));
    verify(view, times(1)).enableInsertRowBelowMenuItem(eq(false));
    verify(view, times(1)).enableDeleteRowMenuItem(eq(true));
  }