michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: package org.mozilla.gecko.background.sync.helpers; michael@0: michael@0: import org.json.simple.JSONArray; michael@0: import org.mozilla.gecko.sync.Utils; michael@0: import org.mozilla.gecko.sync.repositories.domain.BookmarkRecord; michael@0: michael@0: public class BookmarkHelpers { michael@0: michael@0: private static String mobileFolderGuid = "mobile"; michael@0: private static String mobileFolderName = "mobile"; michael@0: private static String topFolderGuid = Utils.generateGuid(); michael@0: private static String topFolderName = "My Top Folder"; michael@0: private static String middleFolderGuid = Utils.generateGuid(); michael@0: private static String middleFolderName = "My Middle Folder"; michael@0: private static String bottomFolderGuid = Utils.generateGuid(); michael@0: private static String bottomFolderName = "My Bottom Folder"; michael@0: private static String bmk1Guid = Utils.generateGuid(); michael@0: private static String bmk2Guid = Utils.generateGuid(); michael@0: private static String bmk3Guid = Utils.generateGuid(); michael@0: private static String bmk4Guid = Utils.generateGuid(); michael@0: michael@0: /* michael@0: * Helpers for creating bookmark records of different types michael@0: */ michael@0: public static BookmarkRecord createBookmarkInMobileFolder1() { michael@0: BookmarkRecord rec = createBookmark1(); michael@0: rec.guid = Utils.generateGuid(); michael@0: rec.parentID = mobileFolderGuid; michael@0: rec.parentName = mobileFolderName; michael@0: return rec; michael@0: } michael@0: michael@0: public static BookmarkRecord createBookmarkInMobileFolder2() { michael@0: BookmarkRecord rec = createBookmark2(); michael@0: rec.guid = Utils.generateGuid(); michael@0: rec.parentID = mobileFolderGuid; michael@0: rec.parentName = mobileFolderName; michael@0: return rec; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createBookmark1() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: JSONArray tags = new JSONArray(); michael@0: tags.add("tag1"); michael@0: tags.add("tag2"); michael@0: tags.add("tag3"); michael@0: record.guid = bmk1Guid; michael@0: record.title = "Foo!!!"; michael@0: record.bookmarkURI = "http://foo.bar.com"; michael@0: record.description = "This is a description for foo.bar.com"; michael@0: record.tags = tags; michael@0: record.keyword = "fooooozzzzz"; michael@0: record.parentID = topFolderGuid; michael@0: record.parentName = topFolderName; michael@0: record.type = "bookmark"; michael@0: return record; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createBookmark2() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: JSONArray tags = new JSONArray(); michael@0: tags.add("tag1"); michael@0: tags.add("tag2"); michael@0: record.guid = bmk2Guid; michael@0: record.title = "Bar???"; michael@0: record.bookmarkURI = "http://bar.foo.com"; michael@0: record.description = "This is a description for Bar???"; michael@0: record.tags = tags; michael@0: record.keyword = "keywordzzz"; michael@0: record.parentID = topFolderGuid; michael@0: record.parentName = topFolderName; michael@0: record.type = "bookmark"; michael@0: return record; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createBookmark3() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: JSONArray tags = new JSONArray(); michael@0: tags.add("tag1"); michael@0: tags.add("tag2"); michael@0: record.guid = bmk3Guid; michael@0: record.title = "Bmk3"; michael@0: record.bookmarkURI = "http://bmk3.com"; michael@0: record.description = "This is a description for bmk3"; michael@0: record.tags = tags; michael@0: record.keyword = "snooozzz"; michael@0: record.parentID = middleFolderGuid; michael@0: record.parentName = middleFolderName; michael@0: record.type = "bookmark"; michael@0: return record; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createBookmark4() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: JSONArray tags = new JSONArray(); michael@0: tags.add("tag1"); michael@0: tags.add("tag2"); michael@0: record.guid = bmk4Guid; michael@0: record.title = "Bmk4"; michael@0: record.bookmarkURI = "http://bmk4.com"; michael@0: record.description = "This is a description for bmk4?"; michael@0: record.tags = tags; michael@0: record.keyword = "booooozzz"; michael@0: record.parentID = bottomFolderGuid; michael@0: record.parentName = bottomFolderName; michael@0: record.type = "bookmark"; michael@0: return record; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createMicrosummary() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: JSONArray tags = new JSONArray(); michael@0: tags.add("tag1"); michael@0: tags.add("tag2"); michael@0: record.guid = Utils.generateGuid(); michael@0: record.title = "Microsummary 1"; michael@0: record.bookmarkURI = "www.bmkuri.com"; michael@0: record.description = "microsummary description"; michael@0: record.tags = tags; michael@0: record.keyword = "keywordzzz"; michael@0: record.parentID = topFolderGuid; michael@0: record.parentName = topFolderName; michael@0: record.type = "microsummary"; michael@0: return record; michael@0: } michael@0: michael@0: public static BookmarkRecord createQuery() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: record.guid = Utils.generateGuid(); michael@0: record.title = "Query 1"; michael@0: record.bookmarkURI = "http://www.query.com"; michael@0: record.description = "Query 1 description"; michael@0: record.tags = new JSONArray(); michael@0: record.keyword = "queryKeyword"; michael@0: record.parentID = topFolderGuid; michael@0: record.parentName = topFolderName; michael@0: record.type = "query"; michael@0: return record; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createFolder1() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: record.guid = topFolderGuid; michael@0: record.title = topFolderName; michael@0: record.parentID = "mobile"; michael@0: record.parentName = "mobile"; michael@0: JSONArray children = new JSONArray(); michael@0: children.add(bmk1Guid); michael@0: children.add(bmk2Guid); michael@0: record.children = children; michael@0: record.type = "folder"; michael@0: return record; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createFolder2() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: record.guid = middleFolderGuid; michael@0: record.title = middleFolderName; michael@0: record.parentID = topFolderGuid; michael@0: record.parentName = topFolderName; michael@0: JSONArray children = new JSONArray(); michael@0: children.add(bmk3Guid); michael@0: record.children = children; michael@0: record.type = "folder"; michael@0: return record; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createFolder3() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: record.guid = bottomFolderGuid; michael@0: record.title = bottomFolderName; michael@0: record.parentID = middleFolderGuid; michael@0: record.parentName = middleFolderName; michael@0: JSONArray children = new JSONArray(); michael@0: children.add(bmk4Guid); michael@0: record.children = children; michael@0: record.type = "folder"; michael@0: return record; michael@0: } michael@0: michael@0: @SuppressWarnings("unchecked") michael@0: public static BookmarkRecord createLivemark() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: record.guid = Utils.generateGuid(); michael@0: record.title = "Livemark title"; michael@0: record.parentID = topFolderGuid; michael@0: record.parentName = topFolderName; michael@0: JSONArray children = new JSONArray(); michael@0: children.add(Utils.generateGuid()); michael@0: children.add(Utils.generateGuid()); michael@0: record.children = children; michael@0: record.type = "livemark"; michael@0: return record; michael@0: } michael@0: michael@0: public static BookmarkRecord createSeparator() { michael@0: BookmarkRecord record = new BookmarkRecord(); michael@0: record.guid = Utils.generateGuid(); michael@0: record.androidPosition = 3; michael@0: record.parentID = topFolderGuid; michael@0: record.parentName = topFolderName; michael@0: record.type = "separator"; michael@0: return record; michael@0: } michael@0: }