Package whitewerx.com.trapos.translators

Examples of whitewerx.com.trapos.translators.TradeTranslator


    public MarketTradeEventHandler(TradeTranslator translator) {
        this.translator = translator;
    }
   
    public MarketTradeEventHandler() {
        this(new TradeTranslator());
    }
View Full Code Here


   
    @Test
    public void consumesTradeEvent() throws Exception {
       
        final String delimitedTrade = "T|S|2.3m|R|GBPUSD|1.6324";
        final TradeTranslator tradeTranslator = context.mock(TradeTranslator.class);
        final MarketEvent marketEvent = context.mock(MarketEvent.class);
        final Trade trade = context.mock(Trade.class);
       
        final MarketTradeEventHandler h = new MarketTradeEventHandler(tradeTranslator);
        context.checking(new Expectations(){{
View Full Code Here

   
    @Test
    public void shouldNotConsumeRateEvents() throws Exception {
        final String delimitedRate = "R|GBPUSD|1.6324";
       
        final TradeTranslator tradeTranslator = context.mock(TradeTranslator.class);
        final MarketEvent marketEvent = context.mock(MarketEvent.class);
       
        final MarketTradeEventHandler h = new MarketTradeEventHandler(tradeTranslator);
        context.checking(new Expectations(){{
            oneOf(marketEvent).getMessage();
View Full Code Here

       
        Amount fivePointOneThousand = new Amount(5.1 * 1000, new Currency("EUR"));
        Rate atEURUSDRate = new Rate(1.3124, EURUSD);
        final Trade expected = new Trade(TradeType.BUY, fivePointOneThousand, atEURUSDRate);
       
        TradeTranslator t = new TradeTranslator();
        Trade trade = t.translate(delimitedTrade);
        assertThat(trade, equalTo(expected));
    }
View Full Code Here

       
        Amount fivePointOne = new Amount(5.1, new Currency("EUR"));
        Rate atEURUSDRate = new Rate(1.3124, EURUSD);
        final Trade expected = new Trade(TradeType.SELL, fivePointOne, atEURUSDRate);
       
        TradeTranslator t = new TradeTranslator();
        Trade trade = t.translate(delimitedTrade);
        assertThat(trade, equalTo(expected));
    }
View Full Code Here

       
        Amount twoMillion = new Amount(2000000.0, new Currency("USD"));
        Rate atUSDCADRate = new Rate(1.0012, USDCAD);
        final Trade expected = new Trade(TradeType.SELL, twoMillion, atUSDCADRate);
       
        TradeTranslator t = new TradeTranslator();
        Trade trade = t.translate(delimitedTrade);
        assertThat(trade, equalTo(expected));
    }   
View Full Code Here

   
    @Test(expected=TranslateException.class)
    public void translateInvalidTradeMessage() throws Exception {
        String invalidTrade = "T||5.1|R|EURUSD|1.3124";

        TradeTranslator t = new TradeTranslator();
        t.translate(invalidTrade);
    }
View Full Code Here

    @Test
    public void shouldTranslateTradeMessages(){
        String delimitedTrade = "T";
       
        TradeTranslator tradeTranslator = new TradeTranslator();
        assertThat(tradeTranslator.canHandle(delimitedTrade), equalTo(true));
    }
View Full Code Here

   
    @Test
    public void shouldNotTranslateAnyOtherMessageTypes(){
        String otherMessageType = "C";
       
        TradeTranslator tradeTranslator = new TradeTranslator();
        assertThat(tradeTranslator.canHandle(otherMessageType), equalTo(false));
    }   
View Full Code Here

TOP

Related Classes of whitewerx.com.trapos.translators.TradeTranslator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.