| /** |
| * <copyright> |
| * |
| * Copyright (c) 2009 Metascape, LLC. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Metascape - Initial API and Implementation |
| * |
| * </copyright> |
| * |
| */ |
| package org.metaabm.gen.test; |
| |
| /** |
| * Basic Movement Agent Java Implementation. |
| * |
| * Generated by metaabm system: May 12, 2009 7:32:33 PM PDT in project: org.metaabm.gen.test (testing) */ |
| |
| import static org.junit.Assert.*; |
| |
| public class BasicMovementAgent { |
| |
| /** |
| * |
| */ |
| |
| private int vision = 20; |
| /** |
| * |
| */ |
| |
| private boolean movingTowardGoal = true; |
| /** |
| * |
| */ |
| |
| private boolean success = false; |
| /** |
| * Constructs a new Basic Movement Agent. |
| */ |
| |
| public BasicMovementAgent() { |
| createUniqueID(); |
| } |
| //todo, make this a useful value for evaluating compatibility of different versions of generated classes |
| private static final long serialVersionUID = 89989998L; |
| |
| private String uniqueID; |
| |
| public String getUID() { |
| return uniqueID; |
| } |
| |
| public void createUniqueID() { |
| uniqueID = org.apache.commons.lang.RandomStringUtils |
| .randomAlphanumeric(5); |
| } |
| |
| /** |
| * Clones the agent, ensuring that a unique id is assigned. |
| */ |
| public Object clone() { |
| try { |
| BasicMovementAgent clone = (BasicMovementAgent) super.clone(); |
| clone.createUniqueID(); |
| return clone; |
| } catch (Exception e) { |
| throw new RuntimeException("Unexpected cloning exception: " + e); |
| } |
| } |
| |
| @org.junit.Test |
| public void dummy() { |
| assertTrue(true); |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveToRandomAvailable() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToRandomAvailable_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| /* |
| Spatial Functions: |
| [available] |
| */ |
| BasicCell availableCell = new BasicCell(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToRandomAvailable_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveToRandomNoAvailableCheck() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToRandomNoAvailableCheck_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| /* |
| Spatial Functions: |
| [] |
| */ |
| BasicMovementAgent basicMovementAgentCopyCopyCopy = new BasicMovementAgent(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToRandomNoAvailableCheck_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveToNeighbor() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToNeighbor_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| /* |
| Spatial Functions: |
| [neighbor] |
| */ |
| BasicCell neighboringSpace = new BasicCell(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToNeighbor_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveToAvailableNeighbor() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToAvailableNeighbor_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| /* |
| Spatial Functions: |
| [neighbor, available] |
| */ |
| BasicCell basicMovementAgentCopy = new BasicCell(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToAvailableNeighbor_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveToNearestGoal() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToNearestGoal_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| if (isMovingTowardGoal()) { |
| { |
| /* |
| Evaluation: |
| Expression: |
| goalinArea.isGoal2() |
| */ |
| |
| /* |
| Spatial Functions: |
| [nearest] |
| */ |
| BasicCell goalinArea = new BasicCell(); |
| |
| } |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToNearestGoal_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveTowardNearestAgent() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveTowardNearestAgent_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| /* |
| Spatial Functions: |
| [toward, nearest] |
| */ |
| BasicMovementAgent otherPerson = new BasicMovementAgent(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveTowardNearestAgent_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveTowardNearestGoal() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveTowardNearestGoal_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| /* |
| Evaluation: |
| Expression: |
| selectNearestToward.isGoal2() |
| */ |
| |
| /* |
| Spatial Functions: |
| [nearest, toward] |
| */ |
| BasicCell selectNearestToward = new BasicCell(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveTowardNearestGoal_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveWithEvaluate() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveWithEvaluate_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| /* |
| Evaluation: |
| int totalVision = getVision()+actPerson1.getVision(); |
| Expression: |
| totalVision>actPerson1.getBasicMovementModel().getAreaCount() |
| */ |
| |
| /* |
| Spatial Functions: |
| [neighbor] |
| */ |
| BasicMovementAgent actPerson1 = new BasicMovementAgent(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveWithEvaluate_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveTwice() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveTwice_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| if (isMovingTowardGoal()) { |
| |
| { |
| /* |
| Evaluation: |
| Expression: |
| goalinArea2.isGoal() |
| */ |
| |
| /* |
| Spatial Functions: |
| [nearest] |
| */ |
| BasicCell goalinArea2 = new BasicCell(); |
| |
| { |
| /* |
| Evaluation: |
| Expression: |
| closestNearGoal.isGoal2() |
| */ |
| |
| /* |
| Spatial Functions: |
| [nearest] |
| */ |
| BasicCell closestNearGoal = new BasicCell(); |
| |
| } |
| |
| } |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveTwice_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void andWithOrGoal() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_andWithOrGoal_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| /* |
| Evaluation: |
| Expression: |
| (andOrAgent.isGoal()||andOrAgent.isGoal2()) |
| */ |
| |
| /* |
| Spatial Functions: |
| [nearest] |
| */ |
| BasicCell andOrAgent = new BasicCell(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_andWithOrGoal_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void andWithAndGoal() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_andWithAndGoal_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| /* |
| Evaluation: |
| Expression: |
| (andAndAgent.isGoal()&&andAndAgent.isGoal2()) |
| */ |
| |
| /* |
| Spatial Functions: |
| [nearest] |
| */ |
| BasicCell andAndAgent = new BasicCell(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_andWithAndGoal_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void moveToGoalWithin() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToGoalWithin_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| /* |
| Evaluation: |
| Expression: |
| areaWithGoal.isGoal() |
| */ |
| |
| /* |
| Spatial Functions: |
| [within] |
| */ |
| BasicCell areaWithGoal = new BasicCell(); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_moveToGoalWithin_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void setConditionNeighbor() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_setConditionNeighbor_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| /* |
| Evaluation: |
| Expression: |
| basicMovementAgent.isSuccess() |
| */ |
| |
| /* |
| Spatial Functions: |
| [neighbor] |
| */ |
| BasicMovementAgent basicMovementAgent = new BasicMovementAgent(); |
| |
| basicMovementAgent.setSuccess(true); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_setConditionNeighbor_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void setConditionStateAgentNeighbor() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_setConditionStateAgentNeighbor_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| /* |
| Evaluation: |
| Expression: |
| setStateConditionNeighbor.getState()==StateEnum.option1 |
| */ |
| |
| /* |
| Spatial Functions: |
| [within] |
| */ |
| BasicMovementStateAgent setStateConditionNeighbor = new BasicMovementStateAgent(); |
| |
| setStateConditionNeighbor.setState(StateEnum.option2); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_setConditionStateAgentNeighbor_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| public void setRandomNeighborValue() { |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_setRandomNeighborValue_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| /* |
| Spatial Functions: |
| [neighbor] |
| */ |
| BasicMovementAgent basicMovementAgentCopyCopy = new BasicMovementAgent(); |
| |
| basicMovementAgentCopyCopy.setSuccess(true); |
| |
| } |
| |
| /*PROTECTED REGION ID(BasicMovementAgent_setRandomNeighborValue_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| /** |
| * Gets the Vision property for Basic Movement Agent. |
| * @return |
| */ |
| |
| public int getVision() { |
| return vision; |
| } |
| |
| /** |
| * Sets the Vision property for Basic Movement Agent. |
| * |
| * @param _vision the new Vision value |
| */ |
| |
| public void setVision(int _vision) { |
| vision = _vision; |
| } |
| /** |
| * Gets the Moving Toward Goal property for Basic Movement Agent. |
| * @return |
| */ |
| |
| public boolean isMovingTowardGoal() { |
| return movingTowardGoal; |
| } |
| |
| /** |
| * Sets the Moving Toward Goal property for Basic Movement Agent. |
| * |
| * @param _movingTowardGoal the new Moving Toward Goal value |
| */ |
| |
| public void setMovingTowardGoal(boolean _movingTowardGoal) { |
| movingTowardGoal = _movingTowardGoal; |
| } |
| /** |
| * Gets the Success property for Basic Movement Agent. |
| * @return |
| */ |
| |
| public boolean isSuccess() { |
| return success; |
| } |
| |
| /** |
| * Sets the Success property for Basic Movement Agent. |
| * |
| * @param _success the new Success value |
| */ |
| |
| public void setSuccess(boolean _success) { |
| success = _success; |
| } |
| } |