Search in sources :

Example 1 with ProgressBar

use of au.gov.asd.tac.constellation.views.tableview.components.ProgressBar in project constellation by constellation-app.

the class UpdateTableDataTaskNGTest method updateDataTask.

@Test
public void updateDataTask() {
    final TablePane tablePane = mock(TablePane.class);
    final Graph graph = mock(Graph.class);
    final TableViewState tableViewState = new TableViewState();
    final Table table = mock(Table.class);
    final ProgressBar progressBar = mock(ProgressBar.class);
    when(tablePane.getTable()).thenReturn(table);
    when(tablePane.getProgressBar()).thenReturn(progressBar);
    final TriggerDataUpdateTask updateTableDataTask = new TriggerDataUpdateTask(tablePane, graph, tableViewState);
    updateTableDataTask.run();
    verify(table).updateData(graph, tableViewState, progressBar);
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) Table(au.gov.asd.tac.constellation.views.tableview.components.Table) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) ProgressBar(au.gov.asd.tac.constellation.views.tableview.components.ProgressBar) TablePane(au.gov.asd.tac.constellation.views.tableview.panes.TablePane) Test(org.testng.annotations.Test)

Example 2 with ProgressBar

use of au.gov.asd.tac.constellation.views.tableview.components.ProgressBar in project constellation by constellation-app.

the class TablePaneNGTest method updateTable_interrupt.

@Test
public void updateTable_interrupt() {
    final Graph graph = mock(Graph.class);
    final TableViewState tableViewState = new TableViewState();
    final Table table = mock(Table.class);
    final ProgressBar progressBar = mock(ProgressBar.class);
    final TableToolbar tableToolbar = mock(TableToolbar.class);
    when(tablePane.getTable()).thenReturn(table);
    when(tablePane.getProgressBar()).thenReturn(progressBar);
    when(tablePane.getTableToolbar()).thenReturn(tableToolbar);
    doAnswer(mockitoInvocation -> {
        System.out.println("Interrupt: " + Thread.currentThread().getName());
        Thread.currentThread().interrupt();
        return null;
    }).when(table).updateColumns(graph, tableViewState);
    tablePane.updateTable(graph, tableViewState);
    try {
        tablePane.getFuture().get(30, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException ex) {
        fail("The update thread did not finish as expected within the allowed time. " + "Something went wrong");
    }
    verify(tableToolbar).updateToolbar(tableViewState);
    // Update columns is called
    verify(table).updateColumns(graph, tableViewState);
    // Verify everything after that is not called
    verify(table, times(0)).updateData(graph, tableViewState, progressBar);
    verify(table, times(0)).updateSelection(graph, tableViewState);
    // The future finished but maybe not the JavaFX thread
    WaitForAsyncUtils.waitForFxEvents();
    verify(table, times(0)).updateSortOrder();
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) Table(au.gov.asd.tac.constellation.views.tableview.components.Table) TableToolbar(au.gov.asd.tac.constellation.views.tableview.components.TableToolbar) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) ExecutionException(java.util.concurrent.ExecutionException) ProgressBar(au.gov.asd.tac.constellation.views.tableview.components.ProgressBar) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test)

Example 3 with ProgressBar

use of au.gov.asd.tac.constellation.views.tableview.components.ProgressBar in project constellation by constellation-app.

the class TablePaneNGTest method updateTable.

@Test
public void updateTable() {
    final Graph graph = mock(Graph.class);
    final TableViewState tableViewState = new TableViewState();
    final Table table = mock(Table.class);
    final ProgressBar progressBar = mock(ProgressBar.class);
    final TableToolbar tableToolbar = mock(TableToolbar.class);
    when(tablePane.getTable()).thenReturn(table);
    when(tablePane.getProgressBar()).thenReturn(progressBar);
    when(tablePane.getTableToolbar()).thenReturn(tableToolbar);
    tablePane.updateTable(graph, tableViewState);
    try {
        tablePane.getFuture().get(30, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException ex) {
        fail("The update thread did not finish as expected within the allowed time. " + "Something went wrong");
    }
    verify(tableToolbar).updateToolbar(tableViewState);
    verify(table).updateColumns(graph, tableViewState);
    verify(table).updateData(graph, tableViewState, progressBar);
    verify(table).updateSelection(graph, tableViewState);
    // The future finished but maybe not the JavaFX thread
    WaitForAsyncUtils.waitForFxEvents();
    verify(table).updateSortOrder();
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) Table(au.gov.asd.tac.constellation.views.tableview.components.Table) TableToolbar(au.gov.asd.tac.constellation.views.tableview.components.TableToolbar) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) ExecutionException(java.util.concurrent.ExecutionException) ProgressBar(au.gov.asd.tac.constellation.views.tableview.components.ProgressBar) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test)

Example 4 with ProgressBar

use of au.gov.asd.tac.constellation.views.tableview.components.ProgressBar in project constellation by constellation-app.

the class UpdateTableSelectionTaskNGTest method updateSelectionTask.

@Test
public void updateSelectionTask() {
    final TablePane tablePane = mock(TablePane.class);
    final Graph graph = mock(Graph.class);
    final TableViewState tableViewState = new TableViewState();
    final Table table = mock(Table.class);
    final ProgressBar progressBar = mock(ProgressBar.class);
    when(tablePane.getTable()).thenReturn(table);
    when(tablePane.getProgressBar()).thenReturn(progressBar);
    final TriggerSelectionUpdateTask updateTableSelectionTask = new TriggerSelectionUpdateTask(tablePane, graph, tableViewState);
    updateTableSelectionTask.run();
    verify(table).updateSelection(graph, tableViewState);
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) Table(au.gov.asd.tac.constellation.views.tableview.components.Table) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) ProgressBar(au.gov.asd.tac.constellation.views.tableview.components.ProgressBar) TablePane(au.gov.asd.tac.constellation.views.tableview.panes.TablePane) Test(org.testng.annotations.Test)

Aggregations

Graph (au.gov.asd.tac.constellation.graph.Graph)4 ProgressBar (au.gov.asd.tac.constellation.views.tableview.components.ProgressBar)4 Table (au.gov.asd.tac.constellation.views.tableview.components.Table)4 TableViewState (au.gov.asd.tac.constellation.views.tableview.state.TableViewState)4 Test (org.testng.annotations.Test)4 TableToolbar (au.gov.asd.tac.constellation.views.tableview.components.TableToolbar)2 TablePane (au.gov.asd.tac.constellation.views.tableview.panes.TablePane)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2