Package co.nubetech.crux.model

Examples of co.nubetech.crux.model.Report


    welcomeAction.setMappingDAO(mockedMappingDAO);
    when(mockedMappingDAO.findAll()).thenReturn(mappingList);
   
    //No dashboard with reports.
   
    Report report1 = new Report();
    Report report2 = new Report();
    Report report3 = new Report();
   
    List<Report> reportList = new ArrayList<Report>();
    reportList.add(report1);
    reportList.add(report2);
    reportList.add(report3);
View Full Code Here


    ReportType reportType2= new ReportType(122, "ReportType2");
    ReportType reportType3 = new ReportType(123, "ReportType3");
   
    Dashboard dashboard = new Dashboard(1, 2);
   
    Report report1 = new Report(user,"Report1", reportType1, dashboard);
    Report report2 = new Report(user,"Report2", reportType2, dashboard);
    Report report3 = new Report(user,"Report3", reportType3, dashboard);
   
    List<Report> reportList = new ArrayList<Report>();
    reportList.add(report1);
    reportList.add(report2);
    reportList.add(report3);
   
    ReportDAO mockedReportDAO = mock(ReportDAO.class);
    DeleteReportAction deleteReportAction = new DeleteReportAction();
    deleteReportAction.setReportDAO(mockedReportDAO);
    when(mockedReportDAO.findAll()).thenReturn(reportList);
   
    String successString = deleteReportAction.deleteReport();
   
    assertEquals(successString, "success");
   
    assertEquals(deleteReportAction.getReportList().get(0).getName(), report1.getName());
    assertEquals(deleteReportAction.getReportList().get(1).getName(), report2.getName());
    assertEquals(deleteReportAction.getReportList().get(2).getName(), report3.getName());
   
    assertEquals(deleteReportAction.getReportList().get(0).getReportType(), report1.getReportType().getType());
    assertEquals(deleteReportAction.getReportList().get(1).getReportType(), report2.getReportType().getType());
    assertEquals(deleteReportAction.getReportList().get(2).getReportType(), report3.getReportType().getType());
   
    // Report view index starts with integer 1.
    assertEquals(deleteReportAction.getReportList().get(0).getIndex(), 1);
  }
View Full Code Here

  }
 
  @Test
  public void testDeleteReportWithEmptyReports(){
    ReportType reportType = new ReportType(121, "ReportType");
    Report report = new Report();
   
    // Setting report type is must, otherwise NUllPointerException.
    report.setReportType(reportType);
   
    List<Report> reportList = new ArrayList<Report>();
    reportList.add(report);
   
    ReportDAO mockedReportDAO = mock(ReportDAO.class);
    DeleteReportAction deleteReportAction = new DeleteReportAction();
    deleteReportAction.setReportDAO(mockedReportDAO);
    when(mockedReportDAO.findAll()).thenReturn(reportList);
   
    String successString = deleteReportAction.deleteReport();
   
    assertEquals(successString, "success");
   
    assertEquals(deleteReportAction.getReportList().get(0).getName(), null);
    assertEquals(deleteReportAction.getReportList().get(0).getName(), report.getName());
    assertEquals(deleteReportAction.getReportList().get(0).getReportType(), report.getReportType().getType());
  }
View Full Code Here

public class TestReportView {

  @Test
  public void testReportView(){
   
    Report report = new Report();
    report.setId(12);
   
    ReportType reportType = new ReportType(1,"String");
   
    report.setName("report1");
    report.setReportType(reportType);
   
    ReportView reportView = new ReportView(1,report);
   
    assertEquals(reportView.getName(),"report1");
    assertEquals(reportView.getReportType(),report.getReportType().getType());
    assertEquals(reportView.getIndex(),1);
    assertEquals(reportView.getId(),report.getId());
    assertEquals(reportView.getName(),report.getName());
   
  }
View Full Code Here

 
  @Test
  public void testNextNonAggregate() throws CruxException{
    //ceil is applied
    Result result = mock(Result.class);
    Report report = TestingUtil.getReportWithoutAggregateFunctions();
    double dbl = 1234567.8d;
    when(result.getRow()).thenReturn(Bytes.toBytes(dbl));
    CruxResultImpl impl = new CruxResultImpl(result, report);
    assertEquals(1234568.0d, (Double) impl.get(0), 0.001d);   
  }
View Full Code Here

  @Test
  public void testNextAgg() throws CruxException{
    //ceil is applied
    Result result = mock(Result.class);
    Report report = TestingUtil.getReport();
    double dbl = 1234567.8d;
    when(result.getRow()).thenReturn(Bytes.toBytes(dbl));
    CruxResultImpl impl = new CruxResultImpl(result, report);
    assertEquals(1234568.0d, (Double) impl.get(0), 0.001d);   
  }
View Full Code Here

