Browse Source

修改事务测试用例.

聂秋秋 6 years ago
parent
commit
b9a48328dd

+ 2 - 2
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserTest.java

@@ -268,7 +268,7 @@ public class H2UserTest extends BaseTest {
             Assert.assertNull(u.getPrice());
         }
     }
-    
+
     @Test
     public void testBatchTransactional(){
         try {
@@ -278,7 +278,7 @@ public class H2UserTest extends BaseTest {
             Assert.assertTrue(CollectionUtils.isEmpty(list));
         }
     }
-    
+
     @Test
     public void testSimpleTransactional(){
         try {

+ 5 - 0
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/entity/persistent/H2User.java

@@ -113,6 +113,11 @@ public class H2User extends SuperEntity {
         this.testType = testType;
     }
 
+    public H2User(String name, Integer deleted) {
+        this.name = name;
+        this.deleted = deleted;
+    }
+
     @Override
     public String toString() {
         return null == this ? "h2user is null." : new StringBuilder()

+ 6 - 7
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/service/impl/H2UserServiceImpl.java

@@ -15,7 +15,6 @@
  */
 package com.baomidou.mybatisplus.test.h2.service.impl;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -92,20 +91,20 @@ public class H2UserServiceImpl extends ServiceImpl<H2UserMapper, H2User> impleme
     public List<Map> mySelectMaps() {
         return userMapper.mySelectMaps();
     }
-    
+
     @Override
     @Transactional
     public void testBatchTransactional() {
-        saveBatch(Arrays.asList(new H2User("batch1"),new H2User("batch2"),new H2User("batch3")));
-        saveBatch(Arrays.asList(new H2User("batch4"),new H2User("batch5"),new H2User("batch6")));
+        saveBatch(Arrays.asList(new H2User("batch1",0),new H2User("batch2",0),new H2User("batch3",0)));
+        saveBatch(Arrays.asList(new H2User("batch4",0),new H2User("batch5",0),new H2User("batch6",0)));
         throw new MybatisPlusException("测试批量插入事务回滚");
     }
-    
+
     @Override
     @Transactional
     public void testSimpleTransactional() {
-        save(new H2User("simple1"));
-        save(new H2User("simple2"));
+        save(new H2User("simple1",0));
+        save(new H2User("simple2",0));
         throw new MybatisPlusException("测试普通插入事务回滚");
     }
 }