Exemplo n.º 1
0
  @Before
  public void initFixture() {
    devHelper.deleteAll();
    long facilityId1 = dummies.createFacility();
    long facilityId2 = dummies.createFacility();
    long hubId = dummies.createHub(facilityId1, facilityId2);

    hub = hubService.getHub(hubId);
    facility1 = facilityService.getFacility(facilityId1);
    facility2 = facilityService.getFacility(facilityId2);

    operator1 = operatorService.getOperator(facility1.operatorId);
    operator2 = operatorService.getOperator(facility2.operatorId);

    operator1User =
        devHelper.createOrUpdateUser(
            new NewUser(1L, "operator", OPERATOR, facility1.operatorId, "operator"));
    operator2User =
        devHelper.createOrUpdateUser(
            new NewUser(2L, "Ooppera", OPERATOR, facility2.operatorId, "Ooppera"));

    apiUser =
        devHelper.createOrUpdateUser(
            new NewUser(100L, "operator_api", OPERATOR_API, facility1.operatorId, "operator"));
    apiUser2 =
        devHelper.createOrUpdateUser(
            new NewUser(101L, "Ooppera_api", OPERATOR_API, facility2.operatorId, "Ooppera"));

    adminUser = devHelper.createOrUpdateUser(new NewUser(10L, "admin", ADMIN, null, "admin"));
  }
Exemplo n.º 2
0
 private void registerMockFacilityUsages(Facility facility, User user) {
   DateTime startOfDay = BASE_DATE.toDateTimeAtStartOfDay();
   facilityService.registerUtilization(
       facility.id,
       asList(
           utilize(CAR, 24, startOfDay, facility),
           utilize(CAR, 0, startOfDay.plusHours(12), facility),
           utilize(CAR, 24, startOfDay.secondOfDay().withMaximumValue(), facility),
           utilize(ELECTRIC_CAR, 2, startOfDay, facility),
           utilize(ELECTRIC_CAR, 0, startOfDay.plusHours(12), facility),
           utilize(ELECTRIC_CAR, 2, startOfDay.secondOfDay().withMaximumValue(), facility)),
       user);
 }
Exemplo n.º 3
0
 private void addMockMaxUtilizations(Facility f, User apiUser) {
   final Integer capacity = f.builtCapacity.get(CAR);
   // Day 15 to ensure that weekdays stay in the same month
   final DateTime baseDate = BASE_DATE.toDateTimeAtCurrentTime().withDayOfMonth(15);
   facilityService.registerUtilization(
       f.id,
       asList(
           // 50/50 = 100%
           utilize(CAR, 0, baseDate.withDayOfWeek(MONDAY), f),
           // 25/50 =  50%
           utilize(CAR, capacity - (capacity / 2), baseDate.withDayOfWeek(SATURDAY), f),
           // 10/50 =  20%
           utilize(CAR, capacity - (capacity / 5), baseDate.withDayOfWeek(SUNDAY), f)),
       apiUser);
 }