Пример #1
0
  @Before
  public void init() {
    MockitoAnnotations.initMocks(this);

    customer = new Customer();
    customer.setCustomerType(CUSTOMER_TYPE.COMPANY);
    customer.setFirstName("Arkadiy");
    customer.setLastName("Dobkin");
  }
Пример #2
0
  // should be private, but public because of unit test visibility
  public ParkingPriceRate getParkingPriceRate(Customer customer, boolean isWeekday)
      throws Exception {

    // get parking price rates (weekend/weekday) by customer.type
    ParkingPriceRate.PRICE_TYPE priceTypeWeekdays;
    ParkingPriceRate.PRICE_TYPE priceTypeWeekends;

    switch (customer.getCustomerType()) {
      case COMPANY:
        priceTypeWeekdays = PRICE_TYPE.COMPANY_WEEKDAYS;
        priceTypeWeekends = PRICE_TYPE.COMPANY_WEEKENDS;
        break;
      case PRIVATE:
        priceTypeWeekdays = PRICE_TYPE.PRIVATE_WEEKDAYS;
        priceTypeWeekends = PRICE_TYPE.PRIVATE_WEEKENDS;
        break;
      default:
        throw new Exception("Unknown customer type");
    }

    if (isWeekday) {
      return parkingPriceRateService.getParkingPriceRateByPriceType(priceTypeWeekdays);
    } else {
      return parkingPriceRateService.getParkingPriceRateByPriceType(priceTypeWeekends);
    }
  }