⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 groupbytests.java

📁 Mandarax是一个规则引擎的纯Java实现。它支持多类型的事实和基于反映的规则
💻 JAVA
字号:
package test.org.mandarax.util.resultsetfilters;
/*
 * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
import org.mandarax.kernel.VariableTerm;
import org.mandarax.util.resultsetfilters.*;
import org.mandarax.util.resultsetfilters.aggregationfunctions.*;
import junit.framework.TestSuite;

/**
 * Test suite to test the group by filter.
 * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
 * @version 3.4 <7 March 05>
 * @since 3.0
 */

public class GroupByTests extends AbstractTestSuite {
	
	/**
	 * Launch the test suite. See TestRunner for interpretation
	 * of command line parameters.
	 * @see test.org.mandarax.testsupport.TestRunner
	 * @param args parameters
	 */
	public static void main(String[] args) {
		test.org.mandarax.testsupport.TestRunner.run (GroupByTests.class, args);
	}
	
	public static TestSuite suite() throws Exception {
		/* test kb:
			"Tom", "Meier", "01/01/1960", 80, 1.80;
			"John", "Meier", "01/01/1960", 90, 1.90;
			"Jim", "Smith", "01/01/1970", 100, 1.90;
			"Jack", "Smith", "01/01/1970", 60, 1.60;
			"Tom", "Taylor", "01/01/1980", 70, 1.70;
			"John", "Meijer", "01/01/1980", 80, 1.80;
			"Jim", "Mejer", "01/01/1990", 50, 1.50;
		*/
		
		TestSuite suite = new TestSuite("Test cases for the Group By result set filter");
		
		suite.addTest(new GroupByTestCase(
			"Group By filter test case 1",
			new AggregationFunction[]{new MAX(NAME),new MIN(DOB),new AVG(WEIGHT),new SUM(SIZE)},
			new VariableTerm[] {FNAME},
			new Object[][] {
				convert("Tom","Taylor","01/01/1960",75,3.50),
				convert("John","Meijer","01/01/1960",85,3.70),
				convert("Jim","Smith","01/01/1970",75,3.40),
				convert("Jack","Smith","01/01/1970",60,1.60)
			}
		));
		suite.addTest(new GroupByTestCase(
			"Group By filter test case 2",
			new AggregationFunction[]{new AVG(WEIGHT),new MAX(WEIGHT),new MIN(WEIGHT)},
			new VariableTerm[] {NAME,DOB},
			new Object[][] {
				convert("Meier","01/01/1960",85,90,80),
				convert("Smith","01/01/1970",80,100,60),
				convert("Taylor","01/01/1980",70,70,70),
				convert("Meijer","01/01/1980",80,80,80),
				convert("Mejer","01/01/1990",50,50,50)
			}
		));
		suite.addTest(new GroupByTestCase(
		"Group By filter test case 3",
			new AggregationFunction[]{new AVG(WEIGHT),new MAX(WEIGHT),new MIN(WEIGHT),new COUNT()},
			new VariableTerm[] {NAME,DOB},
			new Object[][] {
				convert("Meier","01/01/1960",85,90,80,2),
				convert("Smith","01/01/1970",80,100,60,2),
				convert("Taylor","01/01/1980",70,70,70,1),
				convert("Meijer","01/01/1980",80,80,80,1),
				convert("Mejer","01/01/1990",50,50,50,1)
			}
		));
		suite.addTest(new GroupByTestCase(
		"Group By filter test case 4",
			new AggregationFunction[]{new AVG(SIZE),new MAX(SIZE),new MIN(SIZE)},
			new VariableTerm[] {NAME,DOB},
			new Object[][] {
				convert("Meier","01/01/1960",1.85,1.90,1.80),
				convert("Smith","01/01/1970",1.75,1.90,1.60),
				convert("Taylor","01/01/1980",1.70,1.70,1.70),
				convert("Meijer","01/01/1980",1.80,1.80,1.80),
				convert("Mejer","01/01/1990",1.50,1.50,1.50)
			}
		));
		return suite;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -