Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Accounting and Billing Portal
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[abportal] View of /src/test/java/eu/smartlm/abs/portal/data/aggregation/DataAggregationTest.java
[abportal] / src / test / java / eu / smartlm / abs / portal / data / aggregation / DataAggregationTest.java Repository:
ViewVC logotype

View of /src/test/java/eu/smartlm/abs/portal/data/aggregation/DataAggregationTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (annotate)
Wed Jul 28 10:05:51 2010 UTC (13 years, 10 months ago) by dgarcia
File size: 49083 byte(s)
First code commit
package eu.smartlm.abs.portal.data.aggregation;


import static org.junit.Assert.assertEquals;

import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;

import org.apache.xmlbeans.XmlAnySimpleType;
import org.gridforum.x2003.urWg.HostDocument.Host;
import org.gridforum.x2003.urWg.ProjectNameDocument.ProjectName;
import org.gridforum.x2003.urWg.SubmitHostDocument.SubmitHost;
import org.gridforum.x2003.urWg.UserIdentityDocument.UserIdentity;
import org.junit.Before;
import org.junit.Test;

import eu.smartlm.abs.portal.view.portlet.QueryPortlet;
import eu.smartlm.schemas.x2009.x06.urec.AccountingPeriodType;
import eu.smartlm.schemas.x2009.x06.urec.ChargeType;
import eu.smartlm.schemas.x2009.x06.urec.LicenseResourceType;
import eu.smartlm.schemas.x2009.x06.urec.LicenseType;
import eu.smartlm.schemas.x2009.x06.urec.ProductType;
import eu.smartlm.schemas.x2009.x06.urec.SmartLMUsageRecordType;

/**
 * Test class to evaluate the correct aggregation of data
 * @author David García Pérez - CESGA
 *
 */
public class DataAggregationTest {
	private UserIdentity userA; 
	private UserIdentity userB;
	private String accountingGroupA = "DeparmentA";
	private String accountingGroupB = "DepartmentB";
	private Host hostA;
	private Host hostB;
	private Host hostC;
	private SubmitHost submitHostA;
	private SubmitHost submitHostB;
	private SubmitHost submitHostC;
	private ProductType productA;
	private ProductType productB;
	private ProductType productC;
	private ProjectName projectA;
	private ProjectName projectB;
	private ProjectName projectC;
	private Set<SmartLMUsageRecordType> smartLMUsageRecords;
	
