use of org.jabref.model.groups.GroupTreeNode in project jabref by JabRef.
the class BibtexDatabaseWriterTest method writeGroups.
@Test
public void writeGroups() throws Exception {
GroupTreeNode groupRoot = GroupTreeNode.fromGroup(new AllEntriesGroup(""));
groupRoot.addSubgroup(new ExplicitGroup("test", GroupHierarchyType.INCLUDING, ','));
metaData.setGroups(groupRoot);
StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), new SavePreferences());
// @formatter:off
assertEquals(OS.NEWLINE + "@Comment{jabref-meta: grouping:" + OS.NEWLINE + "0 AllEntriesGroup:;" + OS.NEWLINE + "1 StaticGroup:test\\;2\\;1\\;\\;\\;\\;;" + OS.NEWLINE + "}" + OS.NEWLINE, session.getStringValue());
// @formatter:on
}
use of org.jabref.model.groups.GroupTreeNode in project jabref by JabRef.
the class GroupSerializerTest method getTreeAsStringInComplexTree.
@Test
public void getTreeAsStringInComplexTree() throws Exception {
GroupTreeNode root = GroupTreeNodeTest.getRoot();
GroupTreeNodeTest.getNodeInComplexTree(root);
List<String> expected = Arrays.asList("0 AllEntriesGroup:", "1 SearchGroup:SearchA;2;searchExpression;1;0;1;;;;", "1 StaticGroup:ExplicitA;2;1;;;;", "1 StaticGroup:ExplicitGrandParent;0;1;;;;", "2 StaticGroup:ExplicitB;1;1;;;;", "2 KeywordGroup:KeywordParent;0;searchField;searchExpression;1;0;1;;;;", "3 KeywordGroup:KeywordNode;0;searchField;searchExpression;1;0;1;;;;", "4 StaticGroup:ExplicitChild;1;1;;;;", "3 SearchGroup:SearchC;2;searchExpression;1;0;1;;;;", "3 StaticGroup:ExplicitC;1;1;;;;", "3 KeywordGroup:KeywordC;0;searchField;searchExpression;1;0;1;;;;", "2 SearchGroup:SearchB;2;searchExpression;1;0;1;;;;", "2 KeywordGroup:KeywordB;0;searchField;searchExpression;1;0;1;;;;", "1 KeywordGroup:KeywordA;0;searchField;searchExpression;1;0;1;;;;");
assertEquals(expected, groupSerializer.serializeTree(root));
}
use of org.jabref.model.groups.GroupTreeNode in project jabref by JabRef.
the class BibtexParserTest method integrationTestGroupTree.
@Test
public void integrationTestGroupTree() throws IOException, ParseException {
ParserResult result = BibtexParser.parse(new StringReader("@comment{jabref-meta: groupsversion:3;}" + OS.NEWLINE + "@comment{jabref-meta: groupstree:" + OS.NEWLINE + "0 AllEntriesGroup:;" + OS.NEWLINE + "1 KeywordGroup:Fréchet\\;0\\;keywords\\;FrechetSpace\\;0\\;1\\;;" + OS.NEWLINE + "1 KeywordGroup:Invariant theory\\;0\\;keywords\\;GIT\\;0\\;0\\;;" + OS.NEWLINE + "1 ExplicitGroup:TestGroup\\;0\\;Key1\\;Key2\\;;" + "}"), importFormatPreferences);
GroupTreeNode root = result.getMetaData().getGroups().get();
assertEquals(new AllEntriesGroup("All entries"), root.getGroup());
assertEquals(3, root.getNumberOfChildren());
assertEquals(new RegexKeywordGroup("Fréchet", GroupHierarchyType.INDEPENDENT, "keywords", "FrechetSpace", false), root.getChildren().get(0).getGroup());
assertEquals(new WordKeywordGroup("Invariant theory", GroupHierarchyType.INDEPENDENT, "keywords", "GIT", false, ',', false), root.getChildren().get(1).getGroup());
assertEquals(Arrays.asList("Key1", "Key2"), ((ExplicitGroup) root.getChildren().get(2).getGroup()).getLegacyEntryKeys());
}
use of org.jabref.model.groups.GroupTreeNode 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"));
}
use of org.jabref.model.groups.GroupTreeNode 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());
}
Aggregations