This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 475c53908d5ed456eefa21a1e4b4f81a91969e5c Author: Matthieu Baechler <[email protected]> AuthorDate: Mon Oct 21 12:04:52 2019 +0200 JAMES-2813 demonstrate how to handle nested DTOs with some tests --- .../src/test/java/org/apache/DTOConverterTest.java | 11 ++++--- .../java/org/apache/JsonGenericSerializerTest.java | 28 +++++++++++++++-- json/src/test/java/org/apache/dto/FirstDTO.java | 14 +++++++-- .../java/org/apache/dto/FirstDomainObject.java | 11 +++++-- .../dto/{SecondDTO.java => FirstNestedDTO.java} | 34 ++++++++------------- ...econdDomainObject.java => FirstNestedType.java} | 26 ++++++---------- .../{SecondDomainObject.java => NestedType.java} | 34 +-------------------- json/src/test/java/org/apache/dto/SecondDTO.java | 15 ++++++++-- .../java/org/apache/dto/SecondDomainObject.java | 12 ++++++-- .../dto/{SecondDTO.java => SecondNestedDTO.java} | 33 ++++++++------------ ...condDomainObject.java => SecondNestedType.java} | 26 ++++++---------- json/src/test/java/org/apache/dto/TestModules.java | 33 +++++++++++++++++--- ...condDomainObject.java => TestNestedModule.java} | 35 ++++------------------ 13 files changed, 153 insertions(+), 159 deletions(-) diff --git a/json/src/test/java/org/apache/DTOConverterTest.java b/json/src/test/java/org/apache/DTOConverterTest.java index 3987dbd..d75fffe 100644 --- a/json/src/test/java/org/apache/DTOConverterTest.java +++ b/json/src/test/java/org/apache/DTOConverterTest.java @@ -29,6 +29,7 @@ import java.util.stream.Stream; import org.apache.dto.BaseType; import org.apache.dto.FirstDTO; import org.apache.dto.FirstDomainObject; +import org.apache.dto.NestedType; import org.apache.dto.SecondDTO; import org.apache.dto.SecondDomainObject; import org.apache.dto.TestModules; @@ -40,10 +41,12 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; class DTOConverterTest { - private static final FirstDomainObject FIRST = new FirstDomainObject(Optional.of(1L), ZonedDateTime.parse("2016-04-03T02:01+07:00[Asia/Vientiane]"), "first payload"); - private static final FirstDTO FIRST_DTO = new FirstDTO("first", Optional.of(1L), "2016-04-03T02:01+07:00[Asia/Vientiane]", "first payload"); - private static final SecondDomainObject SECOND = new SecondDomainObject(UUID.fromString("4a2c853f-7ffc-4ce3-9410-a47e85b3b741"), "second payload"); - private static final SecondDTO SECOND_DTO = new SecondDTO("second", "4a2c853f-7ffc-4ce3-9410-a47e85b3b741", "second payload"); + private static final Optional<NestedType> NO_CHILD = Optional.empty(); + private static final Optional<DTO> NO_CHILD_DTO = Optional.empty(); + private static final FirstDomainObject FIRST = new FirstDomainObject(Optional.of(1L), ZonedDateTime.parse("2016-04-03T02:01+07:00[Asia/Vientiane]"), "first payload", NO_CHILD); + private static final FirstDTO FIRST_DTO = new FirstDTO("first", Optional.of(1L), "2016-04-03T02:01+07:00[Asia/Vientiane]", "first payload", NO_CHILD_DTO); + private static final SecondDomainObject SECOND = new SecondDomainObject(UUID.fromString("4a2c853f-7ffc-4ce3-9410-a47e85b3b741"), "second payload", NO_CHILD); + private static final SecondDTO SECOND_DTO = new SecondDTO("second", "4a2c853f-7ffc-4ce3-9410-a47e85b3b741", "second payload", NO_CHILD_DTO); @SuppressWarnings("unchecked") @Test diff --git a/json/src/test/java/org/apache/JsonGenericSerializerTest.java b/json/src/test/java/org/apache/JsonGenericSerializerTest.java index 8205553..3fc6c45 100644 --- a/json/src/test/java/org/apache/JsonGenericSerializerTest.java +++ b/json/src/test/java/org/apache/JsonGenericSerializerTest.java @@ -30,7 +30,10 @@ import java.util.stream.Stream; import org.apache.dto.BaseType; import org.apache.dto.FirstDomainObject; +import org.apache.dto.FirstNestedType; +import org.apache.dto.NestedType; import org.apache.dto.SecondDomainObject; +import org.apache.dto.SecondNestedType; import org.apache.dto.TestModules; import org.apache.james.json.DTO; import org.apache.james.json.JsonGenericSerializer; @@ -40,13 +43,18 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; class JsonGenericSerializerTest { - private static final FirstDomainObject FIRST = new FirstDomainObject(Optional.of(1L), ZonedDateTime.parse("2016-04-03T02:01+07:00[Asia/Vientiane]"), "first payload"); - private static final SecondDomainObject SECOND = new SecondDomainObject(UUID.fromString("4a2c853f-7ffc-4ce3-9410-a47e85b3b741"), "second payload"); + private static final Optional<NestedType> NO_CHILD = Optional.empty(); + private static final FirstDomainObject FIRST = new FirstDomainObject(Optional.of(1L), ZonedDateTime.parse("2016-04-03T02:01+07:00[Asia/Vientiane]"), "first payload", NO_CHILD); + private static final SecondDomainObject SECOND = new SecondDomainObject(UUID.fromString("4a2c853f-7ffc-4ce3-9410-a47e85b3b741"), "second payload", NO_CHILD); + private static final SecondDomainObject SECOND_WITH_NESTED = new SecondDomainObject(UUID.fromString("4a2c853f-7ffc-4ce3-9410-a47e85b3b741"), "second payload", Optional.of(new FirstNestedType(12))); + private static final FirstDomainObject FIRST_WITH_NESTED = new FirstDomainObject(Optional.of(1L), ZonedDateTime.parse("2016-04-03T02:01+07:00[Asia/Vientiane]"), "payload", Optional.of(new SecondNestedType("bar"))); private static final String MISSING_TYPE_JSON = "{\"id\":1,\"time\":\"2016-04-03T02:01+07:00[Asia/Vientiane]\",\"payload\":\"first payload\"}"; private static final String DUPLICATE_TYPE_JSON = "{\"type\":\"first\", \"type\":\"second\", \"id\":1,\"time\":\"2016-04-03T02:01+07:00[Asia/Vientiane]\",\"payload\":\"first payload\"}"; private static final String FIRST_JSON = "{\"type\":\"first\",\"id\":1,\"time\":\"2016-04-03T02:01+07:00[Asia/Vientiane]\",\"payload\":\"first payload\"}"; + private static final String FIRST_JSON_WITH_NESTED = "{\"type\":\"first\",\"id\":1,\"time\":\"2016-04-03T02:01+07:00[Asia/Vientiane]\",\"payload\":\"payload\", \"child\": {\"bar\": \"bar\", \"type\": \"second-nested\"}}"; private static final String SECOND_JSON = "{\"type\":\"second\",\"id\":\"4a2c853f-7ffc-4ce3-9410-a47e85b3b741\",\"payload\":\"second payload\"}"; + private static final String SECOND_WITH_NESTED_JSON = "{\"type\":\"second\",\"id\":\"4a2c853f-7ffc-4ce3-9410-a47e85b3b741\",\"payload\":\"second payload\", \"child\": {\"foo\": 12, \"type\": \"first-nested\"}}"; @SuppressWarnings("unchecked") @Test @@ -58,6 +66,22 @@ class JsonGenericSerializerTest { @SuppressWarnings("unchecked") @Test + void shouldDeserializeNestedTypeWithSecond() throws Exception { + assertThat(JsonGenericSerializer.of(TestModules.FIRST_TYPE, TestModules.SECOND_TYPE, TestModules.FIRST_NESTED, TestModules.SECOND_NESTED) + .deserialize(SECOND_WITH_NESTED_JSON)) + .isEqualTo(SECOND_WITH_NESTED); + } + + @SuppressWarnings("unchecked") + @Test + void shouldDeserializeNestedTypeWithFirst() throws Exception { + assertThat(JsonGenericSerializer.of(TestModules.FIRST_TYPE, TestModules.SECOND_TYPE, TestModules.FIRST_NESTED, TestModules.SECOND_NESTED) + .deserialize(FIRST_JSON_WITH_NESTED)) + .isEqualTo(FIRST_WITH_NESTED); + } + + @SuppressWarnings("unchecked") + @Test void shouldThrowWhenDeserializeEventWithMissingType() { assertThatThrownBy(() -> JsonGenericSerializer.of(TestModules.FIRST_TYPE) .deserialize(MISSING_TYPE_JSON)) diff --git a/json/src/test/java/org/apache/dto/FirstDTO.java b/json/src/test/java/org/apache/dto/FirstDTO.java index 9e4f46b..b1bdf23 100644 --- a/json/src/test/java/org/apache/dto/FirstDTO.java +++ b/json/src/test/java/org/apache/dto/FirstDTO.java @@ -23,6 +23,7 @@ import java.time.ZonedDateTime; import java.util.Optional; import org.apache.james.json.DTO; +import org.apache.james.json.DTOConverter; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -33,17 +34,20 @@ public class FirstDTO implements DTO { private final Optional<Long> id; private final String time; private final String payload; + private final Optional<DTO> child; @JsonCreator public FirstDTO( @JsonProperty("type") String type, @JsonProperty("id") Optional<Long> id, @JsonProperty("time") String time, - @JsonProperty("payload") String payload) { + @JsonProperty("payload") String payload, + @JsonProperty("child") Optional<DTO> child) { this.type = type; this.id = id; this.time = time; this.payload = payload; + this.child = child; } public String getType() { @@ -62,8 +66,12 @@ public class FirstDTO implements DTO { return payload; } + public Optional<DTO> getChild() { + return child; + } + @JsonIgnore - public FirstDomainObject toDomainObject() { - return new FirstDomainObject(id, ZonedDateTime.parse(time), payload); + public FirstDomainObject toDomainObject(DTOConverter<NestedType, DTO> converter) { + return new FirstDomainObject(id, ZonedDateTime.parse(time), payload, child.flatMap(converter::convert)); } } diff --git a/json/src/test/java/org/apache/dto/FirstDomainObject.java b/json/src/test/java/org/apache/dto/FirstDomainObject.java index 6c8a787..13e8462 100644 --- a/json/src/test/java/org/apache/dto/FirstDomainObject.java +++ b/json/src/test/java/org/apache/dto/FirstDomainObject.java @@ -27,11 +27,13 @@ public class FirstDomainObject implements BaseType { private final Optional<Long> id; private final ZonedDateTime time; private final String payload; + private final Optional<NestedType> child; - public FirstDomainObject(Optional<Long> id, ZonedDateTime time, String payload) { + public FirstDomainObject(Optional<Long> id, ZonedDateTime time, String payload, Optional<NestedType> child) { this.id = id; this.time = time; this.payload = payload; + this.child = child; } public Optional<Long> getId() { @@ -46,6 +48,10 @@ public class FirstDomainObject implements BaseType { return payload; } + public Optional<NestedType> getChild() { + return child; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -53,11 +59,12 @@ public class FirstDomainObject implements BaseType { FirstDomainObject that = (FirstDomainObject) o; return Objects.equals(id, that.id) && Objects.equals(time, that.time) && + Objects.equals(child, that.child) && Objects.equals(payload, that.payload); } @Override public int hashCode() { - return Objects.hash(id, time, payload); + return Objects.hash(id, time, child, payload); } } diff --git a/json/src/test/java/org/apache/dto/SecondDTO.java b/json/src/test/java/org/apache/dto/FirstNestedDTO.java similarity index 73% copy from json/src/test/java/org/apache/dto/SecondDTO.java copy to json/src/test/java/org/apache/dto/FirstNestedDTO.java index d31929a..9fd7498 100644 --- a/json/src/test/java/org/apache/dto/SecondDTO.java +++ b/json/src/test/java/org/apache/dto/FirstNestedDTO.java @@ -19,43 +19,35 @@ package org.apache.dto; -import java.util.UUID; - import org.apache.james.json.DTO; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -public class SecondDTO implements DTO { +public class FirstNestedDTO implements DTO { + private final int foo; private final String type; - private final String id; - private final String payload; @JsonCreator - public SecondDTO( - @JsonProperty("type") String type, - @JsonProperty("id") String id, - @JsonProperty("payload") String payload) { + public FirstNestedDTO(@JsonProperty("foo") int foo, + @JsonProperty("type") String type) { + this.foo = foo; this.type = type; - this.id = id; - this.payload = payload; - } - - public String getType() { - return type; } - public String getId() { - return id; + public int getFoo() { + return foo; } - public String getPayload() { - return payload; + @Override + public String getType() { + return type; } @JsonIgnore - public SecondDomainObject toDomainObject() { - return new SecondDomainObject(UUID.fromString(id), payload); + public FirstNestedType toDomainObject() { + return new FirstNestedType(foo); } + } diff --git a/json/src/test/java/org/apache/dto/SecondDomainObject.java b/json/src/test/java/org/apache/dto/FirstNestedType.java similarity index 72% copy from json/src/test/java/org/apache/dto/SecondDomainObject.java copy to json/src/test/java/org/apache/dto/FirstNestedType.java index 30ac702..745a582 100644 --- a/json/src/test/java/org/apache/dto/SecondDomainObject.java +++ b/json/src/test/java/org/apache/dto/FirstNestedType.java @@ -20,36 +20,28 @@ package org.apache.dto; import java.util.Objects; -import java.util.UUID; -public class SecondDomainObject implements BaseType { - private final UUID id; - private final String payload; +public class FirstNestedType implements NestedType{ + final int foo; - public SecondDomainObject(UUID id, String payload) { - this.id = id; - this.payload = payload; + public FirstNestedType(int foo) { + this.foo = foo; } - public UUID getId() { - return id; - } - - public String getPayload() { - return payload; + public int getFoo() { + return foo; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - SecondDomainObject that = (SecondDomainObject) o; - return Objects.equals(id, that.id) && - Objects.equals(payload, that.payload); + FirstNestedType that = (FirstNestedType) o; + return foo == that.foo; } @Override public int hashCode() { - return Objects.hash(id, payload); + return Objects.hash(foo); } } diff --git a/json/src/test/java/org/apache/dto/SecondDomainObject.java b/json/src/test/java/org/apache/dto/NestedType.java similarity index 60% copy from json/src/test/java/org/apache/dto/SecondDomainObject.java copy to json/src/test/java/org/apache/dto/NestedType.java index 30ac702..80145ee 100644 --- a/json/src/test/java/org/apache/dto/SecondDomainObject.java +++ b/json/src/test/java/org/apache/dto/NestedType.java @@ -19,37 +19,5 @@ package org.apache.dto; -import java.util.Objects; -import java.util.UUID; - -public class SecondDomainObject implements BaseType { - private final UUID id; - private final String payload; - - public SecondDomainObject(UUID id, String payload) { - this.id = id; - this.payload = payload; - } - - public UUID getId() { - return id; - } - - public String getPayload() { - return payload; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SecondDomainObject that = (SecondDomainObject) o; - return Objects.equals(id, that.id) && - Objects.equals(payload, that.payload); - } - - @Override - public int hashCode() { - return Objects.hash(id, payload); - } +public interface NestedType { } diff --git a/json/src/test/java/org/apache/dto/SecondDTO.java b/json/src/test/java/org/apache/dto/SecondDTO.java index d31929a..be66948 100644 --- a/json/src/test/java/org/apache/dto/SecondDTO.java +++ b/json/src/test/java/org/apache/dto/SecondDTO.java @@ -19,9 +19,11 @@ package org.apache.dto; +import java.util.Optional; import java.util.UUID; import org.apache.james.json.DTO; +import org.apache.james.json.DTOConverter; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -31,15 +33,18 @@ public class SecondDTO implements DTO { private final String type; private final String id; private final String payload; + private final Optional<DTO> child; @JsonCreator public SecondDTO( @JsonProperty("type") String type, @JsonProperty("id") String id, - @JsonProperty("payload") String payload) { + @JsonProperty("payload") String payload, + @JsonProperty("child") Optional<DTO> child) { this.type = type; this.id = id; this.payload = payload; + this.child = child; } public String getType() { @@ -54,8 +59,12 @@ public class SecondDTO implements DTO { return payload; } + public Optional<DTO> getChild() { + return child; + } + @JsonIgnore - public SecondDomainObject toDomainObject() { - return new SecondDomainObject(UUID.fromString(id), payload); + public SecondDomainObject toDomainObject(DTOConverter<NestedType, DTO> converter) { + return new SecondDomainObject(UUID.fromString(id), payload, child.flatMap(converter::convert)); } } diff --git a/json/src/test/java/org/apache/dto/SecondDomainObject.java b/json/src/test/java/org/apache/dto/SecondDomainObject.java index 30ac702..5c20fc8 100644 --- a/json/src/test/java/org/apache/dto/SecondDomainObject.java +++ b/json/src/test/java/org/apache/dto/SecondDomainObject.java @@ -20,15 +20,18 @@ package org.apache.dto; import java.util.Objects; +import java.util.Optional; import java.util.UUID; public class SecondDomainObject implements BaseType { private final UUID id; private final String payload; + private final Optional<NestedType> child; - public SecondDomainObject(UUID id, String payload) { + public SecondDomainObject(UUID id, String payload, Optional<NestedType> child) { this.id = id; this.payload = payload; + this.child = child; } public UUID getId() { @@ -39,17 +42,22 @@ public class SecondDomainObject implements BaseType { return payload; } + public Optional<NestedType> getChild() { + return child; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SecondDomainObject that = (SecondDomainObject) o; return Objects.equals(id, that.id) && + Objects.equals(child, that.child) && Objects.equals(payload, that.payload); } @Override public int hashCode() { - return Objects.hash(id, payload); + return Objects.hash(id, child, payload); } } diff --git a/json/src/test/java/org/apache/dto/SecondDTO.java b/json/src/test/java/org/apache/dto/SecondNestedDTO.java similarity index 73% copy from json/src/test/java/org/apache/dto/SecondDTO.java copy to json/src/test/java/org/apache/dto/SecondNestedDTO.java index d31929a..9b86497 100644 --- a/json/src/test/java/org/apache/dto/SecondDTO.java +++ b/json/src/test/java/org/apache/dto/SecondNestedDTO.java @@ -19,43 +19,34 @@ package org.apache.dto; -import java.util.UUID; - import org.apache.james.json.DTO; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -public class SecondDTO implements DTO { +public class SecondNestedDTO implements DTO { + private final String bar; private final String type; - private final String id; - private final String payload; @JsonCreator - public SecondDTO( - @JsonProperty("type") String type, - @JsonProperty("id") String id, - @JsonProperty("payload") String payload) { + public SecondNestedDTO(@JsonProperty("bar") String bar, + @JsonProperty("type") String type) { + this.bar = bar; this.type = type; - this.id = id; - this.payload = payload; } - public String getType() { - return type; + public String getBar() { + return bar; } - public String getId() { - return id; - } - - public String getPayload() { - return payload; + @Override + public String getType() { + return type; } @JsonIgnore - public SecondDomainObject toDomainObject() { - return new SecondDomainObject(UUID.fromString(id), payload); + public SecondNestedType toDomainObject() { + return new SecondNestedType(bar); } } diff --git a/json/src/test/java/org/apache/dto/SecondDomainObject.java b/json/src/test/java/org/apache/dto/SecondNestedType.java similarity index 72% copy from json/src/test/java/org/apache/dto/SecondDomainObject.java copy to json/src/test/java/org/apache/dto/SecondNestedType.java index 30ac702..0bbbf2f 100644 --- a/json/src/test/java/org/apache/dto/SecondDomainObject.java +++ b/json/src/test/java/org/apache/dto/SecondNestedType.java @@ -20,36 +20,28 @@ package org.apache.dto; import java.util.Objects; -import java.util.UUID; -public class SecondDomainObject implements BaseType { - private final UUID id; - private final String payload; +public class SecondNestedType implements NestedType { + final String bar; - public SecondDomainObject(UUID id, String payload) { - this.id = id; - this.payload = payload; + public SecondNestedType(String bar) { + this.bar = bar; } - public UUID getId() { - return id; - } - - public String getPayload() { - return payload; + public String getBar() { + return bar; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - SecondDomainObject that = (SecondDomainObject) o; - return Objects.equals(id, that.id) && - Objects.equals(payload, that.payload); + SecondNestedType that = (SecondNestedType) o; + return Objects.equals(bar, that.bar); } @Override public int hashCode() { - return Objects.hash(id, payload); + return Objects.hash(bar); } } diff --git a/json/src/test/java/org/apache/dto/TestModules.java b/json/src/test/java/org/apache/dto/TestModules.java index 45c5418..ad4d04b 100644 --- a/json/src/test/java/org/apache/dto/TestModules.java +++ b/json/src/test/java/org/apache/dto/TestModules.java @@ -19,20 +19,44 @@ package org.apache.dto; +import org.apache.james.json.DTO; +import org.apache.james.json.DTOConverter; import org.apache.james.json.DTOModule; public interface TestModules { + TestNestedModule FIRST_NESTED = DTOModule + .forDomainObject(FirstNestedType.class) + .convertToDTO(FirstNestedDTO.class) + .toDomainObjectConverter(FirstNestedDTO::toDomainObject) + .toDTOConverter((domainObject, typeName) -> new FirstNestedDTO( + domainObject.getFoo(), + typeName)) + .typeName("first-nested") + .withFactory(TestNestedModule::new); + + TestNestedModule SECOND_NESTED = DTOModule + .forDomainObject(SecondNestedType.class) + .convertToDTO(SecondNestedDTO.class) + .toDomainObjectConverter(SecondNestedDTO::toDomainObject) + .toDTOConverter((domainObject, typeName) -> new SecondNestedDTO( + domainObject.getBar(), + typeName)) + .typeName("second-nested") + .withFactory(TestNestedModule::new); + + DTOConverter NESTED_CONVERTERS = DTOConverter.of(FIRST_NESTED, SECOND_NESTED); @SuppressWarnings("rawtypes") TestModule FIRST_TYPE = DTOModule .forDomainObject(FirstDomainObject.class) .convertToDTO(FirstDTO.class) - .toDomainObjectConverter(FirstDTO::toDomainObject) + .toDomainObjectConverter(dto -> dto.toDomainObject(NESTED_CONVERTERS)) .toDTOConverter((domainObject, typeName) -> new FirstDTO( typeName, domainObject.getId(), domainObject.getTime().toString(), - domainObject.getPayload())) + domainObject.getPayload(), + NESTED_CONVERTERS.convert(domainObject.getChild()))) .typeName("first") .withFactory(TestModule::new); @@ -40,11 +64,12 @@ public interface TestModules { TestModule SECOND_TYPE = DTOModule .forDomainObject(SecondDomainObject.class) .convertToDTO(SecondDTO.class) - .toDomainObjectConverter(SecondDTO::toDomainObject) + .toDomainObjectConverter(dto -> dto.toDomainObject(NESTED_CONVERTERS)) .toDTOConverter((domainObject, typeName) -> new SecondDTO( typeName, domainObject.getId().toString(), - domainObject.getPayload())) + domainObject.getPayload(), + NESTED_CONVERTERS.convert(domainObject.getChild()))) .typeName("second") .withFactory(TestModule::new); diff --git a/json/src/test/java/org/apache/dto/SecondDomainObject.java b/json/src/test/java/org/apache/dto/TestNestedModule.java similarity index 60% copy from json/src/test/java/org/apache/dto/SecondDomainObject.java copy to json/src/test/java/org/apache/dto/TestNestedModule.java index 30ac702..e67df12 100644 --- a/json/src/test/java/org/apache/dto/SecondDomainObject.java +++ b/json/src/test/java/org/apache/dto/TestNestedModule.java @@ -19,37 +19,12 @@ package org.apache.dto; -import java.util.Objects; -import java.util.UUID; +import org.apache.james.json.DTO; +import org.apache.james.json.DTOModule; -public class SecondDomainObject implements BaseType { - private final UUID id; - private final String payload; +public class TestNestedModule<T extends NestedType, U extends DTO> extends DTOModule<T, U> { - public SecondDomainObject(UUID id, String payload) { - this.id = id; - this.payload = payload; - } - - public UUID getId() { - return id; - } - - public String getPayload() { - return payload; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SecondDomainObject that = (SecondDomainObject) o; - return Objects.equals(id, that.id) && - Objects.equals(payload, that.payload); - } - - @Override - public int hashCode() { - return Objects.hash(id, payload); + protected TestNestedModule(DTOConverter<T, U> converter, DomainObjectConverter<T, U> toDomainObjectConverter, Class<T> domainObjectType, Class<U> dtoType, String typeName) { + super(converter, toDomainObjectConverter, domainObjectType, dtoType, typeName); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
