Package rinde.sim.core.model.pdp

Examples of rinde.sim.core.model.pdp.Parcel


  public void testPickupFail5() {
    // wrong position
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    model.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 0, 0, 2.0);
    rm.register(pack1);
    rm.addObjectAt(pack1, new Point(0, 0));
    model.register(pack1);
    model.pickup(truck, pack1, TimeLapseFactory.create(0, 1));
  }
View Full Code Here


  public void testPickupFail6A() {
    // package does not fit in truck
    final Vehicle truck = new TestVehicle(new Point(1, 1), 1.0, 1.0);
    rm.register(truck);
    model.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 0, 0, 2.0);
    rm.register(pack1);
    model.register(pack1);
    rm.addObjectAtSamePosition(pack1, truck);
    assertTrue(rm.equalPosition(truck, pack1));
    model.pickup(truck, pack1, TimeLapseFactory.create(0, 100));
View Full Code Here

    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    model.register(truck);

    for (int i = 0; i < 9; i++) {
      final Parcel newPack = new TestParcel(new Point(2, 2), 0, 0, 1.0);
      rm.register(newPack);
      model.register(newPack);
      rm.addObjectAtSamePosition(newPack, truck);
      model.pickup(truck, newPack, TimeLapseFactory.create(0, 1));
    }
    assertEquals(model.getContents(truck).size(), 9);
    assertEquals(model.getContentsSize(truck), 9.0, EPSILON);

    final Parcel packTooMuch = new TestParcel(new Point(2, 2), 0, 0, 1.1);
    rm.register(packTooMuch);
    model.register(packTooMuch);
    rm.addObjectAtSamePosition(packTooMuch, truck);
    boolean fail = false;
    try {
View Full Code Here

  @Test
  public void testDeliver() {
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    model.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 10, 10, 2.0);
    rm.register(pack1);
    model.register(pack1);
    rm.addObjectAtSamePosition(pack1, truck);
    assertTrue(rm.equalPosition(truck, pack1));
    assertEquals(ParcelState.AVAILABLE, model.getParcelState(pack1));
    assertEquals(VehicleState.IDLE, model.getVehicleState(truck));
    assertEquals(newHashSet(pack1), model.getParcels(ParcelState.AVAILABLE));

    model.pickup(truck, pack1, TimeLapseFactory.create(0, 100));
    assertEquals(ParcelState.IN_CARGO, model.getParcelState(pack1));
    assertEquals(VehicleState.IDLE, model.getVehicleState(truck));
    assertTrue(model.getParcels(ParcelState.AVAILABLE).isEmpty());

    rm.moveTo(truck, pack1.getDestination(),
        TimeLapseFactory.create(0, 3600000 * 3));
    assertEquals(pack1.getDestination(), rm.getPosition(truck));

    model.deliver(truck, pack1, TimeLapseFactory.create(0, 8));
    assertEquals(ParcelState.DELIVERING, model.getParcelState(pack1));
    assertEquals(VehicleState.DELIVERING, model.getVehicleState(truck));

    final TimeLapse tl = TimeLapseFactory.create(0, 10);
    model.continuePreviousActions(truck, tl);
    assertEquals(ParcelState.DELIVERED, model.getParcelState(pack1));
    assertEquals(VehicleState.IDLE, model.getVehicleState(truck));
    assertEquals(8, tl.getTimeLeft());

    final Parcel pack2 = new TestParcel(new Point(2, 2), 10, 10, 2.0);
    rm.register(pack2);
    model.register(pack2);
    rm.addObjectAtSamePosition(pack2, truck);
    assertEquals(ParcelState.AVAILABLE, model.getParcelState(pack2));
    assertEquals(VehicleState.IDLE, model.getVehicleState(truck));
View Full Code Here

  @Test(expected = IllegalArgumentException.class)
  public void testDeliverFail2() {
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    model.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 10, 10, 2.0);
    rm.register(pack1);
    model.register(pack1);
    rm.addObjectAtSamePosition(pack1, truck);

    model.pickup(truck, pack1, TimeLapseFactory.create(0, 1));
View Full Code Here

  @Test(expected = IllegalArgumentException.class)
  public void testDeliverFail3() {
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    model.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 10, 10, 2.0);
    rm.register(pack1);
    model.register(pack1);
    rm.addObjectAtSamePosition(pack1, truck);

    model.deliver(truck, pack1, TimeLapseFactory.create(0, 1));
View Full Code Here

  @Test(expected = IllegalArgumentException.class)
  public void testDeliverFail4() {
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    model.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 10, 10, 2.0);
    rm.register(pack1);
    model.register(pack1);
    rm.addObjectAtSamePosition(pack1, truck);

    model.pickup(truck, pack1, TimeLapseFactory.create(0, 10));
View Full Code Here

  @Test
  public void addPackageIn() {
    assertTrue(model.getParcels(ParcelState.AVAILABLE).isEmpty());
    final Depot d = new TestDepot(10);
    final Parcel p1 = new TestParcel(new Point(0, 0), 0, 0, 1);
    model.register(d);
    model.register(p1);
    rm.addObjectAt(d, new Point(0, 0));
    model.addParcelIn(d, p1);
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void addPackageInFail1() {
    final Depot d = new TestDepot(10);
    final Parcel p1 = new TestParcel(new Point(0, 0), 0, 0, 1);
    rm.addObjectAt(p1, new Point(0, 0));
    model.addParcelIn(d, p1);
  }
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void addPackageInFail2() {
    final Depot d = new TestDepot(10);
    final Parcel p1 = new TestParcel(new Point(0, 0), 0, 0, 1);
    model.addParcelIn(d, p1);
  }
View Full Code Here

TOP

Related Classes of rinde.sim.core.model.pdp.Parcel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.