blob: b3c304bbef1785400cc464400e70e5fd54b2de4e [file] [log] [blame]
package org.metaabm.gen.test;
/**
* Complex Location Java Implementation.
*
* Generated by metaabm system: May 13, 2009 11:53:50 AM PDT in project: org.metaabm.gen.repast.test (testing) */
import static org.junit.Assert.*;
public class ComplexLocation {
/**
*
*/
private boolean locationGood = false;
/**
* Constructs a new Complex Location.
*/
public ComplexLocation() {
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 {
ComplexLocation clone = (ComplexLocation) super.clone();
clone.createUniqueID();
return clone;
} catch (Exception e) {
throw new RuntimeException("Unexpected cloning exception: " + e);
}
}
@org.junit.Test
public void dummy() {
assertTrue(true);
}
/**
*
*/
private SpatialModel spatialModelList = null;
/**
* Gets the Spatial Model property for .
* @return
*/
public SpatialModel getSpatialModel() {
return spatialModelList;
}
/**
* Sets the Spatial Model property for .
*
* @param _spatialModel the new Spatial Model value
*/
public void setSpatialModel(SpatialModel _spatialModel) {
spatialModelList = _spatialModel;
}
public double randomInRange(double minValue, double maxValue) {
return repast.simphony.random.RandomHelper.nextDoubleFromTo(minValue,
maxValue);
}
public double randomToLimit(double maxValue) {
return repast.simphony.random.RandomHelper.nextDoubleFromTo(0.0,
maxValue);
}
public int randomToLimit(int maxValue) {
return repast.simphony.random.RandomHelper.nextIntFromTo(0, maxValue);
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -0)
public void testSelfAvailableCreate() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context
.getProjection("Grid 2D");
/*PROTECTED REGION ID(ComplexLocation_testSelfAvailableCreate_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
ComplexMovementAgent createAgents = null;
for (int i = 0; i < 1; i++) {
createAgents = new ComplexMovementAgent();
context.add(createAgents);
createAgents.setSpatialModel(this);
}
int[] movetoLocationinGrid2DLoc = grid2D.getLocation(this)
.toIntArray(null);
grid2D.moveTo(createAgents, movetoLocationinGrid2DLoc);
}
/*PROTECTED REGION ID(ComplexLocation_testSelfAvailableCreate_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -4)
public void testSelfAvailableWithin() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context
.getProjection("Grid 2D");
/*PROTECTED REGION ID(ComplexLocation_testSelfAvailableWithin_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
setLocationGood(true);
}
/*PROTECTED REGION ID(ComplexLocation_testSelfAvailableWithin_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -9)
public void testAgentHere() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context
.getProjection("Grid 2D");
/*PROTECTED REGION ID(ComplexLocation_testAgentHere_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> agentHereQueryQuery = null;
repast.simphony.query.Query<Object> agentHereQueryQueryAgentClass = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
return (object instanceof ComplexMovementAgent);
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
agentHereQueryQuery = new repast.simphony.query.AndQuery<Object>(
agentHereQueryQuery, agentHereQueryQueryAgentClass);
java.util.Iterator agentHereQueryIter = agentHereQueryQuery.query()
.iterator();
if (agentHereQueryIter.hasNext()) {
java.util.List agentHereQueryList = org.apache.commons.collections15.IteratorUtils
.toList(agentHereQueryIter);
final ComplexMovementAgent agent = (ComplexMovementAgent) agentHereQueryList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0, agentHereQueryList.size() - 1));
agent.setSomeBoolean(true);
}
}
/*PROTECTED REGION ID(ComplexLocation_testAgentHere_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -13)
public void testSelfAvailable() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context
.getProjection("Grid 2D");
/*PROTECTED REGION ID(ComplexLocation_testSelfAvailable_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
setLocationGood(true);
}
/*PROTECTED REGION ID(ComplexLocation_testSelfAvailable_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -16)
public void testSelfWithinBounds() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context
.getProjection("Grid 2D");
/*PROTECTED REGION ID(ComplexLocation_testSelfWithinBounds_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
setLocationGood(true);
}
/*PROTECTED REGION ID(ComplexLocation_testSelfWithinBounds_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* Gets the Location Good property for Complex Location.
* @return
*/
@repast.simphony.parameter.Parameter(displayName = "Location Good", usageName = "locationGood", defaultValue = "false")
public boolean isLocationGood() {
return locationGood;
}
/**
* Sets the Location Good property for Complex Location.
*
* @param _locationGood the new Location Good value
*/
public void setLocationGood(boolean _locationGood) {
locationGood = _locationGood;
}
}