use of org.opennms.features.reporting.dao.jasper.LocalJasperReportsDao in project opennms by OpenNMS.
the class LegacyLocalReportRepositoryTest method setUp.
/**
* <p>setUp</p>
* <p/>
* Initialize and mockup the LegacyLocalReportRepository
*
* @throws Exception
*/
@Before
public void setUp() throws Exception {
// Mocked report list as a result from DAOs
List<BasicReportDefinition> reports = new ArrayList<>();
List<BasicReportDefinition> onlineReports = new ArrayList<>();
reports.add(new LegacyLocalReportDefinition());
reports.add(new LegacyLocalReportDefinition());
onlineReports.add(new LegacyLocalReportDefinition());
// Mock DAOs for the local repository test
LocalReportsDao m_localReportsDao = EasyMock.createMock(LocalReportsDao.class);
LocalJasperReportsDao m_localJasperReportsDao = EasyMock.createMock(LocalJasperReportsDao.class);
// TODO indigo: Mockup an InputStream with EasyMock is not trivial, InputStream isn't an interface
// InputStream jrTemplateStream = EasyMock.createMock(InputStream.class);
// EasyMock.expect(m_localJasperReportsDao.getTemplateStream("sample-report")).andReturn(jrTemplateStream);
// Initialize the local report repository to provide reports from database-reports.xml and jasper-reports.xml
m_legacyLocalReportRepository = new LegacyLocalReportRepository(m_localReportsDao, m_localJasperReportsDao);
m_legacyLocalReportRepository.setLocalReportsDao(m_localReportsDao);
m_legacyLocalReportRepository.setLocalJasperReportsDao(m_localJasperReportsDao);
EasyMock.expect(m_localReportsDao.getOnlineReports()).andReturn(onlineReports);
EasyMock.expect(m_localReportsDao.getDisplayName("sample-report")).andReturn("displayNameMockup");
EasyMock.expect(m_localReportsDao.getReports()).andReturn(reports);
EasyMock.expect(m_localReportsDao.getOnlineReports()).andReturn(onlineReports);
EasyMock.expect(m_localReportsDao.getReportService("sample-report")).andReturn("jasperReportServiceMockup");
EasyMock.expect(m_localJasperReportsDao.getTemplateLocation("sample-report")).andReturn("mocked-jdbc");
EasyMock.expect(m_localJasperReportsDao.getEngine("sample-report")).andReturn("mocked-jdbc");
EasyMock.replay(m_localReportsDao);
EasyMock.replay(m_localJasperReportsDao);
// Sanitycheck
assertNotNull("Test if mocked DAO for database-reports.xml is not null", m_legacyLocalReportRepository.getLocalReportsDao());
assertNotNull("Test if mocked DAo for jasper-reports.xml is not null", m_legacyLocalReportRepository.getLocalJasperReportsDao());
}
Aggregations