Search in sources :

Example 1 with CleanupActionsListModel

use of org.jabref.gui.cleanup.CleanupActionsListModel in project jabref by JabRef.

the class CleanupActionsListModelTest method resetFiresItemsChanged.

@Test
public void resetFiresItemsChanged() throws Exception {
    CleanupActionsListModel model = new CleanupActionsListModel(Collections.emptyList());
    ListDataListener listener = mock(ListDataListener.class);
    model.addListDataListener(listener);
    FieldFormatterCleanups defaultFormatters = mock(FieldFormatterCleanups.class);
    model.reset(defaultFormatters);
    ArgumentCaptor<ListDataEvent> argument = ArgumentCaptor.forClass(ListDataEvent.class);
    verify(listener).contentsChanged(argument.capture());
    assertEquals(ListDataEvent.CONTENTS_CHANGED, argument.getValue().getType());
}
Also used : ListDataEvent(javax.swing.event.ListDataEvent) CleanupActionsListModel(org.jabref.gui.cleanup.CleanupActionsListModel) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) ListDataListener(javax.swing.event.ListDataListener) Test(org.junit.Test)

Example 2 with CleanupActionsListModel

use of org.jabref.gui.cleanup.CleanupActionsListModel in project jabref by JabRef.

the class CleanupActionsListModelTest method removedAtIndexMinus1DoesNothing.

@Test
public void removedAtIndexMinus1DoesNothing() {
    CleanupActionsListModel model = new CleanupActionsListModel(getDefaultFieldFormatterCleanups());
    ListDataListener listener = mock(ListDataListener.class);
    model.addListDataListener(listener);
    model.removeAtIndex(-1);
    verifyZeroInteractions(listener);
}
Also used : CleanupActionsListModel(org.jabref.gui.cleanup.CleanupActionsListModel) ListDataListener(javax.swing.event.ListDataListener) Test(org.junit.Test)

Example 3 with CleanupActionsListModel

use of org.jabref.gui.cleanup.CleanupActionsListModel in project jabref by JabRef.

the class CleanupActionsListModelTest method removedAtIndexOkay.

@Test
public void removedAtIndexOkay() {
    CleanupActionsListModel model = new CleanupActionsListModel(getDefaultFieldFormatterCleanups());
    ListDataListener listener = mock(ListDataListener.class);
    model.addListDataListener(listener);
    model.removeAtIndex(0);
    ArgumentCaptor<ListDataEvent> argument = ArgumentCaptor.forClass(ListDataEvent.class);
    verify(listener).intervalRemoved(argument.capture());
    assertEquals(ListDataEvent.INTERVAL_REMOVED, argument.getValue().getType());
}
Also used : ListDataEvent(javax.swing.event.ListDataEvent) CleanupActionsListModel(org.jabref.gui.cleanup.CleanupActionsListModel) ListDataListener(javax.swing.event.ListDataListener) Test(org.junit.Test)

Example 4 with CleanupActionsListModel

use of org.jabref.gui.cleanup.CleanupActionsListModel in project jabref by JabRef.

the class CleanupActionsListModelTest method removedAtIndexgreaterListSizeDoesNothing.

@Test
public void removedAtIndexgreaterListSizeDoesNothing() {
    CleanupActionsListModel model = new CleanupActionsListModel(getDefaultFieldFormatterCleanups());
    ListDataListener listener = mock(ListDataListener.class);
    model.addListDataListener(listener);
    model.removeAtIndex((getDefaultFieldFormatterCleanups().size() + 1));
    verifyZeroInteractions(listener);
}
Also used : CleanupActionsListModel(org.jabref.gui.cleanup.CleanupActionsListModel) ListDataListener(javax.swing.event.ListDataListener) Test(org.junit.Test)

Example 5 with CleanupActionsListModel

use of org.jabref.gui.cleanup.CleanupActionsListModel in project jabref by JabRef.

the class CleanupActionsListModelTest method resetSetsFormattersToPassedList.

@Test
public void resetSetsFormattersToPassedList() throws Exception {
    CleanupActionsListModel model = new CleanupActionsListModel(Collections.emptyList());
    FieldFormatterCleanups defaultFormatters = mock(FieldFormatterCleanups.class);
    List<FieldFormatterCleanup> formatters = Arrays.asList(new FieldFormatterCleanup("test", new ClearFormatter()));
    when(defaultFormatters.getConfiguredActions()).thenReturn(formatters);
    model.reset(defaultFormatters);
    assertEquals(formatters, model.getAllActions());
}
Also used : CleanupActionsListModel(org.jabref.gui.cleanup.CleanupActionsListModel) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) ClearFormatter(org.jabref.logic.formatter.bibtexfields.ClearFormatter) Test(org.junit.Test)

Aggregations

CleanupActionsListModel (org.jabref.gui.cleanup.CleanupActionsListModel)5 Test (org.junit.Test)5 ListDataListener (javax.swing.event.ListDataListener)4 ListDataEvent (javax.swing.event.ListDataEvent)2 FieldFormatterCleanups (org.jabref.model.cleanup.FieldFormatterCleanups)2 ClearFormatter (org.jabref.logic.formatter.bibtexfields.ClearFormatter)1 FieldFormatterCleanup (org.jabref.model.cleanup.FieldFormatterCleanup)1