Exemplo n.º 1
0
  @Test
  public void whenTwoServicesHaveTheSameId_theyShouldBeEqual() {
    Service one =
        Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("foo").build();
    Service two =
        Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("fo").build();

    assertTrue(one.equals(two));
  }
Exemplo n.º 2
0
 @Test
 public void noName() {
   Set<Service> serviceSet = new HashSet<Service>();
   Service one =
       Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("foo").build();
   Service two =
       Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("fo").build();
   serviceSet.add(one);
   //		assertTrue(serviceSet.contains(two));
   serviceSet.remove(two);
   assertTrue(serviceSet.isEmpty());
 }
Exemplo n.º 3
0
 @Test
 public void
     whenShipmentIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero() {
   Service one = Service.Builder.newInstance("s").setLocationId("foofoo").build();
   assertEquals(1, one.getSize().getNuOfDimensions());
   assertEquals(0, one.getSize().get(0));
 }
Exemplo n.º 4
0
 @Test
 public void
     whenShipmentIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly() {
   Service one =
       Service.Builder.newInstance("s").addSizeDimension(0, 1).setLocationId("foofoo").build();
   assertEquals(1, one.getSize().getNuOfDimensions());
   assertEquals(1, one.getSize().get(0));
 }
Exemplo n.º 5
0
 @Test
 public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo() {
   Service one =
       Service.Builder.newInstance("s")
           .setLocationId("foofoo")
           .addSizeDimension(0, 2)
           .addSizeDimension(1, 4)
           .build();
   assertEquals(2, one.getSize().getNuOfDimensions());
 }
Exemplo n.º 6
0
 @Test
 public void whenSettingTimeWindow_itShouldBeSetCorrectly() {
   Service s =
       Service.Builder.newInstance("s")
           .setLocationId("loc")
           .setTimeWindow(TimeWindow.newInstance(1.0, 2.0))
           .build();
   assertEquals(1.0, s.getTimeWindow().getStart(), 0.01);
   assertEquals(2.0, s.getTimeWindow().getEnd(), 0.01);
 }
Exemplo n.º 7
0
 @Test
 public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly() {
   Service s =
       Service.Builder.newInstance("s")
           .setLocationId("loc")
           .addRequiredSkill("screwDriver")
           .build();
   assertFalse(s.getRequiredSkills().containsSkill("drill"));
   assertFalse(s.getRequiredSkills().containsSkill("drilL"));
 }
Exemplo n.º 8
0
 @Test(expected = IllegalArgumentException.class)
 public void whenCapacityDimValueIsNegative_throwIllegalStateExpception() {
   @SuppressWarnings("unused")
   Service s =
       Service.Builder.newInstance("s").setLocationId("foo").addSizeDimension(0, -10).build();
 }
Exemplo n.º 9
0
 @Test
 public void nameShouldBeAssigned() {
   Service s =
       (Service) Service.Builder.newInstance("s").setLocationId("loc").setName("name").build();
   assertEquals("name", s.getName());
 }
Exemplo n.º 10
0
 @Test
 public void whenSettingLocation_itShouldBeSetCorrectly() {
   Service s = Service.Builder.newInstance("s").setLocationId("loc").build();
   assertEquals("loc", s.getLocationId());
 }
Exemplo n.º 11
0
 @Test(expected = IllegalArgumentException.class)
 public void whenTimeWindowIsNull_throwException() {
   @SuppressWarnings("unused")
   Service s = Service.Builder.newInstance("s").setLocationId("loc").setTimeWindow(null).build();
 }
Exemplo n.º 12
0
 @Test
 public void whenSettingServiceTime_itShouldBeSetCorrectly() {
   Service s = Service.Builder.newInstance("s").setLocationId("loc").setServiceTime(1).build();
   assertEquals(1.0, s.getServiceDuration(), 0.01);
 }
Exemplo n.º 13
0
 @Test(expected = IllegalArgumentException.class)
 public void whenServiceTimeSmallerZero_throwIllegalStateException() {
   @SuppressWarnings("unused")
   Service s = Service.Builder.newInstance("s").setLocationId("loc").setServiceTime(-1).build();
 }
Exemplo n.º 14
0
 @Test(expected = IllegalStateException.class)
 public void whenSettingNeitherLocationIdNorCoord_throwsException() {
   @SuppressWarnings("unused")
   Service s = Service.Builder.newInstance("s").build();
 }
Exemplo n.º 15
0
 @Test
 public void whenSettingLocationCoord_itShouldBeSetCorrectly() {
   Service s = Service.Builder.newInstance("s").setCoord(Coordinate.newInstance(1, 2)).build();
   assertEquals(1.0, s.getCoord().getX(), 0.01);
   assertEquals(2.0, s.getCoord().getY(), 0.01);
 }
Exemplo n.º 16
0
 @Test
 public void whenCallingForNewInstanceOfBuilder_itShouldReturnBuilderCorrectly() {
   Service.Builder builder = Service.Builder.newInstance("s");
   assertNotNull(builder);
   assertTrue(builder instanceof Service.Builder);
 }
Exemplo n.º 17
0
 @Test
 public void whenSettingNoType_itShouldReturn_service() {
   Service s = Service.Builder.newInstance("s").setLocationId("loc").build();
   assertEquals("service", s.getType());
 }