Search in sources :

Example 1 with ArchiveDateRepository

use of org.b3log.solo.repository.ArchiveDateRepository in project solo by b3log.

the class ArchiveDateRepositoryImplTestCase method add.

/**
     * Adds successfully.
     *
     * @throws Exception exception
     */
@Test
public void add() throws Exception {
    final ArchiveDateRepository archiveDateRepository = getArchiveDateRepository();
    final JSONObject archiveDate = new JSONObject();
    archiveDate.put(ArchiveDate.ARCHIVE_TIME, DateUtils.parseDate("2011/12", new String[] { "yyyy/MM" }).getTime());
    archiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, 1);
    archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, 1);
    final Transaction transaction = archiveDateRepository.beginTransaction();
    archiveDateRepository.add(archiveDate);
    transaction.commit();
    final List<JSONObject> archiveDates = archiveDateRepository.getArchiveDates();
    Assert.assertNotNull(archiveDates);
    Assert.assertEquals(1, archiveDates.size());
}
Also used : ArchiveDateRepository(org.b3log.solo.repository.ArchiveDateRepository) JSONObject(org.json.JSONObject) Transaction(org.b3log.latke.repository.Transaction) Test(org.testng.annotations.Test)

Example 2 with ArchiveDateRepository

use of org.b3log.solo.repository.ArchiveDateRepository in project solo by b3log.

the class ArchiveDateRepositoryImplTestCase method getByArchiveDate.

/**
     * Get By ArchiveDate.
     *
     * @throws Exception exception
     */
@Test(dependsOnMethods = "add")
public void getByArchiveDate() throws Exception {
    final ArchiveDateRepository archiveDateRepository = getArchiveDateRepository();
    final JSONObject archiveDate = archiveDateRepository.getByArchiveDate("2011/12");
    Assert.assertNotNull(archiveDate);
    System.out.println(archiveDate.toString(SoloServletListener.JSON_PRINT_INDENT_FACTOR));
}
Also used : ArchiveDateRepository(org.b3log.solo.repository.ArchiveDateRepository) JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Aggregations

ArchiveDateRepository (org.b3log.solo.repository.ArchiveDateRepository)2 JSONObject (org.json.JSONObject)2 Test (org.testng.annotations.Test)2 Transaction (org.b3log.latke.repository.Transaction)1