From 611093f6d3c4c647230c0b18822c57880b4f236a Mon Sep 17 00:00:00 2001 From: wyl <959814898@qq.com> Date: Thu, 19 May 2022 00:33:48 +0800 Subject: [PATCH] test --- .../SpringBootXxjobApplicationTests.java | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/spring-boot/spring-boot-mybatis/src/test/java/com/wyl/springbootmybatis/mybatis/SpringBootXxjobApplicationTests.java b/spring-boot/spring-boot-mybatis/src/test/java/com/wyl/springbootmybatis/mybatis/SpringBootXxjobApplicationTests.java index 497bf20..683880d 100644 --- a/spring-boot/spring-boot-mybatis/src/test/java/com/wyl/springbootmybatis/mybatis/SpringBootXxjobApplicationTests.java +++ b/spring-boot/spring-boot-mybatis/src/test/java/com/wyl/springbootmybatis/mybatis/SpringBootXxjobApplicationTests.java @@ -1,11 +1,16 @@ package com.wyl.springbootmybatis.mybatis; import com.wyl.springbootmybatis.BaseTest; +import com.wyl.springbootmybatis.mybatis.domain.KeyTest; import com.wyl.springbootmybatis.mybatis.domain.MybatisTest; +import com.wyl.springbootmybatis.mybatis.mapper.KeyTestMapper; +import com.wyl.springbootmybatis.mybatis.service.KeyTestService; import com.wyl.springbootmybatis.mybatis.service.MybatisTestService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import sun.security.krb5.internal.ktab.KeyTabEntry; +import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -14,6 +19,9 @@ class SpringBootMybatisApplicationTests extends BaseTest { @Autowired MybatisTestService mybatisTestService; + @Autowired + KeyTestMapper keyTestMapper; + @Test void getDataTest() { List list = mybatisTestService.list(); @@ -22,12 +30,51 @@ class SpringBootMybatisApplicationTests extends BaseTest { @Test void saveDataTest() { - for(int i =0;i<300000;i++) - { + for (int i = 0; i < 300000; i++){ MybatisTest mybatisTest = new MybatisTest(); - mybatisTest.setCode(UUID.randomUUID().toString()); + mybatisTest.setCode(UUID.randomUUID() + .toString()); mybatisTestService.save(mybatisTest); } } + @Test + void updateOrsave() { + keyTestMapper.updateOrsave("12", "123", "wwww"); + } + + @Test + void batchSaveOrUpdate() { + KeyTest keyTest = new KeyTest(); + KeyTest keyTest1 = new KeyTest(); + KeyTest keyTest2 = new KeyTest(); + KeyTest keyTest3 = new KeyTest(); + KeyTest keyTest4 = new KeyTest(); + keyTest.setWCode("123"); + keyTest1.setWCode("1233"); + keyTest2.setWCode("345"); + keyTest3.setWCode("SDF"); + keyTest4.setWCode("123"); + keyTest.setSkuCode("12"); + keyTest1.setSkuCode("12"); + keyTest2.setSkuCode("123"); + keyTest3.setSkuCode("122"); + keyTest4.setSkuCode("142"); + + keyTest.setData("1"); + keyTest1.setData("1"); + keyTest2.setData("1"); + keyTest3.setData("1"); + keyTest4.setData("1"); + + List list = new ArrayList<>(); + list.add(keyTest); + list.add(keyTest1); + list.add(keyTest2); + list.add(keyTest3); + list.add(keyTest4); + + keyTestMapper.batchSaveOrUpdate(list); + } + }