Search in sources :

Example 1 with WordKeywordGroup

use of org.jabref.model.groups.WordKeywordGroup in project jabref by JabRef.

the class GroupNodeViewModelTest method draggedOnTopOfGroupAddsBeforeIt.

@Test
public void draggedOnTopOfGroupAddsBeforeIt() throws Exception {
    GroupNodeViewModel rootViewModel = getViewModelForGroup(new WordKeywordGroup("root", GroupHierarchyType.INCLUDING, "keywords", "A", true, ',', true));
    WordKeywordGroup groupA = new WordKeywordGroup("A", GroupHierarchyType.INCLUDING, "keywords", "A", true, ',', true);
    WordKeywordGroup groupB = new WordKeywordGroup("B", GroupHierarchyType.INCLUDING, "keywords", "A > B", true, ',', true);
    WordKeywordGroup groupC = new WordKeywordGroup("C", GroupHierarchyType.INCLUDING, "keywords", "A > B > B1", true, ',', true);
    GroupNodeViewModel groupAViewModel = getViewModelForGroup(rootViewModel.addSubgroup(groupA));
    GroupNodeViewModel groupBViewModel = getViewModelForGroup(rootViewModel.addSubgroup(groupB));
    GroupNodeViewModel groupCViewModel = getViewModelForGroup(rootViewModel.addSubgroup(groupC));
    groupCViewModel.draggedOn(groupBViewModel, DroppingMouseLocation.TOP);
    assertEquals(Arrays.asList(groupAViewModel, groupCViewModel, groupBViewModel), rootViewModel.getChildren());
}
Also used : WordKeywordGroup(org.jabref.model.groups.WordKeywordGroup) Test(org.junit.Test)

Example 2 with WordKeywordGroup

use of org.jabref.model.groups.WordKeywordGroup in project jabref by JabRef.

the class GroupNodeViewModelTest method treeOfAutomaticKeywordGroupIsCombined.

@Test
public void treeOfAutomaticKeywordGroupIsCombined() throws Exception {
    BibEntry entryOne = new BibEntry().withField("keywords", "A > B > B1, A > C");
    BibEntry entryTwo = new BibEntry().withField("keywords", "A > D, E");
    BibEntry entryThree = new BibEntry().withField("keywords", "A > B > B2");
    databaseContext.getDatabase().insertEntries(entryOne, entryTwo, entryThree);
    AutomaticKeywordGroup group = new AutomaticKeywordGroup("Keywords", GroupHierarchyType.INDEPENDENT, "keywords", ',', '>');
    GroupNodeViewModel groupViewModel = getViewModelForGroup(group);
    WordKeywordGroup expectedGroupA = new WordKeywordGroup("A", GroupHierarchyType.INCLUDING, "keywords", "A", true, ',', true);
    WordKeywordGroup expectedGroupB = new WordKeywordGroup("B", GroupHierarchyType.INCLUDING, "keywords", "A > B", true, ',', true);
    WordKeywordGroup expectedGroupB1 = new WordKeywordGroup("B1", GroupHierarchyType.INCLUDING, "keywords", "A > B > B1", true, ',', true);
    WordKeywordGroup expectedGroupB2 = new WordKeywordGroup("B2", GroupHierarchyType.INCLUDING, "keywords", "A > B > B2", true, ',', true);
    WordKeywordGroup expectedGroupC = new WordKeywordGroup("C", GroupHierarchyType.INCLUDING, "keywords", "A > C", true, ',', true);
    WordKeywordGroup expectedGroupD = new WordKeywordGroup("D", GroupHierarchyType.INCLUDING, "keywords", "A > D", true, ',', true);
    WordKeywordGroup expectedGroupE = new WordKeywordGroup("E", GroupHierarchyType.INCLUDING, "keywords", "E", true, ',', true);
    GroupNodeViewModel expectedA = getViewModelForGroup(expectedGroupA);
    GroupTreeNode expectedB = expectedA.addSubgroup(expectedGroupB);
    expectedB.addSubgroup(expectedGroupB1);
    expectedB.addSubgroup(expectedGroupB2);
    expectedA.addSubgroup(expectedGroupC);
    expectedA.addSubgroup(expectedGroupD);
    GroupNodeViewModel expectedE = getViewModelForGroup(expectedGroupE);
    ObservableList<GroupNodeViewModel> expected = FXCollections.observableArrayList(expectedA, expectedE);
    assertEquals(expected, groupViewModel.getChildren());
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) AutomaticKeywordGroup(org.jabref.model.groups.AutomaticKeywordGroup) GroupTreeNode(org.jabref.model.groups.GroupTreeNode) WordKeywordGroup(org.jabref.model.groups.WordKeywordGroup) Test(org.junit.Test)

