@Test
 public void
     linkContainsCellsCorrespondingToInJunctionFollowedByCellsInCellChainFollowedByOutJunction()
         throws Exception {
   context.checking(
       new Expectations() {
         {
           oneOf(cellChain).iterator();
           will(returnIterator(linkCell0, linkCell1));
         }
       });
   assertThat(link.cells(), contains(inJunction, linkCell0, linkCell1, outJunction));
 }
 @Test
 public void getCellAtIndexReturnsDelgatesCallToCellChain() throws Exception {
   context.checking(
       new Expectations() {
         {
           oneOf(cellChain).getCellAtIndex(0);
           will(returnValue(linkCell0));
           oneOf(cellChain).getCellAtIndex(1);
           will(returnValue(linkCell1));
         }
       });
   assertThat(link.getCell(0), is(linkCell0));
   assertThat(link.getCell(1), is(linkCell1));
 }
  @Test
  public void occupancyReturnsLinkOccupancyObject() throws Exception {
    defineExpectationsForOccupancyOnCellChain();
    defineExpectationsForCapacityOnCellChain();

    context.checking(
        new Expectations() {
          {
            oneOf(occupancyFactory).create(occupancy, capacity);
            will(returnValue(occupancyMeasure));
            oneOf(linkOccupancyFactory).create(link, occupancyMeasure);
            will(returnValue(linkOccupancy));
          }
        });
    assertThat(link.occupancy(), is(linkOccupancy));
  }
 @Test
 public void congestionReturnsValueOfOccupancyDividedByCapacity() throws Exception {
   defineExpectationsForOccupancyOnCellChain();
   defineExpectationsForCapacityOnCellChain();
   assertThat(link.congestion(), is(0.4));
 }