  @Test
  public void testNoFn() throws CruxException{
    //ceil is applied
    Result result = mock(Result.class);
    KeyValue kv = mock(KeyValue.class);
    Report report = TestingUtil.getReportNoFunctionsNoGroupBy();
    String val = "123";
    when(result.getColumnLatest(TestingUtil.TEST_FAMILY,
        TestingUtil.TEST_MULTI_CQ)).thenReturn(kv);
    when (kv.getValue()).thenReturn(Bytes.toBytes(val));
    CruxResultImpl impl = new CruxResultImpl(result, report);
View Full Code Here

    return id;
  }

  public Report findById(long id) throws CruxException {

    Report report = (Report) session.get(Report.class, id);
    if (report == null) {
      throw new CruxException(
          "Selected Report does not exists in the database.",
          new Throwable());
    }
View Full Code Here

  }

  public long save(Report report) throws CruxException {
    if (report != null) {
      long id = report.getId();
      Report foundReport = null;
      ArrayList<ReportDesign> oldDesignList = null;
      ArrayList<RowAliasFilter> oldRowFilter = null;
      ArrayList<ColumnFilter> oldColumnFilter = null;
      if (id != 0) {
        try {
          foundReport = this.findById(id);
        } catch (CruxException e) {
          throw new CruxException(
              "Report you are trying to edit does not exists in database",
              e);
        }
        oldDesignList = new ArrayList<ReportDesign>(
            foundReport.getDesigns());
        oldRowFilter = new ArrayList<RowAliasFilter>(
            foundReport.getRowAliasFilters());
        oldColumnFilter = new ArrayList<ColumnFilter>(
            foundReport.getColumnFilters());

        foundReport.getDesigns().clear();
        foundReport.getRowAliasFilters().clear();
        foundReport.getColumnFilters().clear();

        for (ReportDesign design : oldDesignList) {
          try {
            transaction.begin();
            session.delete(design);
            transaction.commit();
          } catch (JDBCException e) {
            transaction.rollback();
            throw new CruxException(e.getSQLException()
                .getMessage(), e);
          }
        }

        for (RowAliasFilter rowFilter : oldRowFilter) {
          try {
            transaction.begin();
            session.delete(rowFilter);
            transaction.commit();
          } catch (JDBCException e) {
            transaction.rollback();
            throw new CruxException(e.getSQLException()
                .getMessage(), e);
          }
        }

        for (ColumnFilter columnFilter : oldColumnFilter) {
          try {
            transaction.begin();
            session.delete(columnFilter);
            transaction.commit();
          } catch (JDBCException e) {
            transaction.rollback();
            throw new CruxException(e.getSQLException()
                .getMessage(), e);
          }
        }

        ArrayList<ReportDesign> newDesignList = new ArrayList<ReportDesign>(
            report.getDesigns());
        for (ReportDesign design : newDesignList) {
          design.setReport(foundReport);
        }

        ArrayList<RowAliasFilter> newRowFilter = new ArrayList<RowAliasFilter>(
            report.getRowAliasFilters());
        for (RowAliasFilter rowFilter : newRowFilter) {
          rowFilter.setReport(foundReport);
        }

        ArrayList<ColumnFilter> newColumnFilter = new ArrayList<ColumnFilter>(
            report.getColumnFilters());
        for (ColumnFilter columnFilter : newColumnFilter) {
          columnFilter.setReport(foundReport);
        }

        foundReport.setColumnFilters(newColumnFilter);
        foundReport.setRowAliasFilters(newRowFilter);
        foundReport.setDesigns(newDesignList);
        foundReport.setName(report.getName());
        foundReport.setReportType(report.getReportType());
        foundReport.setUser(report.getUser());
        foundReport.setDashboard(report.getDashboard());
        foundReport.setNumRecordsPerPage(report.getNumRecordsPerPage());
        return saveReport(foundReport);

      }
      return saveReport(report);
    } else {
View Full Code Here

    List<GroupBy> groupByList = new ArrayList<GroupBy>();
    groupByList.add(groupBy1);
    groupByList.add(groupBy2);
   
   
    Report report = new Report();
    report.setId(1234l);
   
    GroupBys groupBys = new GroupBys();
    groupBys.setGroupBy(groupByList);
    groupBys.setReport(report);
    groupBys.setId(1l);
    report.setGroupBys(groupBys);
   
    SaveReportAction saveReportAction = new SaveReportAction();
    saveReportAction.populateGroupBys(rowAliasMap);
    saveReportAction.setReport(report);
   
View Full Code Here

TOP

Related Classes of co.nubetech.crux.model.Report

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.