mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-06 09:09:13 +08:00
test: 多包扫描测试用例
This commit is contained in:
parent
47647aa60e
commit
29fd02f4f6
@ -10,6 +10,7 @@ import co.elastic.clients.elasticsearch.core.SearchRequest;
|
||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
||||
import co.elastic.clients.json.JsonData;
|
||||
import co.elastic.clients.transport.rest_client.RestClientOptions;
|
||||
import org.dromara.easyes.common.constants.BaseEsConstants;
|
||||
import org.dromara.easyes.core.biz.EntityInfo;
|
||||
import org.dromara.easyes.core.biz.EsPageInfo;
|
||||
import org.dromara.easyes.core.biz.OrderByParam;
|
||||
@ -939,41 +940,41 @@ public class AllTest {
|
||||
Boolean success = documentMapper.setRequestOptions(new RestClientOptions(builder.build()));
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
//
|
||||
// // 4.删除
|
||||
// @Test
|
||||
// @Order(76)
|
||||
// public void testDeleteById() {
|
||||
// int count = documentMapper.deleteById("1");
|
||||
// Assertions.assertEquals(1, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(77)
|
||||
// public void testDeleteBatchIds() {
|
||||
// List<String> idList = Arrays.asList("2", "3", "4");
|
||||
// int count = documentMapper.deleteBatchIds(idList);
|
||||
// Assertions.assertEquals(3, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(78)
|
||||
// public void testDeleteByWrapper() {
|
||||
// LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
|
||||
// wrapper.match(Document::getCreator, "老汉");
|
||||
//
|
||||
// int count = documentMapper.delete(wrapper);
|
||||
// Assertions.assertEquals(18, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(80)
|
||||
// public void testDeleteIndex() {
|
||||
// boolean deleted = documentMapper.deleteIndex(EntityInfoHelper.getEntityInfo(Document.class).getIndexName());
|
||||
// boolean lockDeleted = documentMapper.deleteIndex(BaseEsConstants.LOCK_INDEX);
|
||||
// Assertions.assertTrue(deleted);
|
||||
// Assertions.assertTrue(lockDeleted);
|
||||
// }
|
||||
|
||||
// 4.删除
|
||||
@Test
|
||||
@Order(76)
|
||||
public void testDeleteById() {
|
||||
int count = documentMapper.deleteById("1");
|
||||
Assertions.assertEquals(1, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(77)
|
||||
public void testDeleteBatchIds() {
|
||||
List<String> idList = Arrays.asList("2", "3", "4");
|
||||
int count = documentMapper.deleteBatchIds(idList);
|
||||
Assertions.assertEquals(3, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(78)
|
||||
public void testDeleteByWrapper() {
|
||||
LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.match(Document::getCreator, "老汉");
|
||||
|
||||
int count = documentMapper.delete(wrapper);
|
||||
Assertions.assertEquals(18, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(80)
|
||||
public void testDeleteIndex() {
|
||||
boolean deleted = documentMapper.deleteIndex(EntityInfoHelper.getEntityInfo(Document.class).getIndexName());
|
||||
boolean lockDeleted = documentMapper.deleteIndex(BaseEsConstants.LOCK_INDEX);
|
||||
Assertions.assertTrue(deleted);
|
||||
Assertions.assertTrue(lockDeleted);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(79)
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
easy-es:
|
||||
# enable: true
|
||||
address: 127.0.0.1:9200
|
||||
schema: https
|
||||
username: elastic
|
||||
password: a2*HFkQU93mBnxOTaEAs
|
||||
address: 192.168.0.18:9200
|
||||
# schema: https
|
||||
# username: elastic
|
||||
# password: a2*HFkQU93mBnxOTaEAs
|
||||
keep-alive-millis: 18000
|
||||
global-config:
|
||||
i-kun-mode: false
|
||||
@ -11,7 +11,7 @@ easy-es:
|
||||
async-process-index-blocking: true
|
||||
print-dsl: true
|
||||
db-config:
|
||||
map-underscore-to-camel-case: false
|
||||
map-underscore-to-camel-case: true
|
||||
id-type: customize
|
||||
field-strategy: not_empty
|
||||
refresh-policy: immediate
|
||||
|
||||
@ -10,6 +10,7 @@ import co.elastic.clients.elasticsearch.core.SearchRequest;
|
||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
||||
import co.elastic.clients.json.JsonData;
|
||||
import co.elastic.clients.transport.rest_client.RestClientOptions;
|
||||
import org.dromara.easyes.common.constants.BaseEsConstants;
|
||||
import org.dromara.easyes.core.biz.EntityInfo;
|
||||
import org.dromara.easyes.core.biz.EsPageInfo;
|
||||
import org.dromara.easyes.core.biz.OrderByParam;
|
||||
@ -675,7 +676,7 @@ public class XmlScannerAllTest {
|
||||
wrapper.match(Document::getCreator, "老汉");
|
||||
List<OrderByParam> orderByParams = new ArrayList<>();
|
||||
OrderByParam orderByParam = new OrderByParam();
|
||||
orderByParam.setOrder("starNum");
|
||||
orderByParam.setOrder("star_num");
|
||||
orderByParam.setSort("DESC");
|
||||
orderByParams.add(orderByParam);
|
||||
wrapper.orderBy(orderByParams);
|
||||
@ -941,39 +942,39 @@ public class XmlScannerAllTest {
|
||||
}
|
||||
|
||||
// 4.删除
|
||||
// @Test
|
||||
// @Order(76)
|
||||
// public void testDeleteById() {
|
||||
// int count = documentMapper.deleteById("1");
|
||||
// Assertions.assertEquals(1, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(77)
|
||||
// public void testDeleteBatchIds() {
|
||||
// List<String> idList = Arrays.asList("2", "3", "4");
|
||||
// int count = documentMapper.deleteBatchIds(idList);
|
||||
// Assertions.assertEquals(3, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(78)
|
||||
// public void testDeleteByWrapper() {
|
||||
// LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
|
||||
// wrapper.match(Document::getCreator, "老汉");
|
||||
//
|
||||
// int count = documentMapper.delete(wrapper);
|
||||
// Assertions.assertEquals(18, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(80)
|
||||
// public void testDeleteIndex() {
|
||||
// boolean deleted = documentMapper.deleteIndex(EntityInfoHelper.getEntityInfo(Document.class).getIndexName());
|
||||
// boolean lockDeleted = documentMapper.deleteIndex(BaseEsConstants.LOCK_INDEX);
|
||||
// Assertions.assertTrue(deleted);
|
||||
// Assertions.assertTrue(lockDeleted);
|
||||
// }
|
||||
@Test
|
||||
@Order(76)
|
||||
public void testDeleteById() {
|
||||
int count = documentMapper.deleteById("1");
|
||||
Assertions.assertEquals(1, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(77)
|
||||
public void testDeleteBatchIds() {
|
||||
List<String> idList = Arrays.asList("2", "3", "4");
|
||||
int count = documentMapper.deleteBatchIds(idList);
|
||||
Assertions.assertEquals(3, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(78)
|
||||
public void testDeleteByWrapper() {
|
||||
LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.match(Document::getCreator, "老汉");
|
||||
|
||||
int count = documentMapper.delete(wrapper);
|
||||
Assertions.assertEquals(18, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(80)
|
||||
public void testDeleteIndex() {
|
||||
boolean deleted = documentMapper.deleteIndex(EntityInfoHelper.getEntityInfo(Document.class).getIndexName());
|
||||
boolean lockDeleted = documentMapper.deleteIndex(BaseEsConstants.LOCK_INDEX);
|
||||
Assertions.assertTrue(deleted);
|
||||
Assertions.assertTrue(lockDeleted);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(79)
|
||||
|
||||
@ -11,15 +11,13 @@
|
||||
|
||||
<bean id="easyEsProperties" class="org.dromara.easyes.common.property.EasyEsProperties">
|
||||
<property name="enable" value="true"/>
|
||||
<property name="address" value="192.168.1.16:30156"/>
|
||||
<property name="username" value="elastic"/>
|
||||
<property name="password" value="mg123456"/>
|
||||
<property name="address" value="192.168.0.18:9200"/>
|
||||
<property name="keepAliveMillis" value="18000"/>
|
||||
<property name="globalConfig.IKunMode" value="false"/>
|
||||
<property name="globalConfig.processIndexMode" value="MANUAL"/>
|
||||
<property name="globalConfig.asyncProcessIndexBlocking" value="true"/>
|
||||
<property name="globalConfig.printDsl" value="true"/>
|
||||
<property name="globalConfig.dbConfig.mapUnderscoreToCamelCase" value="false"/>
|
||||
<property name="globalConfig.dbConfig.mapUnderscoreToCamelCase" value="true"/>
|
||||
<property name="globalConfig.dbConfig.idType" value="CUSTOMIZE"/>
|
||||
<property name="globalConfig.dbConfig.fieldStrategy" value="NOT_EMPTY"/>
|
||||
<property name="globalConfig.dbConfig.refreshPolicy" value="IMMEDIATE"/>
|
||||
@ -32,6 +30,6 @@
|
||||
|
||||
<!-- easy-es配置 -->
|
||||
<bean id="mapperScannerConfigurer" class="org.dromara.easyes.spring.MapperScannerConfigurer">
|
||||
<property name="basePackage" value="org.dromara.easyes.test.mapper"/>
|
||||
<property name="basePackage" value="org.dromara.easyes.test.mapper,org.dromara.easyes.test.mapper2"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@ -1,4 +1,4 @@
|
||||
package org.dromara.easyes.test.mapper;
|
||||
package org.dromara.easyes.test.mapper2;
|
||||
|
||||
|
||||
import org.dromara.easyes.core.kernel.BaseEsMapper;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.dromara.easyes.test.mapper;
|
||||
package org.dromara.easyes.test.mapper3;
|
||||
|
||||
|
||||
import org.dromara.easyes.core.kernel.BaseEsMapper;
|
||||
@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
* Copyright © 2021 xpc1024 All Rights Reserved
|
||||
**/
|
||||
@SpringBootApplication
|
||||
@EsMapperScan("org.dromara.easyes.test.mapper")
|
||||
@EsMapperScan({"org.dromara.easyes.test.mapper", "org.dromara.easyes.test.mapper2", "org.dromara.easyes.test.mapper3"})
|
||||
public class TestEasyEsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TestEasyEsApplication.class, args);
|
||||
|
||||
@ -10,6 +10,7 @@ import co.elastic.clients.elasticsearch.core.SearchRequest;
|
||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
||||
import co.elastic.clients.json.JsonData;
|
||||
import co.elastic.clients.transport.rest_client.RestClientOptions;
|
||||
import org.dromara.easyes.common.constants.BaseEsConstants;
|
||||
import org.dromara.easyes.core.biz.EntityInfo;
|
||||
import org.dromara.easyes.core.biz.EsPageInfo;
|
||||
import org.dromara.easyes.core.biz.OrderByParam;
|
||||
@ -942,40 +943,40 @@ public class AllTest {
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
// // 4.删除
|
||||
// @Test
|
||||
// @Order(76)
|
||||
// public void testDeleteById() {
|
||||
// int count = documentMapper.deleteById("1");
|
||||
// Assertions.assertEquals(1, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(77)
|
||||
// public void testDeleteBatchIds() {
|
||||
// List<String> idList = Arrays.asList("2", "3", "4");
|
||||
// int count = documentMapper.deleteBatchIds(idList);
|
||||
// Assertions.assertEquals(3, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(78)
|
||||
// public void testDeleteByWrapper() {
|
||||
// LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
|
||||
// wrapper.match(Document::getCreator, "老汉");
|
||||
//
|
||||
// int count = documentMapper.delete(wrapper);
|
||||
// Assertions.assertEquals(18, count);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @Order(80)
|
||||
// public void testDeleteIndex() {
|
||||
// boolean deleted = documentMapper.deleteIndex(EntityInfoHelper.getEntityInfo(Document.class).getIndexName());
|
||||
// boolean lockDeleted = documentMapper.deleteIndex(BaseEsConstants.LOCK_INDEX);
|
||||
// Assertions.assertTrue(deleted);
|
||||
// Assertions.assertTrue(lockDeleted);
|
||||
// }
|
||||
// 4.删除
|
||||
@Test
|
||||
@Order(76)
|
||||
public void testDeleteById() {
|
||||
int count = documentMapper.deleteById("1");
|
||||
Assertions.assertEquals(1, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(77)
|
||||
public void testDeleteBatchIds() {
|
||||
List<String> idList = Arrays.asList("2", "3", "4");
|
||||
int count = documentMapper.deleteBatchIds(idList);
|
||||
Assertions.assertEquals(3, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(78)
|
||||
public void testDeleteByWrapper() {
|
||||
LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.match(Document::getCreator, "老汉");
|
||||
|
||||
int count = documentMapper.delete(wrapper);
|
||||
Assertions.assertEquals(18, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(80)
|
||||
public void testDeleteIndex() {
|
||||
boolean deleted = documentMapper.deleteIndex(EntityInfoHelper.getEntityInfo(Document.class).getIndexName());
|
||||
boolean lockDeleted = documentMapper.deleteIndex(BaseEsConstants.LOCK_INDEX);
|
||||
Assertions.assertTrue(deleted);
|
||||
Assertions.assertTrue(lockDeleted);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(79)
|
||||
|
||||
@ -10,8 +10,8 @@ import org.dromara.easyes.test.entity.Author;
|
||||
import org.dromara.easyes.test.entity.Comment;
|
||||
import org.dromara.easyes.test.entity.Contact;
|
||||
import org.dromara.easyes.test.entity.Document;
|
||||
import org.dromara.easyes.test.mapper.AuthorMapper;
|
||||
import org.dromara.easyes.test.mapper.CommentMapper;
|
||||
import org.dromara.easyes.test.mapper2.AuthorMapper;
|
||||
import org.dromara.easyes.test.mapper3.CommentMapper;
|
||||
import org.dromara.easyes.test.mapper.ContactMapper;
|
||||
import org.dromara.easyes.test.mapper.DocumentMapper;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package org.dromara.easyes.test.mapper;
|
||||
|
||||
import org.dromara.easyes.spring.annotation.EsMapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 启动类
|
||||
* <p>
|
||||
* Copyright © 2021 xpc1024 All Rights Reserved
|
||||
**/
|
||||
@SpringBootApplication
|
||||
@EsMapperScan({"org.dromara.easyes.test.mapper", "org.dromara.easyes.test.mapper2", "org.dromara.easyes.test.mapper3"})
|
||||
public class MapperScanEsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MapperScanEsApplication.class, args);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package org.dromara.easyes.test.mapper;
|
||||
|
||||
import org.dromara.easyes.common.constants.BaseEsConstants;
|
||||
import org.dromara.easyes.core.toolkit.EntityInfoHelper;
|
||||
import org.dromara.easyes.test.TestEasyEsApplication;
|
||||
import org.dromara.easyes.test.entity.Document;
|
||||
import org.dromara.easyes.test.mapper2.AuthorMapper;
|
||||
import org.dromara.easyes.test.mapper3.CommentMapper;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author MoJie
|
||||
* @since 2.0
|
||||
*/
|
||||
@DisplayName("easy-es多包扫描单元测试")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@SpringBootTest(classes = MapperScanEsApplication.class)
|
||||
public class MapperScanTest {
|
||||
|
||||
@Resource
|
||||
private ContactMapper contactMapper;
|
||||
@Resource
|
||||
private AuthorMapper authorMapper;
|
||||
@Resource
|
||||
private CommentMapper commentMapper;
|
||||
|
||||
@Test
|
||||
@Order(0)
|
||||
public void testCreateIndex1() {
|
||||
boolean success = contactMapper.createIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void testDeleteIndex1() {
|
||||
boolean deleted = contactMapper.deleteIndex();
|
||||
Assertions.assertTrue(deleted);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testCreateIndex2() {
|
||||
boolean success = authorMapper.createIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testDeleteIndex2() {
|
||||
boolean success = authorMapper.deleteIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void testCreateIndex3() {
|
||||
boolean success = commentMapper.createIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
public void testDeleteIndex3() {
|
||||
boolean success = commentMapper.deleteIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package org.dromara.easyes.test.mapper;
|
||||
|
||||
import org.dromara.easyes.test.mapper2.AuthorMapper;
|
||||
import org.dromara.easyes.test.mapper3.CommentMapper;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author MoJie
|
||||
* @since 2.0
|
||||
*/
|
||||
@DisplayName("easy-es多包扫描单元测试")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@SpringBootTest(classes = PattenScanEsApplication.class)
|
||||
public class PattenMapperScanTest {
|
||||
|
||||
@Resource
|
||||
private ContactMapper contactMapper;
|
||||
@Resource
|
||||
private AuthorMapper authorMapper;
|
||||
@Resource
|
||||
private CommentMapper commentMapper;
|
||||
|
||||
@Test
|
||||
@Order(0)
|
||||
public void testCreateIndex1() {
|
||||
boolean success = contactMapper.createIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void testDeleteIndex1() {
|
||||
boolean deleted = contactMapper.deleteIndex();
|
||||
Assertions.assertTrue(deleted);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testCreateIndex2() {
|
||||
boolean success = authorMapper.createIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testDeleteIndex2() {
|
||||
boolean success = authorMapper.deleteIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void testCreateIndex3() {
|
||||
boolean success = commentMapper.createIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
public void testDeleteIndex3() {
|
||||
boolean success = commentMapper.deleteIndex();
|
||||
Assertions.assertTrue(success);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package org.dromara.easyes.test.mapper;
|
||||
|
||||
import org.dromara.easyes.spring.annotation.EsMapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 启动类
|
||||
* <p>
|
||||
* Copyright © 2021 xpc1024 All Rights Reserved
|
||||
**/
|
||||
@SpringBootApplication
|
||||
@EsMapperScan({"org.dromara.easyes.test.*"})
|
||||
public class PattenScanEsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PattenScanEsApplication.class, args);
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
easy-es:
|
||||
# enable: true
|
||||
address: 10.18.2.45:9200
|
||||
address: 192.168.0.18:9200
|
||||
# schema: http
|
||||
# username: elastic
|
||||
# password: mg123456
|
||||
compatible: false
|
||||
keep-alive-millis: 18000
|
||||
global-config:
|
||||
i-kun-mode: false
|
||||
@ -25,7 +26,6 @@ easy-es:
|
||||
# address: 10.18.2.45:9200 # 数据源2
|
||||
#username: '若无可去掉此行'
|
||||
#password: '若无可去掉此行'
|
||||
compatible: true
|
||||
#logging:
|
||||
# level:
|
||||
# tracer: trace
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user