Package net.helipilot50.stocktrade.server

Source Code of net.helipilot50.stocktrade.server.CustomerSOTest

package net.helipilot50.stocktrade.server;

import java.util.List;

import net.helipilot50.stocktrade.client.CustomerSO;
import net.helipilot50.stocktrade.shared.Customer;
import net.helipilot50.stocktrade.shared.Holding;

import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class CustomerSOTest {
  @Autowired
  CustomerSO customerSO;

  @Test
  public void getStockList(){
    List<String> stocks = customerSO.getStockNameList();
    System.out.println("Stocks:");
    for (String stock : stocks){
      System.out.println("\t"+stock);
    }
  }

  @Test
  public void getCustomer() {
    Customer customer = customerSO.getCustomer("Pat");
    printCustomer(customer);
    customer = customerSO.getCustomer("Al");
    printCustomer(customer);
    customer = customerSO.getCustomer("Natasha");
    printCustomer(customer);
    customer = customerSO.getCustomer("Gordon");
    printCustomer(customer);
  }
 

  private void printCustomer(Customer customer){
    System.out.println(customer.getCustomerName());
    System.out.println(customer.getAddress());
    System.out.println(customer.getPhoneNumber());
    System.out.println(customer.getCashBalance());

    List<Holding> holdings = customer.getHoldingList();
    if (holdings != null) {
      for (Holding holding : holdings){
        System.out.println("\t" + holding.getStockName() + " " +
            holding.getPrice() + " " +
            holding.getQuantity());
      }
    }
  }
}
TOP

Related Classes of net.helipilot50.stocktrade.server.CustomerSOTest

TOP
Copyright © 2018 www.massapi.com. 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.