Search in sources :

Example 6 with ExplicitGroup

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

the class ConvertLegacyExplicitGroupsTest method setUp.

@Before
public void setUp() throws Exception {
    action = new ConvertLegacyExplicitGroups();
    entry = new BibEntry();
    entry.setCiteKey("Entry1");
    group = new ExplicitGroup("TestGroup", GroupHierarchyType.INCLUDING, ',');
    group.addLegacyEntryKey("Entry1");
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) ExplicitGroup(org.jabref.model.groups.ExplicitGroup) Before(org.junit.Before)

Example 7 with ExplicitGroup

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

the class ConvertLegacyExplicitGroupsTest method performActionWritesGroupMembershipInEntryForComplexGroupTree.

@Test
public void performActionWritesGroupMembershipInEntryForComplexGroupTree() throws Exception {
    GroupTreeNode root = GroupTreeNode.fromGroup(new AllEntriesGroup(""));
    root.addSubgroup(new ExplicitGroup("TestGroup2", GroupHierarchyType.INCLUDING, ','));
    root.addSubgroup(group);
    ParserResult parserResult = generateParserResult(root);
    action.performAction(parserResult);
    assertEquals(Optional.of("TestGroup"), entry.getField("groups"));
}
Also used : AllEntriesGroup(org.jabref.model.groups.AllEntriesGroup) ParserResult(org.jabref.logic.importer.ParserResult) GroupTreeNode(org.jabref.model.groups.GroupTreeNode) ExplicitGroup(org.jabref.model.groups.ExplicitGroup) Test(org.junit.Test)

Example 8 with ExplicitGroup

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

the class GroupsParserTest method testImportSubGroups.

@Test
public void testImportSubGroups() throws ParseException {
    List<String> orderedData = Arrays.asList("0 AllEntriesGroup:", "1 ExplicitGroup:1;0;", "2 ExplicitGroup:2;0;", "0 ExplicitGroup:3;0;");
    //Create group hierarchy:
    //  Level 0 Name: All entries
    //  Level 1 Name: 1
    //  Level 2 Name: 2
    //  Level 1 Name: 3
    GroupTreeNode rootNode = new GroupTreeNode(new ExplicitGroup("All entries", GroupHierarchyType.INDEPENDENT, ','));
    AbstractGroup firstSubGrpLvl1 = new ExplicitGroup("1", GroupHierarchyType.INDEPENDENT, ',');
    rootNode.addSubgroup(firstSubGrpLvl1);
    AbstractGroup subLvl2 = new ExplicitGroup("2", GroupHierarchyType.INDEPENDENT, ',');
    rootNode.getFirstChild().ifPresent(c -> c.addSubgroup(subLvl2));
    AbstractGroup thirdSubGrpLvl1 = new ExplicitGroup("3", GroupHierarchyType.INDEPENDENT, ',');
    rootNode.addSubgroup(thirdSubGrpLvl1);
    GroupTreeNode parsedNode = GroupsParser.importGroups(orderedData, ',');
    assertEquals(rootNode.getChildren(), parsedNode.getChildren());
}
Also used : AbstractGroup(org.jabref.model.groups.AbstractGroup) GroupTreeNode(org.jabref.model.groups.GroupTreeNode) ExplicitGroup(org.jabref.model.groups.ExplicitGroup) Test(org.junit.Test)

Example 9 with ExplicitGroup

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

the class GroupsParserTest method fromStringParsesExplicitGroupWithIconAndDesrcitpion.

@Test
public void fromStringParsesExplicitGroupWithIconAndDesrcitpion() throws Exception {
    ExplicitGroup expected = new ExplicitGroup("myExplicitGroup", GroupHierarchyType.INDEPENDENT, ',');
    expected.setIconCode("test icon");
    expected.setExpanded(true);
    expected.setColor(Color.ALICEBLUE);
    expected.setDescription("test description");
    AbstractGroup parsed = GroupsParser.fromString("StaticGroup:myExplicitGroup;0;1;0xf0f8ffff;test icon;test description;", ',');
    assertEquals(expected, parsed);
}
Also used : AbstractGroup(org.jabref.model.groups.AbstractGroup) ExplicitGroup(org.jabref.model.groups.ExplicitGroup) Test(org.junit.Test)

Example 10 with ExplicitGroup

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

the class GroupsParserTest method fromStringParsesExplicitGroupWithEscapedCharacterInName.

@Test
public // For https://github.com/JabRef/jabref/issues/1681
void fromStringParsesExplicitGroupWithEscapedCharacterInName() throws Exception {
    ExplicitGroup expected = new ExplicitGroup("B{\\\"{o}}hmer", GroupHierarchyType.INDEPENDENT, ',');
    AbstractGroup parsed = GroupsParser.fromString("ExplicitGroup:B{\\\\\"{o}}hmer;0;", ',');
    assertEquals(expected, parsed);
}
Also used : AbstractGroup(org.jabref.model.groups.AbstractGroup) ExplicitGroup(org.jabref.model.groups.ExplicitGroup) Test(org.junit.Test)

Aggregations

ExplicitGroup (org.jabref.model.groups.ExplicitGroup)15 Test (org.junit.Test)9 AbstractGroup (org.jabref.model.groups.AbstractGroup)4 AllEntriesGroup (org.jabref.model.groups.AllEntriesGroup)4 GroupTreeNode (org.jabref.model.groups.GroupTreeNode)4 GroupTreeNodeTest (org.jabref.model.groups.GroupTreeNodeTest)3 ArrayList (java.util.ArrayList)2 ParseException (org.jabref.logic.importer.ParseException)2 QuotedStringTokenizer (org.jabref.logic.util.strings.QuotedStringTokenizer)2 BibEntry (org.jabref.model.entry.BibEntry)2 NamedCompound (org.jabref.gui.undo.NamedCompound)1 UndoableInsertEntry (org.jabref.gui.undo.UndoableInsertEntry)1 UndoableInsertString (org.jabref.gui.undo.UndoableInsertString)1 ParserResult (org.jabref.logic.importer.ParserResult)1 BibDatabase (org.jabref.model.database.BibDatabase)1 BibtexString (org.jabref.model.entry.BibtexString)1 KeywordGroup (org.jabref.model.groups.KeywordGroup)1 SearchGroup (org.jabref.model.groups.SearchGroup)1 ContentSelector (org.jabref.model.metadata.ContentSelector)1 MetaData (org.jabref.model.metadata.MetaData)1