	@Before
	public void init() {
		// We construct the object map for the test
		userA = UserIdentity.Factory.newInstance();
		userA.setLocalUserId("UserA");
		userB = UserIdentity.Factory.newInstance();
		userB.setLocalUserId("UserB");
	
		XmlAnySimpleType productAId = XmlAnySimpleType.Factory.newInstance();
		productAId.setStringValue("Ansys CFX ID");
		XmlAnySimpleType productBId = XmlAnySimpleType.Factory.newInstance();
		productBId.setStringValue("CalcuNetW ID");
		XmlAnySimpleType productCId = XmlAnySimpleType.Factory.newInstance();
		productCId.setStringValue("GCWorkSpaces ID");
		//xmlAnySimpleType.set
		productA = ProductType.Factory.newInstance();
		productA.setName("Ansys CFX");
		productA.setProductId("Ansys CFX ID");
		//productA.setProductId(productAId);
		productB = ProductType.Factory.newInstance();
		productB.setName("CalcuNetW");
		productB.setProductId("CalcuNetW ID");
		//productB.setProductId(productBId);
		productC = ProductType.Factory.newInstance();
		productC.setName("GCWorkspaces");
		productC.setProductId("GCWorkSpaces ID");
		//productC.setProductId(productCId);
		
		LicenseType licenseA = LicenseType.Factory.newInstance();
		licenseA.setProduct(productA);
		LicenseType licenseB = LicenseType.Factory.newInstance();
		licenseB.setProduct(productB);
		LicenseType licenseC = LicenseType.Factory.newInstance();
		licenseC.setProduct(productC);
			
		hostA = Host.Factory.newInstance();
		hostA.setStringValue("HostA");
		hostB = Host.Factory.newInstance();
		hostB.setStringValue("HostB");
		hostC = Host.Factory.newInstance();
		hostC.setStringValue("HostC");
		
		submitHostA = SubmitHost.Factory.newInstance();
		submitHostA.setStringValue("SubmitHostA");
		submitHostB = SubmitHost.Factory.newInstance();
		submitHostB.setStringValue("SubmitHostB");
		submitHostC = SubmitHost.Factory.newInstance();
		submitHostC.setStringValue("SubmitHostC");
		
		Calendar date1 = Calendar.getInstance();
		date1.set(Calendar.YEAR, 2009);
		date1.set(Calendar.MONTH, 4);
		date1.set(Calendar.DAY_OF_MONTH, 7);
		date1.set(Calendar.HOUR, 15);
		date1.set(Calendar.MINUTE, 30);
		date1.set(Calendar.SECOND, 0);
		date1.set(Calendar.MILLISECOND, 0);
		
		Calendar date2 = Calendar.getInstance();
		date2.set(Calendar.YEAR, 2009);
		date2.set(Calendar.MONTH, 4);
		date2.set(Calendar.DAY_OF_MONTH, 7);
		date2.set(Calendar.HOUR, 16);
		date2.set(Calendar.MINUTE, 30);
		date2.set(Calendar.SECOND, 0);
		date2.set(Calendar.MILLISECOND, 0);
		
		ChargeType charge = ChargeType.Factory.newInstance();
		charge.setStringValue("10.0");
		
		AccountingPeriodType accountingPeriodA = AccountingPeriodType.Factory.newInstance();
		accountingPeriodA.setStartTime(date1);
		accountingPeriodA.setEndTime(date2);
		
		LicenseResourceType licenseResource01 = LicenseResourceType.Factory.newInstance();
		licenseResource01.setLicense(licenseA);
		licenseResource01.setAccountingPeriod(accountingPeriodA);
		licenseResource01.setAccountingGroup(accountingGroupA);
		licenseResource01.setCharge(charge);
		LicenseResourceType licenseResource02 = LicenseResourceType.Factory.newInstance();
		licenseResource02.setLicense(licenseA);
		licenseResource02.setAccountingPeriod(accountingPeriodA);
		licenseResource02.setAccountingGroup(accountingGroupA);
		licenseResource02.setCharge(charge);
		LicenseResourceType licenseResource03 = LicenseResourceType.Factory.newInstance();
		licenseResource03.setLicense(licenseA);
		licenseResource03.setAccountingPeriod(accountingPeriodA);
		licenseResource03.setAccountingGroup(accountingGroupA);
		licenseResource03.setCharge(charge);
		LicenseResourceType licenseResource04 = LicenseResourceType.Factory.newInstance();
		licenseResource04.setLicense(licenseB);
		licenseResource04.setAccountingPeriod(accountingPeriodA);
		licenseResource04.setAccountingGroup(accountingGroupA);
		licenseResource04.setCharge(charge);
		LicenseResourceType licenseResource05 = LicenseResourceType.Factory.newInstance();
		licenseResource05.setLicense(licenseB);
		licenseResource05.setAccountingPeriod(accountingPeriodA);
		licenseResource05.setAccountingGroup(accountingGroupA);
		licenseResource05.setCharge(charge);
		LicenseResourceType licenseResource06 = LicenseResourceType.Factory.newInstance();
		licenseResource06.setLicense(licenseC);
		licenseResource06.setAccountingPeriod(accountingPeriodA);
		licenseResource06.setAccountingGroup(accountingGroupB);
		licenseResource06.setCharge(charge);
		LicenseResourceType licenseResource07 = LicenseResourceType.Factory.newInstance();
		licenseResource07.setLicense(licenseA);
		licenseResource07.setAccountingPeriod(accountingPeriodA);
		licenseResource07.setAccountingGroup(accountingGroupB);
		licenseResource07.setCharge(charge);
		LicenseResourceType licenseResource08 = LicenseResourceType.Factory.newInstance();
		licenseResource08.setLicense(licenseB);
		licenseResource08.setAccountingPeriod(accountingPeriodA);
		licenseResource08.setAccountingGroup(accountingGroupB);
		licenseResource08.setCharge(charge);
		LicenseResourceType licenseResource09 = LicenseResourceType.Factory.newInstance();
		licenseResource09.setLicense(licenseC);
		licenseResource09.setAccountingPeriod(accountingPeriodA);
		licenseResource09.setAccountingGroup(accountingGroupB);
		licenseResource09.setCharge(charge);
		
		projectA = ProjectName.Factory.newInstance();
		projectA.setStringValue("ProjectA");
		projectB = ProjectName.Factory.newInstance();
		projectB.setStringValue("ProjectB");
		projectC = ProjectName.Factory.newInstance();
		projectC.setStringValue("ProjectC");
		
		
		
		SmartLMUsageRecordType usageRecord01 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray01 = {userA};
		LicenseResourceType[] licenseResouceArray01 = {licenseResource01};
		ProjectName[] projectNameArray01 = {projectA};
		usageRecord01.setUserIdentityArray(userIndentityArray01);
		usageRecord01.setLicenseResourceArray(licenseResouceArray01);
		usageRecord01.setProjectNameArray(projectNameArray01);
		Host[] hostArray01 = {hostA};
		usageRecord01.setHostArray(hostArray01);
		SubmitHost[] submitHostArray01 = {submitHostA};
		usageRecord01.setSubmitHostArray(submitHostArray01);
		
		SmartLMUsageRecordType usageRecord02 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray02 = {userA};
		LicenseResourceType[] licenseResouceArray02 = {licenseResource02};
		ProjectName[] projectNameArray02 = {projectA};
		usageRecord02.setUserIdentityArray(userIndentityArray02);
		usageRecord02.setLicenseResourceArray(licenseResouceArray02);
		usageRecord02.setProjectNameArray(projectNameArray02);
		Host[] hostArray02 = {hostA};
		usageRecord02.setHostArray(hostArray02);
		SubmitHost[] submitHostArray02 = {submitHostA};
		usageRecord02.setSubmitHostArray(submitHostArray02);
		
		SmartLMUsageRecordType usageRecord03 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray03 = {userA};
		LicenseResourceType[] licenseResouceArray03 = {licenseResource03};
		ProjectName[] projectNameArray03 = {projectA};
		usageRecord03.setUserIdentityArray(userIndentityArray03);
		usageRecord03.setLicenseResourceArray(licenseResouceArray03);
		usageRecord03.setProjectNameArray(projectNameArray03);
		Host[] hostArray03 = {hostA};
		usageRecord03.setHostArray(hostArray03);
		SubmitHost[] submitHostArray03 = {submitHostA};
		usageRecord03.setSubmitHostArray(submitHostArray03);
		
		SmartLMUsageRecordType usageRecord04 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray04 = {userA};
		LicenseResourceType[] licenseResouceArray04 = {licenseResource04};
		ProjectName[] projectNameArray04 = {projectA};
		usageRecord04.setUserIdentityArray(userIndentityArray04);
		usageRecord04.setLicenseResourceArray(licenseResouceArray04);
		usageRecord04.setProjectNameArray(projectNameArray04);
		Host[] hostArray04 = {hostA};
		usageRecord04.setHostArray(hostArray04);
		SubmitHost[] submitHostArray04 = {submitHostA};
		usageRecord04.setSubmitHostArray(submitHostArray04);
		
		SmartLMUsageRecordType usageRecord05 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray05 = {userA};
		LicenseResourceType[] licenseResouceArray05 = {licenseResource05};
		ProjectName[] projectNameArray05 = {projectA};
		usageRecord05.setUserIdentityArray(userIndentityArray05);
		usageRecord05.setLicenseResourceArray(licenseResouceArray05);
		usageRecord05.setProjectNameArray(projectNameArray05);
		Host[] hostArray05 = {hostB};
		usageRecord05.setHostArray(hostArray05);
		SubmitHost[] submitHostArray05 = {submitHostB};
		usageRecord05.setSubmitHostArray(submitHostArray05);
		
		SmartLMUsageRecordType usageRecord06 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray06 = {userA};
		LicenseResourceType[] licenseResouceArray06 = {licenseResource06};
		ProjectName[] projectNameArray06 = {projectB};
		usageRecord06.setUserIdentityArray(userIndentityArray06);
		usageRecord06.setLicenseResourceArray(licenseResouceArray06);
		usageRecord06.setProjectNameArray(projectNameArray06);
		Host[] hostArray06 = {hostB};
		usageRecord06.setHostArray(hostArray06);
		SubmitHost[] submitHostArray06 = {submitHostB};
		usageRecord06.setSubmitHostArray(submitHostArray06);

		SmartLMUsageRecordType usageRecord07 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray07 = {userB};
		LicenseResourceType[] licenseResouceArray07 = {licenseResource07};
		ProjectName[] projectNameArray07 = {projectB};
		usageRecord07.setUserIdentityArray(userIndentityArray07);
		usageRecord07.setLicenseResourceArray(licenseResouceArray07);
		usageRecord07.setProjectNameArray(projectNameArray07);
		Host[] hostArray07 = {hostB};
		usageRecord07.setHostArray(hostArray07);
		SubmitHost[] submitHostArray07 = {submitHostB};
		usageRecord07.setSubmitHostArray(submitHostArray07);

		SmartLMUsageRecordType usageRecord08 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray08 = {userB};
		LicenseResourceType[] licenseResouceArray08 = {licenseResource08};
		ProjectName[] projectNameArray08 = {projectB};
		usageRecord08.setUserIdentityArray(userIndentityArray08);
		usageRecord08.setLicenseResourceArray(licenseResouceArray08);
		usageRecord08.setProjectNameArray(projectNameArray08);
		Host[] hostArray08 = {hostC};
		usageRecord08.setHostArray(hostArray08);
		SubmitHost[] submitHostArray08 = {submitHostC};
		usageRecord08.setSubmitHostArray(submitHostArray08);

		SmartLMUsageRecordType usageRecord09 = SmartLMUsageRecordType.Factory.newInstance();
		UserIdentity[] userIndentityArray09 = {userB};
		LicenseResourceType[] licenseResouceArray09 = {licenseResource09};
		ProjectName[] projectNameArray09 = {projectB};
		usageRecord09.setUserIdentityArray(userIndentityArray09);
		usageRecord09.setLicenseResourceArray(licenseResouceArray09);
		usageRecord09.setProjectNameArray(projectNameArray09);
		Host[] hostArray09 = {hostB};
		usageRecord09.setHostArray(hostArray09);
		SubmitHost[] submitHostArray09 = {submitHostC};
		usageRecord09.setSubmitHostArray(submitHostArray09);
		
		smartLMUsageRecords = new HashSet<SmartLMUsageRecordType>();
		smartLMUsageRecords.add(usageRecord01);
		smartLMUsageRecords.add(usageRecord02);
		smartLMUsageRecords.add(usageRecord03);
		smartLMUsageRecords.add(usageRecord04);
		smartLMUsageRecords.add(usageRecord05);
		smartLMUsageRecords.add(usageRecord06);
		smartLMUsageRecords.add(usageRecord07);
		smartLMUsageRecords.add(usageRecord08);
		smartLMUsageRecords.add(usageRecord09);
	}

