@SuppressWarnings("boxing")
  public void testMajorToMinor() {

    double majorPx = 25.12;
    ClientNewOrderSingleImpl nos =
        FixTestUtils.getClientNOS(_decoder, "TST0000001", 100, majorPx, _upMsgHandler);
    nos.setCurrency(Currency.GBP);
    ((InstrumentWrite) nos.getInstrument()).setCurrency(Currency.GBp);
    _proc.handle(nos);
    MarketNewOrderSingleImpl mnos =
        (MarketNewOrderSingleImpl) getMessage(_downQ, MarketNewOrderSingleImpl.class);

    // MARKET IS IN POUNDS
    assertSame(Currency.GBp, mnos.getCurrency());
    assertEquals((majorPx * 100.0), mnos.getPrice(), Constants.PRICE_DP);

    Order order = _proc.getOrder(nos.getClOrdId());

    NewOrderAck mack =
        FixTestUtils.getMarketACK(_decoder, "TST0000001", 100, 25.12, _mktOrderId, _execId);
    _proc.handle(mack);
    checkQueueSize(1, 0, 0);
    ClientNewOrderAckImpl cack =
        (ClientNewOrderAckImpl) getMessage(_upQ, ClientNewOrderAckImpl.class);

    assertSame(Currency.GBP, cack.getCurrency());
    assertEquals(majorPx, cack.getPrice(), Constants.WEIGHT);

    ClientProfile client = order.getClientProfile();

    double totVal = nos.getPrice() * nos.getOrderQty() * nos.getCurrency().toUSDFactor();

    assertEquals(totVal, client.getTotalOrderValueUSD());
  }
  private void commonValidation(Exchange ex, OrderRequest req, Order order, long now) {
    if (req.getClOrdId().length() == 0) addError(MISSING_CLORDID);

    validateHandlingInstruction(req.getHandlInst());
    validateAge(req.getTransactTime(), now);

    Instrument inst = req.getInstrument();

    final ViewString exDest = req.getExDest();
    final ViewString secEx = req.getSecurityExchange();
    final double price = order.getPendingVersion().getMarketPrice();

    if (exDest.length() > 0 && !ex.getRecCode().equals(exDest)) {
      delim()
          .append(EXDEST_MISMATCH)
          .append(exDest)
          .append(Strings.EXPECTED)
          .append(ex.getRecCode());
    }

    if (secEx.length() > 0 && !ex.getRecCode().equals(secEx)) {
      delim().append(SECEX_MISMATCH).append(secEx).append(Strings.EXPECTED).append(ex.getRecCode());
    }

    validateTicksize(inst, price);

    if (inst.isRestricted()
        && !canTradeRestricted(req.getClient(), req.getBookingType(), req.getOrderCapacity())) {
      delim()
          .append(RESTRICTED)
          .append(req.getBookingType())
          .append(Strings.ORDCAP)
          .append(req.getOrderCapacity());
    }

    if (!inst.isEnabled()) {
      delim().append(INSTRUMENT_DISABLED).append(inst.getRIC());
    }

    TradingRange band = inst.getValidTradingRange();

    band.valid(price, req.getSide().getIsBuySide(), _err);
  }
  @Override
  public boolean validate(CancelReplaceRequest newVersion, Order order) {
    reset();

    final OrderVersion lastAcc = order.getLastAckedVerion();
    final OrderRequest previous = (OrderRequest) lastAcc.getBaseOrderRequest();
    final int cumQty = order.getLastAckedVerion().getCumQty();

    final Instrument inst = newVersion.getInstrument();
    final Exchange ex = inst.getExchange();

    if (!inst.isTestInstrument()) { // dont validate test instruments at ALL
      final long now = System.currentTimeMillis();
      final int newOrdQty = newVersion.getOrderQty();

      commonValidation(ex, newVersion, order, now);

      if (newVersion.getCurrency() != previous.getCurrency()) { // CANT CHANGE CCY
        delim()
            .append(UNABLE_TO_CHANGE_CCY)
            .append(Strings.FROM)
            .append(previous.getCurrency().toString())
            .append(Strings.TO)
            .append(newVersion.getCurrency().toString());
      }

      if (newVersion.getOrdType() != previous.getOrdType()) {
        delim()
            .append(UNABLE_TO_CHANGE_ORDTYPE)
            .append(Strings.FROM)
            .append(previous.getOrdType().toString())
            .append(Strings.TO)
            .append(newVersion.getOrdType().toString());
      }

      if (newVersion.getSide() != previous.getSide()) {
        delim()
            .append(UNABLE_TO_CHANGE_SIDE)
            .append(Strings.FROM)
            .append(previous.getSide().toString())
            .append(Strings.TO)
            .append(newVersion.getSide().toString());
      }

      if (!newVersion.getSymbol().equals(previous.getSymbol())) {
        delim()
            .append(UNABLE_TO_CHANGE_SYM)
            .append(Strings.FROM)
            .append(previous.getSymbol())
            .append(Strings.TO)
            .append(newVersion.getSymbol());
      }

      if (newVersion.getPrice() == previous.getPrice()
          && newOrdQty == previous.getOrderQty()
          && newVersion.getTimeInForce() == previous.getTimeInForce()) {
        delim().append(MAJOR_FIELDS_UNCHANGED);
      }

      if (newOrdQty < cumQty) {
        delim()
            .append(CANNOT_AMEND_BELOW_CQTY)
            .append(newOrdQty)
            .append(Strings.CUMQTY)
            .append(cumQty);
      }

      final OMExchangeValidator exchangeValidator =
          (OMExchangeValidator) ex.getExchangeEventValidator();
      if (exchangeValidator != null) {
        exchangeValidator.validate(newVersion, _err, now);
      }
    }

    return _err.length() == 0;
  }