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());
}
}