package twitter4j; import static org.junit.Assert.*; import org.junit.Test; public class TestPaging { @Test public void testConstructor() { Paging paging = new Paging(); assertNotNull(paging); assertEquals(paging.getCount(), -1); assertEquals(paging.getMaxId(), -1); assertEquals(paging.getPage(), -1); assertEquals(paging.getSinceId(), -1); } @Test public void testConstructor2() { int page = 23; Paging paging = new Paging(page); assertNotNull(paging); assertEquals(paging.getCount(), -1); assertEquals(paging.getMaxId(), -1); assertEquals(paging.getPage(), page); assertEquals(paging.getSinceId(), -1); } @Test public void testConstructor3() { long sinceId = 42; Paging paging = new Paging(sinceId); assertNotNull(paging); assertEquals(paging.getCount(), -1); assertEquals(paging.getMaxId(), -1); assertEquals(paging.getPage(), -1); assertEquals(paging.getSinceId(), sinceId); } @Test public void testConstructor4() { int page = 37; long sinceId = 59; Paging paging = new Paging(page, sinceId); assertNotNull(paging); assertEquals(paging.getCount(), -1); assertEquals(paging.getMaxId(), -1); assertEquals(paging.getPage(), page); assertEquals(paging.getSinceId(), sinceId); } @Test public void testConstructor5() { int page = 38; int count = 8736; Paging paging = new Paging(page, count); assertNotNull(paging); assertEquals(paging.getCount(), count); assertEquals(paging.getMaxId(), -1); assertEquals(paging.getPage(), page); assertEquals(paging.getSinceId(), -1); } @Test public void testConstructor6() { int page = 13; int count = 74; long sinceId = 128; Paging paging = new Paging(page, count, sinceId); assertNotNull(paging); assertEquals(paging.getCount(), count); assertEquals(paging.getMaxId(), -1); assertEquals(paging.getPage(), page); assertEquals(paging.getSinceId(), sinceId); } @Test public void testConstructor7() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertNotNull(paging); assertEquals(paging.getCount(), count); assertEquals(paging.getMaxId(), maxId); assertEquals(paging.getPage(), page); assertEquals(paging.getSinceId(), sinceId); } @Test public void testSetter() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getCount(), count); int newCount = 70; paging.setCount(newCount); assertEquals(paging.getCount(), newCount); } @Test public void testSetter2() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getCount(), count); int newCount = 71; paging.count(newCount); assertEquals(paging.getCount(), newCount); } @Test public void testSetter3() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getCount(), count); int newCount = -70; try { paging.setCount(newCount); fail("Must not reach here"); } catch (IllegalArgumentException e) { } assertEquals(paging.getCount(), count); } @Test public void testSetter4() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getMaxId(), maxId); long newMaxId = 202; paging.setMaxId(newMaxId); assertEquals(paging.getMaxId(), newMaxId); } @Test public void testSetter4a() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getMaxId(), maxId); long newMaxId = 202; paging.maxId(newMaxId); assertEquals(paging.getMaxId(), newMaxId); } @Test public void testSetter5() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getMaxId(), maxId); long newMaxId = -202; try { paging.setMaxId(newMaxId); fail("Must not reach here"); } catch (IllegalArgumentException e) { } assertEquals(paging.getMaxId(), maxId); } @Test public void testSetter6() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getPage(), page); int newPage = 70; paging.setPage(newPage); assertEquals(paging.getPage(), newPage); } @Test public void testSetter7() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getPage(), page); int newPage = -70; try { paging.setMaxId(newPage); fail("Must not reach here"); } catch (IllegalArgumentException e) { } assertEquals(paging.getPage(), page); } @Test public void testSetter8() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getSinceId(), sinceId); long newSinceId = 1023; paging.setSinceId(newSinceId); assertEquals(paging.getSinceId(), newSinceId); } @Test public void testSetter8a() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getSinceId(), sinceId); long newSinceId = 1023; paging.sinceId(newSinceId); assertEquals(paging.getSinceId(), newSinceId); } @Test public void testSetter9() { int page = 96; int count = 69; long sinceId = 1010; long maxId = 101; Paging paging = new Paging(page, count, sinceId, maxId); assertEquals(paging.getSinceId(), sinceId); long newSinceId = -1023; try { paging.setSinceId(newSinceId); fail("Must not reach here"); } catch (IllegalArgumentException e) { } assertEquals(paging.getSinceId(), sinceId); } @Test public void testEquals() { int page = 1; int count = 2; long sinceId = 3; long maxId = 4; Paging paging = new Paging(page, count, sinceId, maxId); assertTrue(paging.equals(paging)); } @Test public void testEquals2() { int page = 5; int count = 6; long sinceId = 7; long maxId = 8; Paging paging = new Paging(page, count, sinceId, maxId); assertFalse(paging.equals(null)); } @Test public void testEquals3() { int page = 9; int count = 10; long sinceId = 11; long maxId = 12; Paging paging = new Paging(page, count, sinceId, maxId); assertFalse(paging.equals("Hans")); } @Test public void testEquals5() { int page = 13; int count = 14; long sinceId = 15; long maxId = 16; Paging paging = new Paging(page, count, sinceId, maxId); Paging paging2 = new Paging(page, count, sinceId, maxId); assertTrue(paging.equals(paging2)); } @Test public void testEquals6() { int page = 13; int count = 14; long sinceId = 15; long maxId = 16; Paging paging = new Paging(page, count, sinceId, maxId); page *= 2; Paging paging2 = new Paging(page, count, sinceId, maxId); assertFalse(paging.equals(paging2)); } @Test public void testEquals7() { int page = 13; int count = 14; long sinceId = 15; long maxId = 16; Paging paging = new Paging(page, count, sinceId, maxId); count *= 2; Paging paging2 = new Paging(page, count, sinceId, maxId); assertFalse(paging.equals(paging2)); } @Test public void testEquals8() { int page = 13; int count = 14; long sinceId = 15; long maxId = 16; Paging paging = new Paging(page, count, sinceId, maxId); sinceId *= 2; Paging paging2 = new Paging(page, count, sinceId, maxId); assertFalse(paging.equals(paging2)); } @Test public void testEquals9() { int page = 13; int count = 14; long sinceId = 15; long maxId = 16; Paging paging = new Paging(page, count, sinceId, maxId); maxId *= 2; Paging paging2 = new Paging(page, count, sinceId, maxId); assertFalse(paging.equals(paging2)); } }