-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from jitwxs/dev
1.7-RELEASE
- Loading branch information
Showing
39 changed files
with
1,231 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
easydata-sample/src/test/java/io/github/jitwxs/easydata/sample/bean/FieldPropertyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.github.jitwxs.easydata.sample.bean; | ||
|
||
import io.github.jitwxs.easydata.common.bean.FieldProperty; | ||
import io.github.jitwxs.easydata.sample.message.MessageProto; | ||
import lombok.SneakyThrows; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.beans.Introspector; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
/** | ||
* @author jitwxs@foxmail.com | ||
* @since 2022-05-20 23:36 | ||
*/ | ||
public class FieldPropertyTest { | ||
@Test | ||
@SneakyThrows | ||
public void testForProto() { | ||
final Map<String, FieldProperty> properties = FieldProperty.newInstance(MessageProto.OrderEvaluate.class); | ||
|
||
assertNotNull(properties); | ||
assertEquals(MessageProto.OrderEvaluate.newBuilder().getDescriptorForType().getFields().size(), properties.size()); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void testForJava() { | ||
final Map<String, FieldProperty> properties = FieldProperty.newInstance(OrderEvaluate.class); | ||
|
||
assertNotNull(properties); | ||
assertEquals(Introspector.getBeanInfo(OrderEvaluate.class, Object.class).getPropertyDescriptors().length, properties.size()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...-sample/src/test/java/io/github/jitwxs/easydata/sample/core/convert/ProtoConvertTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.github.jitwxs.easydata.sample.core.convert; | ||
|
||
import io.github.jitwxs.easydata.common.enums.ClassDiffVerifyStrategyEnum; | ||
import io.github.jitwxs.easydata.core.mock.EasyMock; | ||
import io.github.jitwxs.easydata.core.verify.EasyVerify; | ||
import io.github.jitwxs.easydata.provider.ConvertProvider; | ||
import io.github.jitwxs.easydata.provider.ProviderFactory; | ||
import io.github.jitwxs.easydata.sample.message.MessageProto; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* @author jitwxs@foxmail.com | ||
* @since 2022-05-21 18:30 | ||
*/ | ||
public class ProtoConvertTest { | ||
|
||
private final static ConvertProvider delegate = ProviderFactory.delegate(ConvertProvider.class); | ||
|
||
@Test | ||
public void builder2Message() { | ||
final MessageProto.OrderEvaluate.Builder protoBuilder = EasyMock.run(MessageProto.OrderEvaluate.Builder.class); | ||
|
||
final MessageProto.OrderEvaluate protoMessage = delegate.convert(protoBuilder, MessageProto.OrderEvaluate.class); | ||
|
||
EasyVerify.with(protoBuilder, protoMessage).ignoreClassDiff(ClassDiffVerifyStrategyEnum.VERIFY_SAME_FIELD).verify(); | ||
} | ||
|
||
@Test | ||
public void message2Builder() { | ||
final MessageProto.OrderEvaluate protoMessage = EasyMock.run(MessageProto.OrderEvaluate.class); | ||
|
||
final MessageProto.OrderEvaluate.Builder protoBuilder = delegate.convert(protoMessage, MessageProto.OrderEvaluate.Builder.class); | ||
|
||
EasyVerify.with(protoMessage, protoBuilder).ignoreClassDiff(ClassDiffVerifyStrategyEnum.VERIFY_SAME_FIELD).verify(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
easydata/src/main/java/io/github/jitwxs/easydata/common/bean/ClassProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.github.jitwxs.easydata.common.bean; | ||
|
||
import io.github.jitwxs.easydata.common.exception.EasyDataException; | ||
import lombok.Getter; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author jitwxs@foxmail.com | ||
* @since 2022-05-21 0:09 | ||
*/ | ||
@Getter | ||
public class ClassProperty { | ||
private final Class<?> target; | ||
|
||
private final Map<String, FieldProperty> all = new HashMap<>(); | ||
|
||
private final Map<String, FieldProperty> readable = new HashMap<>(); | ||
|
||
private final Map<String, FieldProperty> writeAble = new HashMap<>(); | ||
|
||
private final Map<String, FieldProperty> readAndWriteAble = new HashMap<>(); | ||
|
||
public ClassProperty(Class<?> clazz) { | ||
this.target = clazz; | ||
|
||
try { | ||
final Map<String, FieldProperty> propertyMap = FieldProperty.newInstance(this.target); | ||
|
||
propertyMap.forEach((k, v) -> { | ||
this.all.put(k, v); | ||
|
||
if (v.isReadable()) { | ||
this.readable.put(k, v); | ||
} | ||
|
||
if (v.isWriteable()) { | ||
this.writeAble.put(k, v); | ||
} | ||
|
||
if (v.isReadable() && v.isWriteable()) { | ||
this.readAndWriteAble.put(k, v); | ||
} | ||
}); | ||
} catch (Exception e) { | ||
throw new EasyDataException(String.format("Cache Class %s Property Failed", clazz), e); | ||
} | ||
} | ||
} |
Oops, something went wrong.