// Path: core/src/main/java/pt/webdetails/cda/dataaccess/ColumnDefinition.java
// public class ColumnDefinition {
// 
//   public enum TYPE {
//     COLUMN, CALCULATED_COLUMN
//   }
// 
// 
//   private TYPE type;
//   private Integer index;
//   private String name;
//   private String formula;
// 
//   public ColumnDefinition() {
//   }
// 
//   public ColumnDefinition( final Element p ) {
// 
//     this();
// 
//     setName( p.selectSingleNode( "Name" ).getText() );
// 
//     if ( p.getName().equals( "CalculatedColumn" ) ) {
//       setType( TYPE.CALCULATED_COLUMN );
//       setFormula( p.selectSingleNode( "Formula" ).getText() );
//     } else {
//       setType( TYPE.COLUMN );
//       setIndex( Integer.parseInt( p.attributeValue( "idx" ) ) );
//     }
// 
//   }
// 
//   public TYPE getType() {
//     return type;
//   }
// 
//   public void setType( final TYPE type ) {
//     this.type = type;
//   }
// 
//   public Integer getIndex() {
//     return index;
//   }
// 
//   public void setIndex( final Integer index ) {
//     this.index = index;
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   public void setName( final String name ) {
//     this.name = name;
//   }
// 
//   public String getFormula() {
//     return formula;
//   }
// 
//   public void setFormula( final String formula ) {
//     this.formula = formula;
//   }
// 
//   public void accept( DomVisitor xmlVisitor, Element daEle ) {
//     xmlVisitor.visit( this, daEle );
//   }
// 
// }


import org.junit.BeforeClass;
import org.junit.Test;
import org.pentaho.reporting.engine.classic.core.util.TypedTableModel;
import pt.webdetails.cda.dataaccess.ColumnDefinition;
import java.math.BigDecimal;
import static pt.webdetails.cda.test.util.CdaTestHelper.getMockEnvironment;
import static pt.webdetails.cda.test.util.CdaTestHelper.initBareEngine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/*!
 * Copyright 2002 - 2017 Webdetails, a Hitachi Vantara company. All rights reserved.
 *
 * This software was developed by Webdetails and is provided under the terms
 * of the Mozilla Public License, Version 2.0, or any later version. You may not use
 * this file except in compliance with the license. If you need a copy of the license,
 * please go to  http://mozilla.org/MPL/2.0/. The Initial Developer is Webdetails.
 *
 * Software distributed under the Mozilla Public License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
 * the license for the specific language governing your rights and limitations.
 */

package pt.webdetails.cda.utils;






public class CalculatedTableModelTest {

  @BeforeClass
  public static void init() {
    initBareEngine( getMockEnvironment() );
  }

  @Test
  public void testGetValueAt() {
    BigDecimal validValue = new BigDecimal( 7 );

    TypedTableModel typedTableModel = new TypedTableModel( new String[] { "Q1", "Q2" },
      new Class<?>[] { Double.class, Double.class } );
    typedTableModel.addRow( 14.0d, 2.0d );
    typedTableModel.addRow( 14.0d, 0.0d );
    typedTableModel.addRow( null, 15.0d );
    typedTableModel.addRow( 14.0d, null );

    ColumnDefinition columnDefinition = new ColumnDefinition();
    columnDefinition.setFormula( "=[Q1]/[Q2]" );
// Path: core/src/main/java/pt/webdetails/cda/dataaccess/ColumnDefinition.java
// public class ColumnDefinition {
// 
//   public enum TYPE {
//     COLUMN, CALCULATED_COLUMN
//   }
// 
// 
//   private TYPE type;
//   private Integer index;
//   private String name;
//   private String formula;
// 
//   public ColumnDefinition() {
//   }
// 
//   public ColumnDefinition( final Element p ) {
// 
//     this();
// 
//     setName( p.selectSingleNode( "Name" ).getText() );
// 
//     if ( p.getName().equals( "CalculatedColumn" ) ) {
//       setType( TYPE.CALCULATED_COLUMN );
//       setFormula( p.selectSingleNode( "Formula" ).getText() );
//     } else {
//       setType( TYPE.COLUMN );
//       setIndex( Integer.parseInt( p.attributeValue( "idx" ) ) );
//     }
// 
//   }
// 
//   public TYPE getType() {
//     return type;
//   }
// 
//   public void setType( final TYPE type ) {
//     this.type = type;
//   }
// 
//   public Integer getIndex() {
//     return index;
//   }
// 
//   public void setIndex( final Integer index ) {
//     this.index = index;
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   public void setName( final String name ) {
//     this.name = name;
//   }
// 
//   public String getFormula() {
//     return formula;
//   }
// 
//   public void setFormula( final String formula ) {
//     this.formula = formula;
//   }
// 
//   public void accept( DomVisitor xmlVisitor, Element daEle ) {
//     xmlVisitor.visit( this, daEle );
//   }
// 
// }


// Path: core/src/test/java/pt/webdetails/cda/utils/CalculatedTableModelTest.java
import org.junit.BeforeClass;
import org.junit.Test;
import org.pentaho.reporting.engine.classic.core.util.TypedTableModel;
import pt.webdetails.cda.dataaccess.ColumnDefinition;
import java.math.BigDecimal;
import static pt.webdetails.cda.test.util.CdaTestHelper.getMockEnvironment;
import static pt.webdetails.cda.test.util.CdaTestHelper.initBareEngine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

/*!
 * Copyright 2002 - 2017 Webdetails, a Hitachi Vantara company. All rights reserved.
 *
 * This software was developed by Webdetails and is provided under the terms
 * of the Mozilla Public License, Version 2.0, or any later version. You may not use
 * this file except in compliance with the license. If you need a copy of the license,
 * please go to  http://mozilla.org/MPL/2.0/. The Initial Developer is Webdetails.
 *
 * Software distributed under the Mozilla Public License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
 * the license for the specific language governing your rights and limitations.
 */

package pt.webdetails.cda.utils;






public class CalculatedTableModelTest {

  @BeforeClass
  public static void init() {
    initBareEngine( getMockEnvironment() );
  }

  @Test
  public void testGetValueAt() {
    BigDecimal validValue = new BigDecimal( 7 );

    TypedTableModel typedTableModel = new TypedTableModel( new String[] { "Q1", "Q2" },
      new Class<?>[] { Double.class, Double.class } );
    typedTableModel.addRow( 14.0d, 2.0d );
    typedTableModel.addRow( 14.0d, 0.0d );
    typedTableModel.addRow( null, 15.0d );
    typedTableModel.addRow( 14.0d, null );

    ColumnDefinition columnDefinition = new ColumnDefinition();
    columnDefinition.setFormula( "=[Q1]/[Q2]" );
    columnDefinition.setType( ColumnDefinition.TYPE.CALCULATED_COLUMN );