@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"));
  }
Esempio n. 2
0
 public Order create(Order entity) {
   entity.setDate(new Date());
   entity.setStatus(ORDER_STATUS_ACTIVE);
   if (entity.getSubscriber().getId() != 0) entity.getSubscriber().setInTrip(true);
   entity.getDriver().setInTrip(true);
   entity.setDeparturePoint(entity.getDeparturePoint().trim());
   entity.setDestinationPoint(entity.getDestinationPoint().trim());
   if (entity.getNotes() != null) {
     entity.setNotes(entity.getNotes().trim());
   } else {
     entity.setNotes(null);
   }
   entity.setCash(entity.getTotal().subtract(entity.getBonus()));
   entity.setOperator(operatorService.getCurrentOperator());
   return orderDao.create(entity);
 }