BlockTripInstanceLibrary { public static BlockTripInstance getBlockTripInstance( BlockInstance blockInstance, AgencyAndId tripId) { BlockConfigurationEntry blockConfig = blockInstance.getBlock(); List<BlockTripEntry> blockTrips = blockConfig.getTrips(); for (int i = 0; i < blockTrips.size(); ++i) { BlockTripEntry blockTrip = blockTrips.get(i); if (blockTrip.getTrip().getId().equals(tripId)) { return new BlockTripInstance(blockTrip, blockInstance.getState()); } } return null; }  static BlockTripInstance getBlockTripInstance(
      BlockInstance blockInstance, AgencyAndId tripId);  }
@Test public void test() { BlockEntryImpl block = UnitTestingSupport.block("block"); TripEntryImpl tripA = UnitTestingSupport.trip("tripA"); TripEntryImpl tripB = UnitTestingSupport.trip("tripB"); UnitTestingSupport.stopTime(0, null, tripA, 0, 0); UnitTestingSupport.stopTime(0, null, tripB, 0, 0); ServiceIdActivation serviceIds = UnitTestingSupport.serviceIds("sid"); BlockConfigurationEntry blockConfig = UnitTestingSupport.blockConfiguration( block, serviceIds, tripA, tripB); BlockInstance blockInstanceA = new BlockInstance(blockConfig, 123L); BlockTripInstance blockTripInstance = BlockTripInstanceLibrary.getBlockTripInstance( blockInstanceA, UnitTestingSupport.aid("tripA")); assertSame(tripA, blockTripInstance.getBlockTrip().getTrip()); assertEquals(123L, blockTripInstance.getServiceDate()); blockTripInstance = BlockTripInstanceLibrary.getBlockTripInstance( blockInstanceA, UnitTestingSupport.aid("tripB")); assertSame(tripB, blockTripInstance.getBlockTrip().getTrip()); assertEquals(123L, blockTripInstance.getServiceDate()); blockTripInstance = BlockTripInstanceLibrary.getBlockTripInstance( blockInstanceA, UnitTestingSupport.aid("tripC")); assertNull(blockTripInstance); }