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.desk;
 
 import java.util.List;
 import java.util.Map;
 
Abstract functionality to test refactoring the net.officefloor.model.desk.WorkModel to a net.officefloor.compile.work.WorkType via the net.officefloor.model.desk.DeskChanges.

Author(s):
Daniel Sagenschneider
 
 public abstract class AbstractRefactorWorkTest extends
 
 	private WorkModel workModel;

Name to refactor the net.officefloor.model.desk.WorkModel to have.
 
 	private String workName;

 
 
 	private PropertyList properties = null;

 
 	private final Map<StringStringworkTaskNameMapping = new HashMap<StringString>();

 
 	private final Map<StringMap<StringString>> workTaskToObjectNameMapping = new HashMap<StringMap<StringString>>();

 
 	private final Map<StringMap<StringString>> taskToFlowNameMapping = new HashMap<StringMap<StringString>>();

 
 	private final Map<StringMap<StringString>> taskToEscalationTypeMapping = new HashMap<StringMap<StringString>>();

 
 	private String[] tasks = null;

Initiate for specific setup per test.
		super(true);
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see net.officefloor.model.impl.AbstractChangesTestCase#setUp()
	 */
	protected void setUp() throws Exception {
		// Setup the model
		super.setUp();
		// Obtain work model and specify details from it
		this. = this..getWorks().get(0);
	}

Flags to refactor the name of the net.officefloor.model.desk.WorkModel.

Parameters:
workName New name for the net.officefloor.model.desk.WorkModel.
	protected void refactor_workName(String workName) {
		this. = workName;
	}

	protected void refactor_workSourceClassName(String workSourceClassName) {
		this. = workSourceClassName;
	}

	protected void refactor_addProperty(String nameString value) {
		// Lazy create the property list
		if (this. == null) {
		}
		// Add the property
		this..addProperty(name).setValue(value);
	}

	protected void refactor_mapTask(String taskTypeName,
			String workTaskModelName) {
		this..put(taskTypeNameworkTaskModelName);
	}

	protected void refactor_mapObject(String workTaskName,
			String objectTypeNameString workTaskObjectName) {
		this.map(workTaskNameobjectTypeNameworkTaskObjectName,
	}

	protected void refactor_mapFlow(String taskNameString flowTypeName,
			String taskFlowName) {
		this.map(taskNameflowTypeNametaskFlowName,
	}

	protected void refactor_mapEscalation(String taskName,
			String escalationTypeNameString taskEscalationName) {
		this.map(taskNameescalationTypeNametaskEscalationName,
	}

Maps in the values.

Parameters:
a First value.
b Second value.
c Third value.
map Map to have values loaded.
	private void map(String aString bString c,
			Map<StringMap<StringString>> map) {
		// Obtain map by a
		Map<StringStringaMap = map.get(a);
		if (aMap == null) {
			aMap = new HashMap<StringString>();
			map.put(aaMap);
		}
		// Load b and c to aMap
		aMap.put(bc);
	}

Specifies the names of the net.officefloor.compile.work.TaskType instances to include on the net.officefloor.model.desk.WorkModel.

Parameters:
taskNames Names of the net.officefloor.compile.work.TaskType instances to include on the net.officefloor.model.desk.WorkModel.
	protected void refactor_includeTasks(String... taskNames) {
		this. = taskNames;
	}

Convenience method to do refactoring with a simple net.officefloor.compile.work.WorkType.
	protected void doRefactor() {
		this.doRefactor((WorkType<?>) null);
	}

Convenience method to do refactoring and validates applying and reverting.

Parameters:
workTypeConstructor AbstractDeskChangesTestCase.WorkTypeConstructor.
	protected void doRefactor(WorkTypeConstructor workTypeConstructor) {
		// Construct the work type
		WorkType<?> workType = this.constructWorkType(workTypeConstructor);
		// Do the refactoring
		this.doRefactor(workType);
	}

Does the refactoring and validates applying and reverting.

	protected void doRefactor(WorkType<?> workType) {
		// Ensure have a work type
		if (workType == null) {
			// Create simple work type
			workType = this.constructWorkType(new WorkTypeConstructor() {
				public void construct(WorkTypeContext context) {
					// Simple work type
				}
			});
		}
		// Create the property list
		PropertyList propertyList = this.;
		if (propertyList == null) {
			// Not refactoring properties, so take from work model
			propertyList = new PropertyListImpl();
			for (PropertyModel property : this..getProperties()) {
				propertyList.addProperty(property.getName()).setValue(
						property.getValue());
			}
		}
		// Create the listing of tasks
		String[] taskNames = this.;
		if (taskNames == null) {
			// Not refactoring tasks, so take from work model
			List<StringtaskNameList = new LinkedList<String>();
			for (WorkTaskModel workTask : this..getWorkTasks()) {
				taskNameList.add(workTask.getWorkTaskName());
			}
			taskNames = taskNameList.toArray(new String[0]);
		}
		// Create the change to refactor
				this.this.propertyList,
				workTypethis.,
				this.taskNames);
		// Asset the refactoring changes
		this.assertChange(changethis."Refactor work"true);
	}
New to GrepCode? Check out our FAQ X