PageRenderTime 62ms CodeModel.GetById 45ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 1ms

/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
 6package org.sigmah.server.report.generator;
 7
 8import org.junit.Assert;
 9import org.junit.Test;
10import org.sigmah.server.report.generator.map.Grid;
11import org.sigmah.shared.report.content.Point;
12
13import java.util.List;
14/*
15 * @author Alex Bertram
16 */
17
18public class GridTest {
19
20    @Test
21    public void testRetrieveCell() {
22
23        Grid<Integer, String> grid = new Grid<Integer, String>(25);
24        Assert.assertNull(grid.getCell(1, new Point(0, 0)));
25
26        grid.setCell(1, new Point(0, 0), "foobar");
27
28        Assert.assertEquals("foobar", grid.getCell(1, new Point(0,0)));
29
30    }
31
32    @Test
33    public void testPointToCell() {
34
35
36        Grid<Integer, String> grid = new Grid<Integer, String>(25);
37
38        Assert.assertEquals(new Point(0, 0), grid.pointToGridCoord(new Point(0, 0)));
39        Assert.assertEquals(new Point(0, 1), grid.pointToGridCoord(new Point(5, 26)));
40        Assert.assertEquals(new Point(0, 1), grid.pointToGridCoord(new Point(24, 49)));
41
42    }
43
44    @Test
45    public void testGetAll() {
46
47        Grid<Integer, String> grid = new Grid<Integer, String>(25);
48        grid.setCell(1, new Point(0, 0), "foo");
49        grid.setCell(2, new Point(30, 45), "bar");
50
51        List<String> cells = grid.allCells();
52        Assert.assertEquals("length", 2, cells.size());
53    }
54
55
56}