Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * OfficeFloor - http://www.officefloor.net
   * Copyright (C) 2005-2011 Daniel Sagenschneider
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
  * This program 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 General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package net.officefloor.model.impl.officefloor;
 
 
 
Tests the net.officefloor.model.officefloor.OfficeFloorRepository.

Author(s):
Daniel Sagenschneider
 
 public class OfficeFloorRepositoryTest extends OfficeFrameTestCase {

 
 	private final ModelRepository modelRepository = this
 
 	private final ConfigurationItem configurationItem = this
 
Ensures on retrieving a net.officefloor.model.officefloor.OfficeFloorModel that all net.officefloor.model.ConnectionModel instances are connected.
 
 	public void testRetrieveOfficeFloor() throws Exception {
 
 		// Create the raw office floor to be connected
 		OfficeFloorModel officeFloor = new OfficeFloorModel();
 				"MANAGED_OBJECT_SOURCE",
 				"net.example.ExampleManagedObjectSource"Connection.class
 						.getName(), "0");
 		officeFloor
 				.addOfficeFloorManagedObjectSource(officeFloorManagedObjectSource);
 				"INPUT_MANAGED_OBJECT"Connection.class.getName());
 		officeFloor
 				.addOfficeFloorInputManagedObject(officeFloorInputManagedObject);
 		OfficeFloorManagedObjectModel officeFloorManagedObject = new OfficeFloorManagedObjectModel(
				"MANAGED_OBJECT""THREAD");
		officeFloor.addOfficeFloorManagedObject(officeFloorManagedObject);
		OfficeFloorTeamModel officeFloorTeam = new OfficeFloorTeamModel(
				"OFFICE_FLOOR_TEAM""net.example.ExampleTeamSource");
		officeFloor.addOfficeFloorTeam(officeFloorTeam);
		DeployedOfficeModel office = new DeployedOfficeModel("OFFICE",
				"net.example.ExampleOfficeSource""OFFICE_LOCATION");
		officeFloor.addDeployedOffice(office);
				"SECTION""INPUT"Integer.class.getName());
		office.addDeployedOfficeInput(officeInput);
				"OBJECT"Connection.class.getName());
		office.addDeployedOfficeObject(officeObject);
				"OFFICE_TEAM");
		office.addDeployedOfficeTeam(officeTeam);
		// office floor managed object -> office floor managed object source
				"MANAGED_OBJECT_SOURCE");
		officeFloorManagedObject.setOfficeFloorManagedObjectSource(moToSource);
		// input managed object -> bound managed object source
				"MANAGED_OBJECT_SOURCE");
		officeFloorInputManagedObject
		// office floor managed object dependency -> office floor managed object
				"DEPENDENCY_ONE"Connection.class.getName());
		officeFloorManagedObject
				"MO_DEPENDENCY""THREAD");
		officeFloor.addOfficeFloorManagedObject(mo_dependency);
				"MO_DEPENDENCY");
		dependencyOne.setOfficeFloorManagedObject(dependencyToMo);
		// managed object dependency -> input managed object
				"DEPENDENCY_TWO"String.class.getName());
		officeFloorManagedObject
				"INPUT_DEPENDENCY""THREAD");
		officeFloor.addOfficeFloorInputManagedObject(mo_input_dependency);
				"INPUT_DEPENDENCY");
		dependencyTwo.setOfficeFloorInputManagedObject(dependencyToInput);
		// office floor managed object source -> office
				"OFFICE");
		officeFloorManagedObjectSource.setManagingOffice(moSourceToOffice);
		// office floor managed object source -> input managed object
				"INPUT_MANAGED_OBJECT");
		officeFloorManagedObjectSource
		// managed object source input dependency -> managed object
				"INPUT_DEPENDENCY"Connection.class.getName());
		officeFloorManagedObjectSource
				"INPUT_MO_DEPENDENCY""PROCESS");
		officeFloor.addOfficeFloorManagedObject(input_dependency);
				"INPUT_MO_DEPENDENCY");
		inputDependency.setOfficeFloorManagedObject(inputDependencyToMo);
		// office floor managed object source flow -> office input
				"FLOW"Integer.class.getName());
		officeFloorManagedObjectSource
				"OFFICE""SECTION""INPUT");
		flow.setDeployedOfficeInput(flowToInput);
		// office floor managed object source team -> office floor team
				"MO_TEAM");
		officeFloorManagedObjectSource
				"OFFICE_FLOOR_TEAM");
		mosTeam.setOfficeFloorTeam(mosTeamToTeam);
		// office object -> office floor managed object
				"MANAGED_OBJECT");
		officeObject.setOfficeFloorManagedObject(officeObjectToManagedObject);
		// office object -> office floor input managed object
				"INPUT_MANAGED_OBJECT");
		officeObject.setOfficeFloorInputManagedObject(officeObjectToInputMo);
		// office team -> office floor team
				"OFFICE_FLOOR_TEAM");
		officeTeam.setOfficeFloorTeam(officeTeamToFloorTeam);
		// Record retrieving the office
				nullthis.), officeFloor,
					public boolean matches(Object[] expectedObject[] actual) {
						assertTrue("Must be office model",
								actual[0] instanceof OfficeFloorModel);
								"Incorrect configuration item",
								actual[1]);
						return true;
					}
				});
		// Retrieve the office floor
		OfficeFloorModel retrievedOfficeFloor = this.
		assertEquals("Incorrect office"officeFloorretrievedOfficeFloor);
		// Ensure office floor managed object connected to its source
				"office floor managed object <- office floor managed object source",
				officeFloorManagedObjectmoToSource
				"office floor managed object -> office floor managed object source",
				officeFloorManagedObjectSourcemoToSource
		// Ensure input managed object connected to its bound source
		assertEquals("input managed object <- bound managed object source",
				officeFloorInputManagedObjectinputMoToBoundSource
		assertEquals("input managed object -> bound managed object source",
				officeFloorManagedObjectSourceinputMoToBoundSource
		// Ensure managed object dependency to managed object
		assertEquals("dependency <- managed object"dependencyOne,
		assertEquals("dependency -> managed object"mo_dependency,
				dependencyToMo.getOfficeFloorManagedObject());
		// Ensure managed object dependency to input managed object
		assertEquals("dependency <- input managed object"dependencyTwo,
		assertEquals("dependency -> input managed object"mo_input_dependency,
		// Ensure managed object source connected to managing office
		assertEquals("office floor managed object source <- office",
				officeFloorManagedObjectSourcemoSourceToOffice
		assertEquals("office floor managed object source -> office"office,
				moSourceToOffice.getManagingOffice());
		// Ensure managed object source connected to input managed object
				"office floor managed object source <- input managed object",
				officeFloorManagedObjectSourcemoSourceToInputMo
				"office floor managed object source -> input managed object",
				officeFloorInputManagedObjectmoSourceToInputMo
		// Ensure input dependency connected to managed object
		assertEquals("input dependency <- managed object"inputDependency,
		assertEquals("input dependency -> managed object"input_dependency,
				inputDependencyToMo.getOfficeFloorManagedObject());
		// Ensure managed object source flow connected to office input
		assertEquals("office floor managed object source flow <- office input",
		assertEquals("office floor managed object source flow -> office input",
				officeInputflowToInput.getDeployedOfficeInput());
		// Ensure managed object source team connected to office floor team
				"office floor managed object source team <- office floor team",
				mosTeammosTeamToTeam.getOfficeFloorManagedObjectSourceTeam());
				"office floor managed object source team -> office floor team",
				officeFloorTeammosTeamToTeam.getOfficeFloorTeam());
		// Ensure office object connected to office floor managed object
		assertEquals("office object <- office floor managed object",
				officeObjectofficeObjectToManagedObject
		assertEquals("office object -> office floor managed object",
				officeFloorManagedObjectofficeObjectToManagedObject
		// Ensure office object connected to office floor input managed object
		assertEquals("office object <- office floor input managed object",
				officeObjectofficeObjectToInputMo.getDeployedOfficeObject());
		assertEquals("office object -> office floor input managed object",
				officeFloorInputManagedObjectofficeObjectToInputMo
		// Ensure office team connected to office floor team
		assertEquals("office team <- office floor team"officeTeam,
				officeTeamToFloorTeam.getDeployedOfficeTeam());
		assertEquals("office team -> office floor team"officeFloorTeam,
				officeTeamToFloorTeam.getOfficeFloorTeam());
	}

Ensures on storing a net.officefloor.model.officefloor.OfficeFloorModel that all net.officefloor.model.ConnectionModel instances are readied for storing.
	public void testStoreOfficeFloor() throws Exception {
		// Create the office floor (without connections)
		OfficeFloorModel officeFloor = new OfficeFloorModel();
				"MANAGED_OBJECT_SOURCE",
				"net.example.ExampleManagedObjectSource"Connection.class
						.getName(), "0");
		officeFloor
				.addOfficeFloorManagedObjectSource(officeFloorManagedObjectSource);
				"INPUT_MANAGED_OBJECT"Connection.class.getName());
		officeFloor
				.addOfficeFloorInputManagedObject(officeFloorInputManagedObject);
				"MANAGED_OBJECT""THREAD");
		officeFloor.addOfficeFloorManagedObject(officeFloorManagedObject);
		OfficeFloorTeamModel officeFloorTeam = new OfficeFloorTeamModel(
				"OFFICE_FLOOR_TEAM""net.example.ExampleTeamSource");
		officeFloor.addOfficeFloorTeam(officeFloorTeam);
		DeployedOfficeModel office = new DeployedOfficeModel("OFFICE",
				"net.example.ExampleOfficeSource""OFFICE_LOCATION");
		officeFloor.addDeployedOffice(office);
				"SECTION""INPUT"Integer.class.getName());
		office.addDeployedOfficeInput(officeInput);
				"OBJECT"Connection.class.getName());
		office.addDeployedOfficeObject(officeObject);
				"OFFICE_TEAM");
		office.addDeployedOfficeTeam(officeTeam);
		// office floor managed object -> office floor managed object source
		moToSource.setOfficeFloorManagedObject(officeFloorManagedObject);
		moToSource
				.setOfficeFloorManagedObjectSource(officeFloorManagedObjectSource);
		moToSource.connect();
		// input managed object -> bound managed object source
		inputMoToBoundSource
				.setBoundOfficeFloorInputManagedObject(officeFloorInputManagedObject);
		inputMoToBoundSource
				.setBoundOfficeFloorManagedObjectSource(officeFloorManagedObjectSource);
		inputMoToBoundSource.connect();
		// office floor managed object dependency -> office floor managed object
				"DEPENDENCY_TWO"Connection.class.getName());
		officeFloorManagedObject
				"MO_DEPENDENCY""THREAD");
		officeFloor.addOfficeFloorManagedObject(mo_dependency);
		dependencyToMo.setOfficeFloorManagedObjectDependency(dependencyOne);
		dependencyToMo.setOfficeFloorManagedObject(mo_dependency);
		dependencyToMo.connect();
		// managed object dependency -> input managed object
				"DEPENDENCY_TWO"String.class.getName());
		officeFloorManagedObject
				"INPUT_DEPENDENCY""THREAD");
		officeFloor.addOfficeFloorInputManagedObject(mo_input_dependency);
		dependencyToInput.setOfficeFloorManagedObjectDependency(dependencyTwo);
		dependencyToInput.setOfficeFloorInputManagedObject(mo_input_dependency);
		dependencyToInput.connect();
		// office floor managed object source -> office
		moSourceToOffice
				.setOfficeFloorManagedObjectSource(officeFloorManagedObjectSource);
		moSourceToOffice.setManagingOffice(office);
		moSourceToOffice.connect();
		// office floor managed object source -> input managed object
		moSourceToInputMo
				.setOfficeFloorManagedObjectSource(officeFloorManagedObjectSource);
		moSourceToInputMo
				.setOfficeFloorInputManagedObject(officeFloorInputManagedObject);
		moSourceToInputMo.connect();
		// managed object source input dependency -> managed object
				"INPUT_DEPENDENCY"Connection.class.getName());
		officeFloorManagedObjectSource
				"INPUT_MO_DEPENDENCY""PROCESS");
		officeFloor.addOfficeFloorManagedObject(input_dependency);
		inputDependencyToMo
		inputDependencyToMo.setOfficeFloorManagedObject(input_dependency);
		inputDependencyToMo.connect();
		// office floor managed object source flow -> office input
				"FLOW"Integer.class.getName());
		officeFloorManagedObjectSource
		flowToInput.setDeployedOfficeInput(officeInput);
		flowToInput.connect();
		// office floor managed object source team -> office floor team
				"MO_TEAM");
		officeFloorManagedObjectSource
		mosTeamToTeam.setOfficeFloorTeam(officeFloorTeam);
		mosTeamToTeam.connect();
		// office object -> office floor managed object
		officeObjectToManagedObject.setDeployedOfficeObject(officeObject);
		officeObjectToManagedObject
				.setOfficeFloorManagedObject(officeFloorManagedObject);
		officeObjectToManagedObject.connect();
		// office object -> office floor input managed object
		officeObjectToInputMo.setDeployedOfficeObject(officeObject);
		officeObjectToInputMo
				.setOfficeFloorInputManagedObject(officeFloorInputManagedObject);
		officeObjectToInputMo.connect();
		// office team -> office floor team
		officeTeamToFloorTeam.setDeployedOfficeTeam(officeTeam);
		officeTeamToFloorTeam.setOfficeFloorTeam(officeFloorTeam);
		officeTeamToFloorTeam.connect();
		// Record storing the office floor
		this..store(officeFloorthis.);
		// Store the office floor
		// Ensure the connections have links to enable retrieving
				"office floor managed object - office floor managed object source",
				"MANAGED_OBJECT_SOURCE"moToSource
		assertEquals("input managed object - bound managed object source",
				"MANAGED_OBJECT_SOURCE"inputMoToBoundSource
		assertEquals("dependency - managed object""MO_DEPENDENCY",
		assertEquals("dependency - input managed object""INPUT_DEPENDENCY",
		assertEquals("office floor managed object source - office""OFFICE",
				moSourceToOffice.getManagingOfficeName());
				"office floor managed object source - input managed object",
				"INPUT_MANAGED_OBJECT"moSourceToInputMo
		assertEquals("managed object source input dependency - managed object",
				"INPUT_MO_DEPENDENCY"inputDependencyToMo
				"office floor managed object source flow - office input (office)",
				"OFFICE"flowToInput.getDeployedOfficeName());
				"office floor managed object source flow - office input (section)",
				"SECTION"flowToInput.getSectionName());
				"office floor managed object source flow - office input (input)",
				"INPUT"flowToInput.getSectionInputName());
		assertEquals("office floor managed object team - office floor team",
				"OFFICE_FLOOR_TEAM"mosTeamToTeam.getOfficeFloorTeamName());
		assertEquals("office object - office floor managed object",
				"MANAGED_OBJECT"officeObjectToManagedObject
		assertEquals("office object - office floor input managed object",
				"INPUT_MANAGED_OBJECT"officeObjectToInputMo
		assertEquals("office team - office floor team""OFFICE_FLOOR_TEAM",
				officeTeamToFloorTeam.getOfficeFloorTeamName());
	}
New to GrepCode? Check out our FAQ X