Example 3 with WordKeywordGroup

use of org.jabref.model.groups.WordKeywordGroup in project jabref by JabRef.

the class GroupNodeViewModelTest method getDisplayNameConvertsLatexToUnicode.

@Test
public void getDisplayNameConvertsLatexToUnicode() throws Exception {
    GroupNodeViewModel viewModel = getViewModelForGroup(new WordKeywordGroup("\\beta", GroupHierarchyType.INDEPENDENT, "test", "search", true, ',', false));
    assertEquals("β", viewModel.getDisplayName());
}
Also used : WordKeywordGroup(org.jabref.model.groups.WordKeywordGroup) Test(org.junit.Test)

Example 4 with WordKeywordGroup

use of org.jabref.model.groups.WordKeywordGroup in project jabref by JabRef.

the class GroupNodeViewModelTest method draggedOnTopOfGroupAddsBeforeItWhenSourceGroupWasBefore.

@Test
public void draggedOnTopOfGroupAddsBeforeItWhenSourceGroupWasBefore() throws Exception {
    GroupNodeViewModel rootViewModel = getViewModelForGroup(new WordKeywordGroup("root", GroupHierarchyType.INCLUDING, "keywords", "A", true, ',', true));
    WordKeywordGroup groupA = new WordKeywordGroup("A", GroupHierarchyType.INCLUDING, "keywords", "A", true, ',', true);
    WordKeywordGroup groupB = new WordKeywordGroup("B", GroupHierarchyType.INCLUDING, "keywords", "A > B", true, ',', true);
    WordKeywordGroup groupC = new WordKeywordGroup("C", GroupHierarchyType.INCLUDING, "keywords", "A > B > B1", true, ',', true);
    GroupNodeViewModel groupAViewModel = getViewModelForGroup(rootViewModel.addSubgroup(groupA));
    GroupNodeViewModel groupBViewModel = getViewModelForGroup(rootViewModel.addSubgroup(groupB));
    GroupNodeViewModel groupCViewModel = getViewModelForGroup(rootViewModel.addSubgroup(groupC));
    groupAViewModel.draggedOn(groupCViewModel, DroppingMouseLocation.TOP);
    assertEquals(Arrays.asList(groupBViewModel, groupAViewModel, groupCViewModel), rootViewModel.getChildren());
}
Also used : WordKeywordGroup(org.jabref.model.groups.WordKeywordGroup) Test(org.junit.Test)

Example 5 with WordKeywordGroup

use of org.jabref.model.groups.WordKeywordGroup in project jabref by JabRef.

the class GroupSerializerTest method serializeSingleSimpleKeywordGroup.

@Test
public void serializeSingleSimpleKeywordGroup() {
    WordKeywordGroup group = new WordKeywordGroup("name", GroupHierarchyType.INDEPENDENT, "keywords", "test", false, ',', false);
    List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
    assertEquals(Collections.singletonList("0 KeywordGroup:name;0;keywords;test;0;0;1;;;;"), serialization);
}
Also used : WordKeywordGroup(org.jabref.model.groups.WordKeywordGroup) GroupTreeNodeTest(org.jabref.model.groups.GroupTreeNodeTest) Test(org.junit.Test)

Aggregations

WordKeywordGroup (org.jabref.model.groups.WordKeywordGroup)10 Test (org.junit.Test)8 AutomaticKeywordGroup (org.jabref.model.groups.AutomaticKeywordGroup)2 GroupTreeNode (org.jabref.model.groups.GroupTreeNode)2 RegexKeywordGroup (org.jabref.model.groups.RegexKeywordGroup)2 StringReader (java.io.StringReader)1 StateManager (org.jabref.gui.StateManager)1 CurrentThreadTaskExecutor (org.jabref.gui.util.CurrentThreadTaskExecutor)1 ParserResult (org.jabref.logic.importer.ParserResult)1 QuotedStringTokenizer (org.jabref.logic.util.strings.QuotedStringTokenizer)1 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)1 BibEntry (org.jabref.model.entry.BibEntry)1 AllEntriesGroup (org.jabref.model.groups.AllEntriesGroup)1 GroupHierarchyType (org.jabref.model.groups.GroupHierarchyType)1 GroupTreeNodeTest (org.jabref.model.groups.GroupTreeNodeTest)1 KeywordGroup (org.jabref.model.groups.KeywordGroup)1 Before (org.junit.Before)1