美文网首页
第四讲 service接口的实现

第四讲 service接口的实现

作者: 张三爱的歌 | 来源:发表于2019-09-29 13:36 被阅读0次
    package com.example.demo.service.Impl;
    
    import com.example.demo.dataobject.ProductCategory;
    import org.junit.Assert;
    import org.junit.jupiter.api.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.junit4.SpringRunner;
    
    import java.util.Arrays;
    import java.util.List;
    
    import static org.junit.jupiter.api.Assertions.*;
    
    @RunWith(SpringRunner.class)
    @SpringBootTest
    class CategoryServiceImplTest {
    
        @Autowired
        private  CategoryServiceImpl categoryService;
    
    
        @Test
        void findOne()  throws  Exception{
            ProductCategory productCategory= categoryService.findOne(1);
            Assert.assertEquals(new Integer(1), productCategory.getCategoryId());
        }
    
        @Test
        void findAll() {
           List<ProductCategory> list= categoryService.findAll();
            Assert.assertNotEquals(0, list.size());
        }
    
        @Test
        void findByCategoryTypeIn() {
          List<ProductCategory> productCategoryList=   categoryService.findByCategoryTypeIn(Arrays.asList(0,3));
            Assert.assertNotEquals(0, productCategoryList.size());
    
        }
    
        @Test
        void save() {
            ProductCategory productCategory=new ProductCategory("男生专享受",10);
            categoryService.save(productCategory);
    
        }
    }
    

    相关文章

      网友评论

          本文标题:第四讲 service接口的实现

          本文链接:https://www.haomeiwen.com/subject/hqefpctx.html