-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added type information to serializable classes (#109)
* added type information to serializable classes * snapshot version bump Co-authored-by: Paul Latzelsperger <[email protected]>
- Loading branch information
1 parent
2b7b4c3
commit 5e00144
Showing
11 changed files
with
120 additions
and
24 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
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
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
61 changes: 61 additions & 0 deletions
61
spi/src/test/java/com/microsoft/dagx/spi/types/domain/transfer/TransferTypeTest.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,61 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* All rights reserved. | ||
* | ||
*/ | ||
|
||
package com.microsoft.dagx.spi.types.domain.transfer; | ||
|
||
import com.microsoft.dagx.spi.types.TypeManager; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class TransferTypeTest { | ||
|
||
private TypeManager tm; | ||
|
||
@BeforeEach | ||
void setup() { | ||
tm = new TypeManager(); | ||
tm.registerTypes(TransferType.class); | ||
} | ||
|
||
@Test | ||
void verifySerialization() { | ||
var tt = TransferType.Builder.transferType() | ||
.isFinite(false) | ||
.contentType("someContentType") | ||
.build(); | ||
|
||
var json = tm.writeValueAsString(tt); | ||
|
||
assertThat(json).contains("\"contentType\":\"someContentType\""); | ||
assertThat(json).contains("\"isFinite\":false"); | ||
//noinspection unchecked | ||
final Map<String, Object> map = (Map<String, Object>) tm.readValue(json, Map.class); | ||
assertThat(map).hasSize(2); | ||
assertThat(map).containsKey("contentType"); | ||
assertThat(map).containsKey("isFinite"); | ||
assertThat(map).doesNotContainKey("dagxtype"); | ||
} | ||
|
||
@Test | ||
void verifyDeserialization() { | ||
var tt = TransferType.Builder.transferType() | ||
.isFinite(false) | ||
.contentType("someContentType") | ||
.build(); | ||
|
||
var json = tm.writeValueAsString(tt); | ||
|
||
var restored = tm.readValue(json, TransferType.class); | ||
assertThat(restored).usingRecursiveComparison().isEqualTo(tt); | ||
assertThat(restored.isFinite()).isFalse(); | ||
assertThat(restored.getContentType()).isEqualTo("someContentType"); | ||
} | ||
|
||
} |