mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add and test feature #127
This commit is contained in:
parent
ebff6ff50e
commit
9971d3d349
14 changed files with 397 additions and 177 deletions
|
|
@ -47,7 +47,25 @@ public class VrpXMLReaderTest {
|
|||
public void doBefore(){
|
||||
inFileName = "src/test/resources/finiteVrpForReaderTest.xml";
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldReadNameOfService(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s = (Service) vrp.getJobs().get("1");
|
||||
assertTrue(s.getName().equals("cleaning"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReadNameOfShipment(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertTrue(s.getName().equals("deliver-smth"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVrp_problemTypeIsReadCorrectly(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
|
|
@ -482,7 +500,7 @@ public class VrpXMLReaderTest {
|
|||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals("i(9,9)",s.getDeliveryLocation());
|
||||
assertEquals("i(9,9)",s.getDeliveryLocationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -491,7 +509,7 @@ public class VrpXMLReaderTest {
|
|||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals("i(3,9)",s.getPickupLocation());
|
||||
assertEquals("i(3,9)",s.getPickupLocationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -500,7 +518,7 @@ public class VrpXMLReaderTest {
|
|||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("4");
|
||||
assertEquals("[x=10.0][y=10.0]",s.getPickupLocation());
|
||||
assertEquals("[x=10.0][y=10.0]",s.getPickupLocationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -509,7 +527,7 @@ public class VrpXMLReaderTest {
|
|||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("4");
|
||||
assertEquals("[x=10.0][y=0.0]",s.getDeliveryLocation());
|
||||
assertEquals("[x=10.0][y=0.0]",s.getDeliveryLocationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
|
@ -46,8 +46,7 @@ public class VrpXMLWriterTest {
|
|||
public void doBefore(){
|
||||
infileName = "src/test/resources/infiniteWriterV2Test.xml";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void whenWritingInfiniteVrp_itWritesCorrectly(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
|
|
@ -120,6 +119,36 @@ public class VrpXMLWriterTest {
|
|||
assertEquals("service", s1_read.getType());
|
||||
assertEquals(2.0,s1_read.getServiceDuration(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldWriteNameOfService(){
|
||||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
Service s1 = Service.Builder.newInstance("1").setName("cleaning").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
|
||||
|
||||
VehicleRoutingProblem vrp = builder.addJob(s1).build();
|
||||
new VrpXMLWriter(vrp, null).write(infileName);
|
||||
|
||||
VehicleRoutingProblem.Builder vrpToReadBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpToReadBuilder, null).read(infileName);
|
||||
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
|
||||
Service s1_read = (Service) readVrp.getJobs().get("1");
|
||||
assertTrue(s1_read.getName().equals("cleaning"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldWriteNameOfShipment(){
|
||||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").setName("cleaning").setPickupLocationId("pick").setDeliveryLocationId("del").build();
|
||||
|
||||
VehicleRoutingProblem vrp = builder.addJob(s1).build();
|
||||
new VrpXMLWriter(vrp, null).write(infileName);
|
||||
|
||||
VehicleRoutingProblem.Builder vrpToReadBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpToReadBuilder, null).read(infileName);
|
||||
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
|
||||
Shipment s1_read = (Shipment) readVrp.getJobs().get("1");
|
||||
assertTrue(s1_read.getName().equals("cleaning"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenWritingServicesWithSeveralCapacityDimensions_itWritesThemCorrectly(){
|
||||
|
|
@ -159,9 +188,9 @@ public class VrpXMLWriterTest {
|
|||
builder.addVehicle(v1);
|
||||
builder.addVehicle(v2);
|
||||
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
|
||||
|
||||
|
||||
|
|
@ -173,8 +202,8 @@ public class VrpXMLWriterTest {
|
|||
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
|
||||
assertEquals(2,readVrp.getJobs().size());
|
||||
|
||||
assertEquals("pickLoc",((Shipment)readVrp.getJobs().get("1")).getPickupLocation());
|
||||
assertEquals("delLoc",((Shipment)readVrp.getJobs().get("1")).getDeliveryLocation());
|
||||
assertEquals("pickLoc",((Shipment)readVrp.getJobs().get("1")).getPickupLocationId());
|
||||
assertEquals("delLoc",((Shipment)readVrp.getJobs().get("1")).getDeliveryLocationId());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -190,9 +219,9 @@ public class VrpXMLWriterTest {
|
|||
builder.addVehicle(v1);
|
||||
builder.addVehicle(v2);
|
||||
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
|
||||
|
||||
|
||||
|
|
@ -222,9 +251,9 @@ public class VrpXMLWriterTest {
|
|||
builder.addVehicle(v1);
|
||||
builder.addVehicle(v2);
|
||||
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
|
||||
|
||||
|
||||
|
|
@ -253,9 +282,9 @@ public class VrpXMLWriterTest {
|
|||
builder.addVehicle(v1);
|
||||
builder.addVehicle(v2);
|
||||
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
|
||||
|
||||
|
||||
|
|
@ -284,9 +313,9 @@ public class VrpXMLWriterTest {
|
|||
builder.addVehicle(v1);
|
||||
builder.addVehicle(v2);
|
||||
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
|
||||
|
||||
|
||||
|
|
@ -298,7 +327,7 @@ public class VrpXMLWriterTest {
|
|||
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
|
||||
assertEquals(2,readVrp.getJobs().size());
|
||||
|
||||
assertEquals("[x=1.0][y=2.0]",((Shipment)readVrp.getJobs().get("1")).getPickupLocation());
|
||||
assertEquals("[x=1.0][y=2.0]",((Shipment)readVrp.getJobs().get("1")).getPickupLocationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -403,7 +432,7 @@ public class VrpXMLWriterTest {
|
|||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
|
||||
Shipment s = Shipment.Builder.newInstance("1").addRequiredSkill("skill1").addRequiredSkill("skill2").addRequiredSkill("skill3")
|
||||
.addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
|
||||
|
||||
VehicleRoutingProblem vrp = builder.addJob(s).build();
|
||||
|
|
@ -421,7 +450,7 @@ public class VrpXMLWriterTest {
|
|||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
|
||||
Shipment s = Shipment.Builder.newInstance("1").addRequiredSkill("skill1").addRequiredSkill("skill2").addRequiredSkill("skill3")
|
||||
.addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
|
||||
|
||||
VehicleRoutingProblem vrp = builder.addJob(s).build();
|
||||
|
|
@ -439,7 +468,7 @@ public class VrpXMLWriterTest {
|
|||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
|
||||
Shipment s = Shipment.Builder.newInstance("1").addRequiredSkill("skill1").addRequiredSkill("Skill2").addRequiredSkill("skill3")
|
||||
.addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
|
||||
|
||||
VehicleRoutingProblem vrp = builder.addJob(s).build();
|
||||
|
|
@ -457,7 +486,7 @@ public class VrpXMLWriterTest {
|
|||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
|
||||
Shipment s = Shipment.Builder.newInstance("1").addRequiredSkill("skill1").addRequiredSkill("Skill2").addRequiredSkill("skill3")
|
||||
.addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
|
||||
|
||||
VehicleRoutingProblem vrp = builder.addJob(s).build();
|
||||
|
|
@ -482,9 +511,9 @@ public class VrpXMLWriterTest {
|
|||
builder.addVehicle(v1);
|
||||
builder.addVehicle(v2);
|
||||
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
|
||||
|
||||
|
||||
|
|
@ -508,13 +537,13 @@ public class VrpXMLWriterTest {
|
|||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
|
||||
Shipment s1 = Shipment.Builder.newInstance("1")
|
||||
.setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50)
|
||||
.addSizeDimension(0, 10)
|
||||
.addSizeDimension(2, 100)
|
||||
.build();
|
||||
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
|
||||
|
||||
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.job;
|
||||
|
||||
|
|
@ -81,5 +79,12 @@ public class DeliveryTest {
|
|||
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameShouldBeAssigned(){
|
||||
Delivery s = (Delivery) Delivery.Builder.newInstance("s").setLocationId("loc")
|
||||
.setName("name").build();
|
||||
assertEquals("name", s.getName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.job;
|
||||
|
||||
|
|
@ -82,5 +80,12 @@ public class PickupTest {
|
|||
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameShouldBeAssigned(){
|
||||
Pickup s = (Pickup) Pickup.Builder.newInstance("s").setLocationId("loc")
|
||||
.setName("name").build();
|
||||
assertEquals("name",s.getName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
|
@ -167,4 +167,11 @@ public class ServiceTest {
|
|||
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameShouldBeAssigned(){
|
||||
Service s = (Service) Service.Builder.newInstance("s").setLocationId("loc")
|
||||
.setName("name").build();
|
||||
assertEquals("name",s.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.job;
|
||||
|
||||
|
|
@ -28,47 +26,47 @@ public class ShipmentTest {
|
|||
|
||||
@Test
|
||||
public void whenTwoShipmentsHaveTheSameId_theyReferencesShouldBeUnEqual(){
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
|
||||
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
|
||||
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
|
||||
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
|
||||
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
|
||||
assertTrue(one != two);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenTwoShipmentsHaveTheSameId_theyShouldBeEqual(){
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
|
||||
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
|
||||
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
|
||||
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
|
||||
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
|
||||
assertTrue(one.equals(two));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenShipmentIsInstantiatedWithASizeOf10_theSizeShouldBe10(){
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
|
||||
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
|
||||
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
|
||||
assertEquals(10,one.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException_v2(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenIdIsNull_itShouldThrowException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment one = Shipment.Builder.newInstance(null).addSizeDimension(0, 10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
|
||||
Shipment one = Shipment.Builder.newInstance(null).addSizeDimension(0, 10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -80,30 +78,30 @@ public class ShipmentTest {
|
|||
@Test(expected=IllegalStateException.class)
|
||||
public void whenNeitherPickupLocationIdNorPickupCoord_itThrowsException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").build();
|
||||
}
|
||||
|
||||
@Test(expected=IllegalStateException.class)
|
||||
public void whenNeitherDeliveryLocationIdNorDeliveryCoord_itThrowsException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPickupLocationIdIsSet_itShouldBeDoneCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
assertEquals("pickLoc",s.getPickupLocation());
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals("pickLoc",s.getPickupLocationId());
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenPickupLocationIsNull_itThrowsException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment.Builder builder = Shipment.Builder.newInstance("s").setPickupLocation(null);
|
||||
Shipment.Builder builder = Shipment.Builder.newInstance("s").setPickupLocationId(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPickupCoordIsSet_itShouldBeDoneCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setPickupCoord(Coordinate.newInstance(1, 2)).build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").setPickupCoord(Coordinate.newInstance(1, 2)).build();
|
||||
assertEquals(1.0,s.getPickupCoord().getX(),0.01);
|
||||
assertEquals(2.0,s.getPickupCoord().getY(),0.01);
|
||||
}
|
||||
|
|
@ -116,19 +114,19 @@ public class ShipmentTest {
|
|||
|
||||
@Test
|
||||
public void whenDeliveryLocationIdIsSet_itShouldBeDoneCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
assertEquals("delLoc",s.getDeliveryLocation());
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals("delLoc",s.getDeliveryLocationId());
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenDeliveryLocationIsNull_itThrowsException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment.Builder builder = Shipment.Builder.newInstance("s").setDeliveryLocation(null);
|
||||
Shipment.Builder builder = Shipment.Builder.newInstance("s").setDeliveryLocationId(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDeliveryCoordIsSet_itShouldBeDoneCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setDeliveryCoord(Coordinate.newInstance(1, 2)).build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").setDeliveryCoord(Coordinate.newInstance(1, 2)).build();
|
||||
assertEquals(1.0,s.getDeliveryCoord().getX(),0.01);
|
||||
assertEquals(2.0,s.getDeliveryCoord().getY(),0.01);
|
||||
}
|
||||
|
|
@ -141,43 +139,43 @@ public class ShipmentTest {
|
|||
|
||||
@Test
|
||||
public void whenPickupServiceTimeIsNotSet_itShouldBeZero(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals(0.0,s.getPickupServiceTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDeliveryServiceTimeIsNotSet_itShouldBeZero(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals(0.0,s.getDeliveryServiceTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPickupServiceTimeIsSet_itShouldBeDoneCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals(2.0,s.getPickupServiceTime(),0.01);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenPickupServiceIsSmallerThanZero_itShouldThrowException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(-2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDeliveryServiceTimeIsSet_itShouldBeDoneCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals(2.0,s.getDeliveryServiceTime(),0.01);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenDeliveryServiceIsSmallerThanZero_itShouldThrowException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(-2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPickupTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals(0.0,s.getPickupTimeWindow().getStart(),0.01);
|
||||
assertEquals(Double.MAX_VALUE,s.getPickupTimeWindow().getEnd(),0.01);
|
||||
}
|
||||
|
|
@ -185,19 +183,19 @@ public class ShipmentTest {
|
|||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenPickupTimeWindowIsNull_itShouldThrowException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(null).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPickupTimeWindowIsSet_itShouldBeDoneCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals(1.0,s.getPickupTimeWindow().getStart(),0.01);
|
||||
assertEquals(2.0,s.getPickupTimeWindow().getEnd(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDeliveryTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals(0.0,s.getDeliveryTimeWindow().getStart(),0.01);
|
||||
assertEquals(Double.MAX_VALUE,s.getDeliveryTimeWindow().getEnd(),0.01);
|
||||
}
|
||||
|
|
@ -205,12 +203,12 @@ public class ShipmentTest {
|
|||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenDeliveryTimeWindowIsNull_itShouldThrowException(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(null).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDeliveryTimeWindowIsSet_itShouldBeDoneCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||
Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
|
||||
assertEquals(1.0,s.getDeliveryTimeWindow().getStart(),0.01);
|
||||
assertEquals(2.0,s.getDeliveryTimeWindow().getEnd(),0.01);
|
||||
}
|
||||
|
|
@ -218,14 +216,14 @@ public class ShipmentTest {
|
|||
@Test(expected=IllegalArgumentException.class)
|
||||
public void whenShipmentHasNegativeCapacityVal_throwIllegalStateExpception(){
|
||||
@SuppressWarnings("unused")
|
||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setDeliveryLocation("foofoo")
|
||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setDeliveryLocationId("foofoo")
|
||||
.addSizeDimension(0, -2)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setDeliveryLocation("foofoo")
|
||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setDeliveryLocationId("foofoo")
|
||||
.addSizeDimension(0,2)
|
||||
.addSizeDimension(1,4)
|
||||
.build();
|
||||
|
|
@ -234,23 +232,23 @@ public class ShipmentTest {
|
|||
|
||||
@Test
|
||||
public void whenShipmentIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
|
||||
.setDeliveryLocation("foofoo").build();
|
||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setPickupCoord(Coordinate.newInstance(0, 0))
|
||||
.setDeliveryLocationId("foofoo").build();
|
||||
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||
assertEquals(0,one.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenShipmentIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
|
||||
.setDeliveryLocation("foofoo").build();
|
||||
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("foo").setPickupCoord(Coordinate.newInstance(0, 0))
|
||||
.setDeliveryLocationId("foofoo").build();
|
||||
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||
assertEquals(1,one.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAddingSkills_theyShouldBeAddedCorrectly(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation("loc").setDeliveryLocation("delLoc")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("delLoc")
|
||||
.addRequiredSkill("drill").addRequiredSkill("screwdriver").build();
|
||||
assertTrue(s.getRequiredSkills().containsSkill("drill"));
|
||||
assertTrue(s.getRequiredSkills().containsSkill("drill"));
|
||||
|
|
@ -259,7 +257,7 @@ public class ShipmentTest {
|
|||
|
||||
@Test
|
||||
public void whenAddingSkillsCaseSens_theyShouldBeAddedCorrectly(){
|
||||
Delivery s = (Delivery) Delivery.Builder.newInstance("s").setLocationId("loc")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("pick").setDeliveryLocationId("del")
|
||||
.addRequiredSkill("DriLl").addRequiredSkill("screwDriver").build();
|
||||
assertTrue(s.getRequiredSkills().containsSkill("drill"));
|
||||
assertTrue(s.getRequiredSkills().containsSkill("drilL"));
|
||||
|
|
@ -267,9 +265,16 @@ public class ShipmentTest {
|
|||
|
||||
@Test
|
||||
public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly(){
|
||||
Delivery s = (Delivery) Delivery.Builder.newInstance("s").setLocationId("loc")
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("del")
|
||||
.addRequiredSkill("screwDriver").build();
|
||||
assertFalse(s.getRequiredSkills().containsSkill("drill"));
|
||||
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameShouldBeAssigned(){
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("del")
|
||||
.setName("name").build();
|
||||
assertEquals("name",s.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Copyright (C) 2014 Stefan Schroeder
|
||||
~
|
||||
~ This library is free software; you can redistribute it and/or
|
||||
~ modify it under the terms of the GNU Lesser General Public
|
||||
~ License as published by the Free Software Foundation; either
|
||||
~ version 3.0 of the License, or (at your option) any later version.
|
||||
~
|
||||
~ This library 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
|
||||
~ Lesser General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public
|
||||
~ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<problem xmlns="http://www.w3schools.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||
|
|
@ -124,7 +141,8 @@
|
|||
<services>
|
||||
<service id="1" type="service">
|
||||
<locationId>j(1,5)</locationId>
|
||||
<coord x="10.0" y="10.0"/>
|
||||
<name>cleaning</name>
|
||||
<coord x="10.0" y="10.0"/>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">1</dimension>
|
||||
</capacity-dimensions>
|
||||
|
|
@ -140,6 +158,7 @@
|
|||
|
||||
<service id="2" type="service">
|
||||
<locationId>i(3,9)</locationId>
|
||||
<name>cleaning</name>
|
||||
<coord x="10.0" y="10.0"/>
|
||||
<capacity-demand>1</capacity-demand>
|
||||
<duration>0.0</duration>
|
||||
|
|
@ -155,6 +174,7 @@
|
|||
|
||||
<shipments>
|
||||
<shipment id="3">
|
||||
<name>deliver-smth</name>
|
||||
<pickup>
|
||||
<locationId>i(3,9)</locationId>
|
||||
<coord x="10.0" y="10.0"/>
|
||||
|
|
@ -206,6 +226,7 @@
|
|||
<capacity-dimensions>
|
||||
<dimension index="0">10</dimension>
|
||||
</capacity-dimensions>
|
||||
<name>deliver-smth</name>
|
||||
</shipment>
|
||||
|
||||
</shipments>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue