Package com.javaeye.jert.domain

Examples of com.javaeye.jert.domain.ReportDefinition


*/
public class ReportInstanceTest extends DatabaseTestCase {
    private static final String CREATE_TABLE = "DROP TABLE USER IF EXISTS; CREATE TABLE USER (USER_NAME varchar(255), EMAIL varchar(255));";
   
    public void testGenerateStaticQueryReport() {
        ReportDefinition rd = getReportDefinition();

        ReportInstance instance = new ReportInstance(2);
        instance.setReportDefinition(rd);
        instance.generateItems(null);
        ResultSetOutput output = instance.getResultSetOutput();
View Full Code Here


       

    }

    public void testGenerateReportStartIndex() {
        ReportDefinition rd = getReportDefinition();
       
        ReportInstance instance = new ReportInstance(2);
        instance.setReportDefinition(rd);
        instance.setStartIndex(2);
        instance.generateItems(null);
View Full Code Here

   
   
    private ReportDefinition getReportDefinition() {
        Database db = getDatabase();

        ReportDefinition rd = new ReportDefinition();
        rd.setDatabase(db);
        rd.setSql("select * from user order by user_name");
        rd.setQueryType(QueryBuilder.QUERY_TYPE_STATIC);
        return rd;
    }   
View Full Code Here

        return rd;
    }   
   
    public void testGenerateSimpleParameterQueryReport() {
        Database db = getDatabase();
        ReportDefinition rd = new ReportDefinition();
        rd.setDatabase(db);
        rd.setSql("select * from user where user_name = #name#");
        rd.setQueryType(QueryBuilder.QUERY_TYPE_SIMPLE_PARAMETER);
        rd.setupDefaultParameterDefinition();
       
        ReportInstance instance = new ReportInstance();
        instance.setReportDefinition(rd);
        QueryParameter[] parameters = rd.getDefaultQueryParameters();
        parameters[0].setValue("user1");
       
        instance.generateItems(parameters);
        assertEquals(1, instance.getTotalCount());
       
View Full Code Here

        assertEquals("user1@javaeye.com", user1[1]);       
    }
   
    public void testGenerateDynamicParameterQueryReport() {
        Database db = getDatabase();
        ReportDefinition rd = new ReportDefinition();
        rd.setDatabase(db);
        rd.setSql("<plain>select * from user where 1 = 1</plain>"
                + "<dynamic type=\"isNotEmpty\" append-before=\"and user_name = \" parameter-name=\"name\"/>"
                + "<dynamic type=\"isNotEmpty\" append-before=\"and email = \" parameter-name=\"email\"/>");
        rd.setQueryType(QueryBuilder.QUERY_TYPE_DYNAMIC_PARAMETER);
        rd.setupDefaultParameterDefinition();

        ReportInstance instance = new ReportInstance();
        instance.setReportDefinition(rd);
        QueryParameter[] parameters = rd.getDefaultQueryParameters();
        instance.generateItems(parameters);
        assertEquals(5, instance.getTotalCount());

        parameters = rd.getDefaultQueryParameters();
        parameters[0].setValue("user1");
        instance.generateItems(parameters);
        assertEquals(1, instance.getTotalCount());
       
        parameters = rd.getDefaultQueryParameters();
        parameters[0].setValue("user1");
        parameters[1].setValue("user2@javaeye.com");
        instance.generateItems(parameters);
        assertEquals(0, instance.getTotalCount());       
    }
View Full Code Here

   
    public void testAddRemove() {
        Group group = userManager.newGroup();
        group.setName("test group");
       
        ReportDefinition reportDefinition = getReportDefintion();
       
        ReportPermissionGroup rpg = service.addReportPermissionToGroup(reportDefinition, group);
        assertEquals(group.getName(), rpg.getGroupName());
        assertEquals(reportDefinition, rpg.getReportDefinition());
       
View Full Code Here

   
    private ReportDefinition getReportDefintion() {
        Database db = new Database();
        ((DatabaseService) context.getBean("databaseService")).createDatabase(db);

        ReportDefinition rd = new ReportDefinition();
        rd.setDatabase(db);
        rd.setName("test");
        rd.setSql("select * from user");
        rd.setQueryType(QueryBuilder.QUERY_TYPE_STATIC);

        ((ReportDefinitionService) context.getBean("reportDefinitionService")).createReportDefinition(rd);
        return rd;
    }
View Full Code Here

    }
   