	/**
	 * Aggregates the hours or money of different products that are going to be tested
	 * @throws Exception
	 */
	@Test
	public void aggregateProductForUsers() throws Exception {
		// Accounting
		assertEquals(3.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userA,productA, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(2.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userA,productB, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(1.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userA,productC, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(1.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userB,productA, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(1.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userB,productB, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(1.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userB,productC, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		
		//Billing
		assertEquals(30.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userA,productA, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(20.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userA,productB, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(10.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userA,productC, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(10.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userB,productA, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(10.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userB,productB, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(10.0,DataAggregation.determineUsageByProduct(smartLMUsageRecords,userB,productC, QueryPortlet.TYPE_BILLING),0.0001);
	}
	
	/**
	 * Aggregates the hours of different departments filter by users that are going to be tested
	 * @throws Exception
	 */
	@Test
	public void aggregateDeparmentHoursForUsers() throws Exception {
		
		assertEquals(5.0, DataAggregation.determineUsageByAccountingGroup(smartLMUsageRecords, userA, accountingGroupA, QueryPortlet.TYPE_ACCOUNTING), 0.1);
		assertEquals(1.0, DataAggregation.determineUsageByAccountingGroup(smartLMUsageRecords, userA, accountingGroupB, QueryPortlet.TYPE_ACCOUNTING), 0.1);
		assertEquals(0.0, DataAggregation.determineUsageByAccountingGroup(smartLMUsageRecords, userB, accountingGroupA, QueryPortlet.TYPE_ACCOUNTING), 0.1);
		assertEquals(3.0, DataAggregation.determineUsageByAccountingGroup(smartLMUsageRecords, userB, accountingGroupB, QueryPortlet.TYPE_ACCOUNTING), 0.1);
		
		assertEquals(50.0, DataAggregation.determineUsageByAccountingGroup(smartLMUsageRecords, userA, accountingGroupA, QueryPortlet.TYPE_BILLING), 0.1);
		assertEquals(10.0, DataAggregation.determineUsageByAccountingGroup(smartLMUsageRecords, userA, accountingGroupB, QueryPortlet.TYPE_BILLING), 0.1);
		assertEquals(00.0, DataAggregation.determineUsageByAccountingGroup(smartLMUsageRecords, userB, accountingGroupA, QueryPortlet.TYPE_BILLING), 0.1);
		assertEquals(30.0, DataAggregation.determineUsageByAccountingGroup(smartLMUsageRecords, userB, accountingGroupB, QueryPortlet.TYPE_BILLING), 0.1);
	}
	
	/**
	 * This test verifies that the hours a user employs an specific host are correctly calculated
	 * @throws Exception
	 */
	@Test
	public void aggregateHostHoursByUser() throws Exception {
				
		assertEquals(4.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userA, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(2.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userA, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(0.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userA, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(0.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userB, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(2.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userB, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(1.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userB, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		
		assertEquals(40.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userA, hostA, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(20.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userA, hostB, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(00.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userA, hostC, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(00.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userB, hostA, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(20.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userB, hostB, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(10.0, DataAggregation.determineUsageByHost(smartLMUsageRecords, userB, hostC, QueryPortlet.TYPE_BILLING), 0.001);
	}

	/**
	 * This test verifies that the hours a user employs an specific submitHost are correctly calculated
	 * @throws Exception
	 */
	@Test
	public void aggregateSubmitHostHoursByUser() throws Exception {
		
		assertEquals(4.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userA, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(2.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userA, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(0.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userA, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(0.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userB, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(1.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userB, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		assertEquals(2.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userB, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.001);
		
		assertEquals(40.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userA, submitHostA, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(20.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userA, submitHostB, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(00.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userA, submitHostC, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(00.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userB, submitHostA, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(10.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userB, submitHostB, QueryPortlet.TYPE_BILLING), 0.001);
		assertEquals(20.0, DataAggregation.determineUsageBySubmitHost(smartLMUsageRecords, userB, submitHostC, QueryPortlet.TYPE_BILLING), 0.001);
	}
	
	/**
	 * Aggregates the hours spent by a user
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForUsers() throws Exception {
		assertEquals(6.0,DataAggregation.determineUsageForAUser(smartLMUsageRecords,userA, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(3.0,DataAggregation.determineUsageForAUser(smartLMUsageRecords,userB, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		
		assertEquals(60.0,DataAggregation.determineUsageForAUser(smartLMUsageRecords,userA, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(30.0,DataAggregation.determineUsageForAUser(smartLMUsageRecords,userB, QueryPortlet.TYPE_BILLING),0.0001);
	}
	
	/**
	 * Aggregates the hours spent by an AccountingGroups
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForAnAccountingGroup() throws Exception {
		assertEquals(5.0,DataAggregation.determineUsageForAnAccountingGroup(smartLMUsageRecords, accountingGroupA, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(4.0,DataAggregation.determineUsageForAnAccountingGroup(smartLMUsageRecords, accountingGroupB, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		
		assertEquals(50.0,DataAggregation.determineUsageForAnAccountingGroup(smartLMUsageRecords, accountingGroupA, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(40.0,DataAggregation.determineUsageForAnAccountingGroup(smartLMUsageRecords, accountingGroupB, QueryPortlet.TYPE_BILLING),0.0001);
	}
	
	/**
	 * Aggregates the hours spent by an Accounting Group filter by a Project
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForAnAccountingGroupFilterByProject() throws Exception {
		assertEquals(5.0, DataAggregation.determineUsageForAnAccountingGroupFilterByProject(smartLMUsageRecords, accountingGroupA, projectA, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		assertEquals(0.0, DataAggregation.determineUsageForAnAccountingGroupFilterByProject(smartLMUsageRecords, accountingGroupA, projectB, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		assertEquals(0.0, DataAggregation.determineUsageForAnAccountingGroupFilterByProject(smartLMUsageRecords, accountingGroupB, projectA, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		assertEquals(4.0, DataAggregation.determineUsageForAnAccountingGroupFilterByProject(smartLMUsageRecords, accountingGroupB, projectB, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		
		assertEquals(50.0, DataAggregation.determineUsageForAnAccountingGroupFilterByProject(smartLMUsageRecords, accountingGroupA, projectA, QueryPortlet.TYPE_BILLING), 0.0001);
		assertEquals(00.0, DataAggregation.determineUsageForAnAccountingGroupFilterByProject(smartLMUsageRecords, accountingGroupA, projectB, QueryPortlet.TYPE_BILLING), 0.0001);
		assertEquals(00.0, DataAggregation.determineUsageForAnAccountingGroupFilterByProject(smartLMUsageRecords, accountingGroupB, projectA, QueryPortlet.TYPE_BILLING), 0.0001);
		assertEquals(40.0, DataAggregation.determineUsageForAnAccountingGroupFilterByProject(smartLMUsageRecords, accountingGroupB, projectB, QueryPortlet.TYPE_BILLING), 0.0001);
	}
	
	/**
	 * Aggregates the hours spent by a project
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForProject() throws Exception {
		assertEquals(5.0,DataAggregation.determineUsageForAProject(smartLMUsageRecords, projectA, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(4.0,DataAggregation.determineUsageForAProject(smartLMUsageRecords, projectB, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(0.0,DataAggregation.determineUsageForAProject(smartLMUsageRecords, projectC, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		
		assertEquals(50.0,DataAggregation.determineUsageForAProject(smartLMUsageRecords, projectA, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(40.0,DataAggregation.determineUsageForAProject(smartLMUsageRecords, projectB, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(00.0,DataAggregation.determineUsageForAProject(smartLMUsageRecords, projectC, QueryPortlet.TYPE_BILLING),0.0001);
	}
	
	/**
	 * Aggregates the hours spent by a product
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForProduct() throws Exception {
		assertEquals(4.0,DataAggregation.determineUsageForAProduct(smartLMUsageRecords, productA, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(3.0,DataAggregation.determineUsageForAProduct(smartLMUsageRecords, productB, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(2.0,DataAggregation.determineUsageForAProduct(smartLMUsageRecords, productC, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		
		assertEquals(40.0,DataAggregation.determineUsageForAProduct(smartLMUsageRecords, productA, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(30.0,DataAggregation.determineUsageForAProduct(smartLMUsageRecords, productB, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(20.0,DataAggregation.determineUsageForAProduct(smartLMUsageRecords, productC, QueryPortlet.TYPE_BILLING),0.0001);
	}
	
	/**
	 * Aggregates the hours spent by a Host
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForAHost() throws Exception {
		assertEquals(4.0, DataAggregation.determineUsageForAHost(smartLMUsageRecords, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(4.0, DataAggregation.determineUsageForAHost(smartLMUsageRecords, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageForAHost(smartLMUsageRecords, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(40.0, DataAggregation.determineUsageForAHost(smartLMUsageRecords, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(40.0, DataAggregation.determineUsageForAHost(smartLMUsageRecords, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageForAHost(smartLMUsageRecords, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * Aggregates the hours spent by a SubmitHost
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForASubmitHost() throws Exception {
		assertEquals(4.0, DataAggregation.determineUsageForASubmitHost(smartLMUsageRecords, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(3.0, DataAggregation.determineUsageForASubmitHost(smartLMUsageRecords, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(2.0, DataAggregation.determineUsageForASubmitHost(smartLMUsageRecords, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(40.0, DataAggregation.determineUsageForASubmitHost(smartLMUsageRecords, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(30.0, DataAggregation.determineUsageForASubmitHost(smartLMUsageRecords, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(20.0, DataAggregation.determineUsageForASubmitHost(smartLMUsageRecords, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * Test that the time is correctly calculated
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForUserFilterByProject() throws Exception {
		assertEquals(5.0,DataAggregation.determineUsageByProject(smartLMUsageRecords, userA, projectA, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(0.0,DataAggregation.determineUsageByProject(smartLMUsageRecords, userB, projectA, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(1.0,DataAggregation.determineUsageByProject(smartLMUsageRecords, userA, projectB, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		assertEquals(3.0,DataAggregation.determineUsageByProject(smartLMUsageRecords, userB, projectB, QueryPortlet.TYPE_ACCOUNTING),0.0001);
		
		assertEquals(50.0,DataAggregation.determineUsageByProject(smartLMUsageRecords, userA, projectA, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(00.0,DataAggregation.determineUsageByProject(smartLMUsageRecords, userB, projectA, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(10.0,DataAggregation.determineUsageByProject(smartLMUsageRecords, userA, projectB, QueryPortlet.TYPE_BILLING),0.0001);
		assertEquals(30.0,DataAggregation.determineUsageByProject(smartLMUsageRecords, userB, projectB, QueryPortlet.TYPE_BILLING),0.0001);
	}
	
	/**
	 * Test to determine the usage hours by Product filter by Project
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForProductsFilterByProject() throws Exception {
		assertEquals(3.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productA, projectA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productA, projectB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(2.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productB, projectA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productB, projectB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productC, projectA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(2.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productC, projectB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(30.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productA, projectA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productA, projectB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(20.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productB, projectA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productB, projectB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productC, projectA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(20.0, DataAggregation.determineUsageByProductFilterByProject(smartLMUsageRecords, productC, projectB, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * Test to determine the usage hours by Product filter by Host
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForProductsFilterByHost() throws Exception {
		assertEquals(3.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productA, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productA, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productA, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productB, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productB, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productB, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productC, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(2.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productC, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productC, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(30.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productA, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productA, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productA, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productB, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productB, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productB, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productC, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(20.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productC, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProductFilterByHost(smartLMUsageRecords, productC, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * Test to determine the usage hours by Product filter by SubmitHost
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForProductsFilterBySubmitHost() throws Exception {
		assertEquals(3.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productA, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productA, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productA, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productB, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productB, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productB, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productC, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productC, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productC, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(30.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productA, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productA, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productA, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productB, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productB, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productB, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productC, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productC, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProductFilterBySubmitHost(smartLMUsageRecords, productC, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * It determines that the usage hours of an AccountingGroup filter by Host are correctly calculated
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForAccountingGroupsFilterByHosts() throws Exception {
		assertEquals(4.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupA, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupA, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupA, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupB, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(3.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupB, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupB, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(40.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupA, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupA, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupA, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupB, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(30.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupB, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByAccountingGroupFilterByHost(smartLMUsageRecords, accountingGroupB, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * It determines that the usage hours of an AccountingGroup filter by SubmitHost are correctly calculated
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForAccountingGroupsFilterBySubmitHosts() throws Exception {
		assertEquals(4.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupA, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupA, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupA, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupB, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(2.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupB, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(2.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupB, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(40.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupA, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupA, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupA, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupB, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(20.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupB, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(20.0, DataAggregation.determineUsageByAccountingGroupFilterBySubmitHost(smartLMUsageRecords, accountingGroupB, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * It determines that the usage hours of an Project filter by a Host are correctly calculated
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForProjectsFilterByHosts() throws Exception {
		assertEquals(4.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectA, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectB, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectC, hostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectA, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(3.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectB, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectC, hostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectA, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectB, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectC, hostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(40.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectA, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectB, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectC, hostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectA, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(30.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectB, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectC, hostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectA, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectB, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterByHost(smartLMUsageRecords, projectC, hostC, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * It determines that the usage hours of an Project filter by a SubmitHost are correctly calculated
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForProjectsFilterBySubmitHosts() throws Exception {
		assertEquals(4.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectA, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectB, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectC, submitHostA, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(1.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectA, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(2.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectB, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectC, submitHostB, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectA, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(2.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectB, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		assertEquals(0.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectC, submitHostC, QueryPortlet.TYPE_ACCOUNTING), 0.000001);
		
		assertEquals(40.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectA, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectB, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectC, submitHostA, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(10.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectA, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(20.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectB, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectC, submitHostB, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectA, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(20.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectB, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
		assertEquals(00.0, DataAggregation.determineUsageByProjectFilterBySubmitHost(smartLMUsageRecords, projectC, submitHostC, QueryPortlet.TYPE_BILLING), 0.000001);
	}
	
	/**
	 * Test that the time is correctly calculated
	 * @throws Exception
	 */
	@Test
	public void aggregateHoursForProductFilterByDepartment() throws Exception {
		 
		assertEquals(3.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productA, accountingGroupA, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		assertEquals(2.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productB, accountingGroupA, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		assertEquals(0.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productC, accountingGroupA, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		assertEquals(1.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productA, accountingGroupB, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		assertEquals(1.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productB, accountingGroupB, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		assertEquals(2.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productC, accountingGroupB, QueryPortlet.TYPE_ACCOUNTING), 0.0001);
		
		assertEquals(30.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productA, accountingGroupA, QueryPortlet.TYPE_BILLING), 0.0001);
		assertEquals(20.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productB, accountingGroupA, QueryPortlet.TYPE_BILLING), 0.0001);
		assertEquals(00.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productC, accountingGroupA, QueryPortlet.TYPE_BILLING), 0.0001);
		assertEquals(10.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productA, accountingGroupB, QueryPortlet.TYPE_BILLING), 0.0001);
		assertEquals(10.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productB, accountingGroupB, QueryPortlet.TYPE_BILLING), 0.0001);
		assertEquals(20.0,DataAggregation.determineUsageForProductByAccountingGroup(smartLMUsageRecords, productC, accountingGroupB, QueryPortlet.TYPE_BILLING), 0.0001);
	}
}

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge