Program: 141490
Project: 141490
Buggy source:
@Test public void hub_sums_predictions_for_facilities(){
  final long facility2Id=dummies.createFacility();
  final Long operator2Id=facilityService.getFacility(facility2Id).operatorId;
  final User user2=devHelper.createOrUpdateUser(new NewUser(2L,"String_Node_Str",OPERATOR_API,operator2Id,"String_Node_Str"));
  final long hubId=dummies.createHub(facilityId,facility2Id);
  makeDummyPredictions(Usage.PARK_AND_RIDE,facilityId,user);
  makeDummyPredictions(Usage.PARK_AND_RIDE,facility2Id,user2);
  makeDummyPredictions(Usage.COMMERCIAL,facility2Id,user2);
  final Facility f2=facilityService.getFacility(facility2Id);
  f2.builtCapacity=ImmutableMap.of(CAR,1000);
  f2.pricing=asList(new Pricing(CAR,PARK_AND_RIDE,1000,BUSINESS_DAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,PARK_AND_RIDE,1000,SATURDAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,PARK_AND_RIDE,1000,SUNDAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,COMMERCIAL,1000,BUSINESS_DAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,COMMERCIAL,1000,SATURDAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,COMMERCIAL,1000,SUNDAY,"String_Node_Str","String_Node_Str","String_Node_Str"));
  ;
  f2.pricingMethod=PricingMethod.CUSTOM;
  facilityService.updateFacility(f2.id,f2,adminUser);
  final HubPredictionResult[] predictionsForHub=getPredictionsForHub(hubId);
  assertThat(predictionsForHub).hasSize(2);
  assertThat(predictionsForHub[0].hubId).isEqualTo(hubId);
  assertThat(predictionsForHub[0].capacityType).isEqualTo(CapacityType.CAR);
  assertIsNear(DateTime.now(),predictionsForHub[0].timestamp);
  final HubPredictionResult parkAndRide=stream(predictionsForHub).filter(pred -> pred.usage == Usage.PARK_AND_RIDE).findFirst().get();
  assertThat(parkAndRide.spacesAvailable).isEqualTo(SPACES_AVAILABLE * 2);
  final HubPredictionResult commercial=stream(predictionsForHub).filter(pred -> pred.usage == Usage.COMMERCIAL).findFirst().get();
  assertThat(commercial.spacesAvailable).isEqualTo(SPACES_AVAILABLE);
}

Fixed version (ground truth):
@Test public void hub_sums_predictions_for_facilities(){
  final long facility2Id=dummies.createFacility();
  final Long operator2Id=facilityService.getFacility(facility2Id).operatorId;
  final User user2=devHelper.createOrUpdateUser(new NewUser(2L,"String_Node_Str",OPERATOR_API,operator2Id,"String_Node_Str"));
  final long hubId=dummies.createHub(facilityId,facility2Id);
  makeDummyPredictions(Usage.PARK_AND_RIDE,facilityId,user,CapacityType.CAR);
  makeDummyPredictions(Usage.PARK_AND_RIDE,facility2Id,user2,CapacityType.CAR);
  makeDummyPredictions(Usage.COMMERCIAL,facility2Id,user2,CapacityType.CAR);
  final Facility f2=facilityService.getFacility(facility2Id);
  f2.builtCapacity=ImmutableMap.of(CAR,1000);
  f2.pricing=asList(new Pricing(CAR,PARK_AND_RIDE,1000,BUSINESS_DAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,PARK_AND_RIDE,1000,SATURDAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,PARK_AND_RIDE,1000,SUNDAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,COMMERCIAL,1000,BUSINESS_DAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,COMMERCIAL,1000,SATURDAY,"String_Node_Str","String_Node_Str","String_Node_Str"),new Pricing(CAR,COMMERCIAL,1000,SUNDAY,"String_Node_Str","String_Node_Str","String_Node_Str"));
  ;
  f2.pricingMethod=PricingMethod.CUSTOM;
  facilityService.updateFacility(f2.id,f2,adminUser);
  final HubPredictionResult[] predictionsForHub=getPredictionsForHub(hubId);
  assertThat(predictionsForHub).hasSize(2);
  assertThat(predictionsForHub[0].hubId).isEqualTo(hubId);
  assertThat(predictionsForHub[0].capacityType).isEqualTo(CapacityType.CAR);
  assertIsNear(DateTime.now(),predictionsForHub[0].timestamp);
  final HubPredictionResult parkAndRide=stream(predictionsForHub).filter(pred -> pred.usage == Usage.PARK_AND_RIDE).findFirst().get();
  assertThat(parkAndRide.spacesAvailable).isEqualTo(SPACES_AVAILABLE * 2);
  final HubPredictionResult commercial=stream(predictionsForHub).filter(pred -> pred.usage == Usage.COMMERCIAL).findFirst().get();
  assertThat(commercial.spacesAvailable).isEqualTo(SPACES_AVAILABLE);
}