    public void testCRUDDrillDownColumn() throws Exception{
        Database db = new Database();
        ((DatabaseService) context.getBean("databaseService")).createDatabase(db);
        ReportDefinition rd = new ReportDefinition();
        rd.setDatabase(db);
        rd.setName("test report one");
        rd.setSql("select * from user");
        rd.setQueryType(QueryBuilder.QUERY_TYPE_STATIC);
        ReportDefinitionService rs=(ReportDefinitionService)context.getBean("reportDefinitionService");
        rs.createReportDefinition(rd);
        ReportDefinition rd2 = new ReportDefinition();
        rd2.setDatabase(db);
        rd2.setName("test report two");
        rd2.setSql("select * from user");
        rd2.setQueryType(QueryBuilder.QUERY_TYPE_STATIC);
        rs.createReportDefinition(rd2);
        DrillDownColumn ddc=new DrillDownColumn();
        ddc.setName("name");
        ddc.setParametersIndex(2);
        rd.addDrillDownColumn(ddc);
        rd2.addAssociatedDrillDownColumn(ddc);
        ddcService.createDrillDownColumn(ddc);
        assertEquals(rd.getDrillDownColumns().size(),1);
        //getting the stored entity from session is redundant ?
        DrillDownColumn stored=ddcService.getDrillDownColumn(ddc.getId());
        assertEquals(ddc.getId(),stored.getId());
        assertEquals(stored.getName(),"name");
        assertEquals(stored.getParametersIndex(),2);
        assertEquals(stored.getReportDefinition().getId(),rd.getId());
        assertEquals(stored.getToReportDefinition().getId(),rd2.getId());
        stored.setName("changed name");
        ddcService.updateDrillDownColumn(stored);
        assertEquals(stored.getName(),"changed name");
        //test for cascade delete all associated DrillDownColumns
        this.closeSession();
        this.openSession();
        rs=(ReportDefinitionService)context.getBean("reportDefinitionService");
        rd2=rs.getReportDefinition(rd2.getId());
        rs.deleteReportDefinition(rd2);
        assertNull(ddcService.getDrillDownColumn(ddc.getId()));
        rd=rs.getReportDefinition(rd.getId());
        assertEquals(rd.getDrillDownColumns().size(),0);
       
View Full Code Here

    public void testCRUD() {
        Database db = new Database();
        ((DatabaseService) context.getBean("databaseService")).createDatabase(db);

        ReportDefinition rd = new ReportDefinition();
        rd.setDatabase(db);
        rd.setName("test report one");
        rd.setSql("select * from user");
        rd.setQueryType(QueryBuilder.QUERY_TYPE_STATIC);

        service.createReportDefinition(rd);
        ReportDefinition stored = service.getReportDefinition(rd.getId());
        assertEquals("test report one", stored.getName());
        assertEquals("select * from user", stored.getSql());

        stored.setName("test report one new");
        service.updateReportDefinition(stored);

        stored = service.getReportDefinition(rd.getId());
        assertEquals("test report one new", stored.getName());

        service.deleteReportDefinition(stored);
        assertNull(service.getReportDefinition(rd.getId()));
    }
View Full Code Here

    public void testDefaultParameterDefinition() {
        Database db = new Database();
        ((DatabaseService) context.getBean("databaseService")).createDatabase(db);

        ReportDefinition rd = new ReportDefinition();
        rd.setDatabase(db);
        rd.setName("test report one");
        rd.setSql("select * from user where name = #name#");
        rd.setQueryType(QueryBuilder.QUERY_TYPE_SIMPLE_PARAMETER);
        service.createReportDefinition(rd);

        ReportDefinition stored = service.getReportDefinition(rd.getId());
        assertEquals(1, stored.getParameterDefinitions().size());
        assertEquals("name", ((ParameterDefinition) stored.getParameterDefinitions().get(0)).getName());
       
        rd.setSql("select * from user where age > #age#");
        service.updateReportDefinition(stored);
        assertEquals(1, stored.getParameterDefinitions().size());
        assertEquals("age", ((ParameterDefinition) stored.getParameterDefinitions().get(0)).getName());
    }
View Full Code Here

TOP

Related Classes of com.javaeye.jert.domain.ReportDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.