optimize: Code format optimization (#1577)

pull/1290/merge
theNorthWindBlow 3 months ago committed by GitHub
parent a5d1d6f3c0
commit 29ad46fd9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -17,6 +17,7 @@
package cn.hippo4j.common.toolkit;
import com.github.dozermapper.core.converters.ConversionException;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
@ -37,7 +38,6 @@ public class BeanUtilTest {
@Test
public void beanToBeanConvertTest(){
// Test BeanToAnotherBean
final Person person = new Person();
person.setName("Hippo4j");
person.setAge(1);
@ -53,7 +53,6 @@ public class BeanUtilTest {
@Test
public void beanToMapConvertTest() {
// 测试BeanToMap
final Person person = new Person();
person.setName("Hippo4j");
person.setAge(1);
@ -68,7 +67,6 @@ public class BeanUtilTest {
@Test
public void mapToBeanConvertTest() {
// 测试MapToBean
final HashMap<String, Object> map = new HashMap<>();
map.put("name", "Hippo4j");
map.put("age", 1);
@ -105,21 +103,16 @@ public class BeanUtilTest {
@Test
public void copyPropertiesBeanToMapTest() {
// 测试BeanToMap
final Person person = new Person();
person.setName("Hippo4j");
final Map<?, ?> convert = BeanUtil.convert(person, Map.class);
Assert.assertEquals("Hippo4j", convert.get("name"));
// static属性应被忽略
Assert.assertFalse(convert.containsKey("STATIC_NAME"));
}
/**
*
*/
// @Test(expected = ConversionException.class)
@Test(expected = ConversionException.class)
public void mapToBeanWinErrorTest() {
final Map<String, String> map = new HashMap<>();
map.put("age", "Hippo4j");
@ -157,18 +150,43 @@ public class BeanUtilTest {
@NoArgsConstructor
public static class Person {
/**
* STATIC_NAME
*/
public static final String STATIC_NAME = "STATIC_NAME";
/**
* name
*/
private String name;
/**
* age
*/
private int age;
/**
* address
*/
private String address;
/**
* size
*/
private Integer size;
}
@Setter
public static class PersonVo {
/**
* name
*/
private String name;
/**
* age
*/
private int age;
}
@ -176,7 +194,14 @@ public class BeanUtilTest {
@Setter
static class Customer {
/**
* name
*/
String name;
/**
* statusCode
*/
Integer statusCode;
}
@ -184,7 +209,14 @@ public class BeanUtilTest {
@Setter
static class PreCustomer {
/**
* name
*/
String name;
/**
* statusCode
*/
Integer statusCode;
}
@ -192,7 +224,14 @@ public class BeanUtilTest {
@Setter
static class GoodPerson extends Person{
String gender;
String nature;
/**
* gender
*/
private String gender;
/**
* nature
*/
private String nature;
}
}

@ -57,6 +57,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class AdapterThreadPoolElasticSearchMonitorHandler extends AbstractAdapterThreadPoolMonitor {
private AtomicBoolean isIndexExist = null;
@Override
protected void execute(ThreadPoolAdapterState threadPoolAdapterState) {
ElasticSearchThreadPoolRunStateInfo esThreadPoolRunStateInfo = BeanUtil.convert(threadPoolAdapterState, ElasticSearchThreadPoolRunStateInfo.class);
@ -149,12 +150,35 @@ public class AdapterThreadPoolElasticSearchMonitorHandler extends AbstractAdapte
@Builder
private static class EsIndex {
String index;
String type;
String mapping;
Integer shards;
Integer replicas;
String alias;
/**
* index
*/
private String index;
/**
* type
*/
private String type;
/**
* mapping
*/
private String mapping;
/**
* shards
*/
private Integer shards;
/**
* replicas
*/
private Integer replicas;
/**
* alias
*/
private String alias;
}
}

@ -56,6 +56,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class WebThreadPoolElasticSearchMonitorHandler extends AbstractWebThreadPoolMonitor {
private AtomicBoolean isIndexExist = null;
@Override
protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) {
ElasticSearchThreadPoolRunStateInfo esThreadPoolRunStateInfo = BeanUtil.convert(poolRunStateInfo, ElasticSearchThreadPoolRunStateInfo.class);
@ -147,11 +148,34 @@ public class WebThreadPoolElasticSearchMonitorHandler extends AbstractWebThreadP
@Builder
private static class EsIndex {
String index;
String type;
String mapping;
Integer shards;
Integer replicas;
String alias;
/**
* index
*/
private String index;
/**
* type
*/
private String type;
/**
* mapping
*/
private String mapping;
/**
* shards
*/
private Integer shards;
/**
* replicas
*/
private Integer replicas;
/**
* alias
*/
private String alias;
}
}
Loading…
Cancel
Save