Package ru.dreamteam.couch.changes

Source Code of ru.dreamteam.couch.changes.TestChanges

package ru.dreamteam.couch.changes;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.Test;

import ru.dreamteam.couch.BaseTest;
import ru.dreamteam.couch.CouchEntity;
import ru.dreamteam.couch.Db;

/**
* Tests for _changes API
* @author dooman
*
*/
public class TestChanges extends BaseTest {
    private Db db;
    private ChangesQuery query;

    @Override
    public void setUp() throws Exception {
        super.setUp();
        this.db = couch.getDb(testDbName);
        this.query = db.changes();
    }

    @Test
    public void testGetChanges() throws Exception {
        List<Change> changes = query.list();
        assertNotNull(changes);
    }

    @Test
    public void testDocChanges() throws Exception {
        CouchEntity entity = new CouchEntity();
        db.save(entity);

        List<Change> changes = query.limit(1).descending(true).list();
        assertEquals(1, changes.size());
        assertEquals(entity.getId(), changes.get(0).getId());
        assertEquals(entity.getRevision(), changes.get(0).getRev());
    }
}
TOP

Related Classes of ru.dreamteam.couch.changes.TestChanges

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.