*
* @throws Exception exception
*/
@Test(dependsOnMethods = "add")
public void getMostUsedTags() throws Exception {
final TagRepository tagRepository = getTagRepository();
final JSONObject tag = new JSONObject();
tag.put(Tag.TAG_TITLE, "tag title2");
tag.put(Tag.TAG_REFERENCE_COUNT, 3);
tag.put(Tag.TAG_PUBLISHED_REFERENCE_COUNT, 3);
final Transaction transaction = tagRepository.beginTransaction();
tagRepository.add(tag);
transaction.commit();
List<JSONObject> mostUsedTags = tagRepository.getMostUsedTags(3);
Assert.assertNotNull(mostUsedTags);
Assert.assertEquals(mostUsedTags.size(), 2);
mostUsedTags = tagRepository.getMostUsedTags(1);
Assert.assertNotNull(mostUsedTags);
Assert.assertEquals(mostUsedTags.size(), 1);
Assert.assertEquals(mostUsedTags.get(0).getInt(
Tag.TAG_PUBLISHED_REFERENCE_COUNT), 3);
}