PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://sigma-h.googlecode.com/
Java | 57 lines | 29 code | 16 blank | 12 comment | 0 complexity | cecc516a8717c87532314e56ca1b380f 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.shared.domain.User;
11import org.sigmah.server.util.DateUtilCalendarImpl;
12import org.sigmah.shared.date.DateUtil;
13import org.sigmah.shared.report.model.DateRange;
14import org.sigmah.shared.report.model.Report;
15
16import static org.easymock.EasyMock.createNiceMock;
17import static org.easymock.EasyMock.replay;
18
19/**
20 * @author Alex Bertram (akbertram@gmail.com)
21 */
22public class ReportGeneratorTest {
23
24
25    private <T> T createAndReplayMock(Class<T> clazz) {
26        T mock = createNiceMock(clazz);
27        replay(mock);
28        return mock;
29    }
30
31    @Test
32    public void testFileName() {
33
34        // Input user
35        User user = new User();
36        user.setLocale("en");
37
38        // Input test data: report model + parameter
39		Report report = new Report();
40		report.setFileName("Report ${DATE_RANGE} of Activities");
41
42        // Input test data: parameter values
43        DateUtil dateUtil = new DateUtilCalendarImpl();
44        DateRange dateRange = dateUtil.monthRange(2009, 1);
45
46
47		// class under test
48        ReportGenerator generator = new ReportGenerator(null, null, null, null, null);
49
50        generator.generate(user, report, null, dateRange);
51
52        // VERIFY correct file name
53
54		Assert.assertEquals("Report Jan 2009 of Activities", report.getContent().getFileName());
55
56    }
57}