/sigmah/src/test/java/org/sigmah/server/report/generator/GridTest.java

http://sigma-h.googlecode.com/ · Java · 56 lines · 30 code · 19 blank · 7 comment · 0 complexity · 2dd51a69ca76d3ac15e774a41edec296 MD5 · raw file

  1. /*
  2. * All Sigmah code is released under the GNU General Public License v3
  3. * See COPYRIGHT.txt and LICENSE.txt.
  4. */
  5. package org.sigmah.server.report.generator;
  6. import org.junit.Assert;
  7. import org.junit.Test;
  8. import org.sigmah.server.report.generator.map.Grid;
  9. import org.sigmah.shared.report.content.Point;
  10. import java.util.List;
  11. /*
  12. * @author Alex Bertram
  13. */
  14. public class GridTest {
  15. @Test
  16. public void testRetrieveCell() {
  17. Grid<Integer, String> grid = new Grid<Integer, String>(25);
  18. Assert.assertNull(grid.getCell(1, new Point(0, 0)));
  19. grid.setCell(1, new Point(0, 0), "foobar");
  20. Assert.assertEquals("foobar", grid.getCell(1, new Point(0,0)));
  21. }
  22. @Test
  23. public void testPointToCell() {
  24. Grid<Integer, String> grid = new Grid<Integer, String>(25);
  25. Assert.assertEquals(new Point(0, 0), grid.pointToGridCoord(new Point(0, 0)));
  26. Assert.assertEquals(new Point(0, 1), grid.pointToGridCoord(new Point(5, 26)));
  27. Assert.assertEquals(new Point(0, 1), grid.pointToGridCoord(new Point(24, 49)));
  28. }
  29. @Test
  30. public void testGetAll() {
  31. Grid<Integer, String> grid = new Grid<Integer, String>(25);
  32. grid.setCell(1, new Point(0, 0), "foo");
  33. grid.setCell(2, new Point(30, 45), "bar");
  34. List<String> cells = grid.allCells();
  35. Assert.assertEquals("length", 2, cells.size());
  36. }
  37. }