@Test
  public void testGetGDTTWithDataInMemory() {
    PutThrough tran1 = new PutThrough();
    tran1.setFloorCode("02");
    tran1.setStockSymbol("VND");
    tran1.setTime("20141225");

    PutThrough tran2 = new PutThrough();
    tran2.setFloorCode("02");
    tran2.setStockSymbol("SHB");
    tran2.setTime("20141225");

    PutThrough tran3 = new PutThrough();
    tran3.setFloorCode("10");
    tran3.setStockSymbol("HAG");
    tran3.setTime("20141225");

    List<PutThrough> t_hnxransactions = new ArrayList<>();
    t_hnxransactions.add(tran1);
    t_hnxransactions.add(tran2);

    List<PutThrough> transactions_hose = new ArrayList<>();
    transactions_hose.add(tran3);

    memory.put("PutThrough", "02", t_hnxransactions);
    memory.put("PutThrough", "10", transactions_hose);

    Map<String, List<Map<String, Object>>> adOrderList = adOrdercontroller.getPtOrder();
    Assert.assertEquals(2, adOrderList.size());
    Assert.assertTrue(adOrderList.containsKey("02"));
  }
 @Test
 public void testStockControllerWithEmptyCodes() {
   InMemory memory = new InMemory();
   memory.put("STOCK_COMPRESSION", "VND", "data for VND");
   memory.put("STOCK_COMPRESSION", "SSI", "data for SSI");
   JsonParser parser = new JsonParser();
   StockController controller = new StockController(memory, parser);
   String[] json = controller.getStock("", new ModelMap());
   Assert.assertEquals(0, json.length);
 }
 @Test
 public void testStockController() {
   InMemory memory = new InMemory();
   memory.put("STOCK_COMPRESSION", "VND", "data for VND");
   memory.put("STOCK_COMPRESSION", "SSI", "data for SSI");
   JsonParser parser = new JsonParser();
   StockController controller = new StockController(memory, parser);
   String[] json = controller.getStock("VND,SSI", new ModelMap());
   Assert.assertTrue(json[0].contains("VND"));
   Assert.assertTrue(json[1].contains("SSI"));
 }
  @Test
  public void testPtOrderMemoryHandler() {
    PutThroughTransaction pushThroughTransactionInfo = new PutThroughTransaction();
    pushThroughTransactionInfo.setSymbol("SAM");
    pushThroughTransactionInfo.setVolume(4120.0);
    pushThroughTransactionInfo.setPrice(14000.0);
    pushThroughTransactionInfo.setFloorCode("10");
    pushThroughTransactionInfo.setTradingDate("2015019");

    PutThroughTransaction pushThroughTransactionInfo1 = new PutThroughTransaction();
    pushThroughTransactionInfo1.setSymbol("SSI");
    pushThroughTransactionInfo1.setVolume(6120.0);
    pushThroughTransactionInfo1.setPrice(24000.0);
    pushThroughTransactionInfo1.setFloorCode("10");
    pushThroughTransactionInfo1.setTradingDate("2015019");

    List<PutThroughTransaction> listOfPt = new ArrayList<PutThroughTransaction>();

    listOfPt.add(pushThroughTransactionInfo);
    listOfPt.add(pushThroughTransactionInfo1);

    SecInfo stock2 = new SecInfo();
    stock2.setCode("SAM");
    stock2.setBasicPrice(21.0);
    stock2.setCeilingPrice(21.9);
    stock2.setFloorPrice(19.5);

    SecInfo stock1 = new SecInfo();
    stock1.setCode("SSI");
    stock1.setBasicPrice(8.0);
    stock1.setCeilingPrice(8.8);
    stock1.setFloorPrice(7.5);

    memory.put("STOCK", "SSI", stock1);
    memory.put("STOCK", "SAM", stock2);

    memoryHandler.handle(pushThroughTransactionInfo);
    memoryHandler.handle(pushThroughTransactionInfo1);

    List<PutThroughTransaction> putThroughTransactions =
        (List<PutThroughTransaction>) memory.get("PutThroughTransaction", "10");
    Assert.assertEquals(listOfPt, putThroughTransactions);
  }
  @Test
  public void testGetGDTTByFloorCodeWithDataInMemory() {
    PutThrough tran1 = new PutThrough();
    tran1.setFloorCode("02");
    tran1.setStockSymbol("HAG");
    tran1.setTime("20141225");

    List<PutThrough> transactions = new ArrayList<>();
    transactions.add(tran1);

    memory.put("PutThrough", "02", transactions);

    SecInfo stock1 = new SecInfo();
    stock1.setCode("HAG");
    stock1.setBasicPrice(21.0);
    stock1.setCeilingPrice(21.9);
    stock1.setFloorPrice(19.5);

    memory.put("STOCK", "HAG", stock1);

    Map<String, List<Map<String, Object>>> adOrderList = adOrdercontroller.getPtOrder();
    Assert.assertEquals(1, adOrderList.size());
  }
  @Test
  public void testCompanyNameLoaderLoadData() throws Exception {
    List<Object> expectedListCompany = new ArrayList<Object>();
    Company company1 = new Company();
    company1.setCode("VND");
    company1.setCompanyName("CT chung khoan VNDIRECT");
    Company company2 = new Company();
    company2.setCode("SSI");
    company2.setCompanyName("CT chung khoan SSI");
    expectedListCompany.add(company1);
    expectedListCompany.add(company2);

    Mockito.when(
            elasticSearchClient.getDataByIndex(
                Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any()))
        .thenReturn(expectedListCompany);
    loader.load();
    List<Object> listCompany = (List<Object>) memory.get("COMPANY_LIST", "COMPANY_LIST");
    Assert.assertEquals(expectedListCompany, listCompany);
  }