@@ -0,0 +1,2192 @@
+package com.cfg.shop.test;%0A%0A/**%0A * Created by Administrator on 2017/7/3.%0A */%0A%0Aimport com.cfg.shop.ShopServerApplication;%0Aimport com.cfg.shop.domain.PRODUCT_STATUS;%0Aimport com.cfg.shop.domain.Product;%0Aimport com.cfg.shop.service.ShopService;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.boot.test.mock.mockito.MockBean;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport java.util.Date;%0Aimport java.util.List;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.mockito.BDDMockito.given;%0Aimport static org.mockito.Matchers.any;%0A%0A/**%0A * Created by yhp to test the shopservice interface%0A */%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@SpringBootTest(classes=ShopServerApplication.class)%0Apublic class ShopServiceTests %7B%0A    @Autowired%0A    private ShopService shopService;%0A%0A    @Test%0A    public void showShopProducts()  %7B%0A        List%3CProduct%3E productList=shopService.getProductLists();%0A        Assert.assertNotNull(%22%E8%BF%94%E5%9B%9E%E4%BA%A7%E5%93%81%E4%B8%BA%E7%A9%BA%22,productList);%0A        Assert.assertEquals(productList.size(),2);%0A        //Assert.assertFalse(%22%E6%95%B0%E6%8D%AE%E4%B8%8D%E4%B8%80%E8%87%B4%22, !expectedResult.equals(result));%0A    %7D%0A%0A%0A    @Test%0A    public void buyShopProducts()  %7B%0A        String orderNo=shopService.createOrderNo();%0A        Assert.assertNotNull(%22%E8%AE%A2%E5%8D%95%E7%BC%96%E5%8F%B7%E4%B8%BA%E7%A9%BA%22,orderNo);%0A%0A        Product  productA=new Product(%22ProductNoA%22,%22A%22, PRODUCT_STATUS.ONSALE);%0A%0A        Product  productC=new Product(%22ProductNoC%22,%22C%22, PRODUCT_STATUS.ONSALE);%0A%0A        String result=shopService.buyProduct(orderNo,productA,1L);%0A        Assert.assertNull(%22%E8%B4%AD%E4%B9%B0%E4%BA%A7%E5%93%81%E5%A4%B1%E8%B4%A5%22,result);%0A%0A        result=shopService.buyProduct(orderNo,productA,100L);%0A        Assert.assertNotNull(%22%E8%B4%AD%E4%B9%B0%E4%BA%A7%E5%93%81%E6%95%B0%E9%87%8F%E8%B6%85%E5%BA%93%E5%AD%98%22,result);%0A%0A        result=shopService.buyProduct(orderNo,productC,1L);%0A        Assert.assertNotNull(%22%E8%B4%AD%E4%B9%B0%E5%BA%93%E5%AD%98%E4%B8%AD%E4%B8%8D%E5%AD%98%E5%9C%A8%E7%9A%84%E4%BA%A7%E5%93%81%22,result);%0A%0A        result=shopService.checkStockProductAmount(productA,10L);%0A        Assert.assertNull(%22%E5%BA%93%E5%AD%98%E6%95%B0%E9%87%8F%E5%BC%82%E5%B8%B8%22,result);%0A%0A%0A    %7D%0A%7D%0A

add unit test file