-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
107 additions
and
4 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
48 changes: 48 additions & 0 deletions
48
.../java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMasksSerializationTest.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,48 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.data.genotype; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.math.BigInteger; | ||
import java.util.concurrent.ThreadLocalRandom; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class VariantMasksSerializationTest { | ||
|
||
@Test | ||
public void testFieldMaxLength() throws JsonProcessingException { | ||
VariantMasks variantMasks = new VariantMasks(); | ||
|
||
StringBuilder homozygousStr = new StringBuilder(); | ||
for (int i = 0 ; i < 5000; i++) { | ||
homozygousStr.append(ThreadLocalRandom.current().nextInt(0, 10)); | ||
} | ||
variantMasks.homozygousMask = new BigInteger(homozygousStr.toString()); | ||
|
||
StringBuilder heterozygousStr = new StringBuilder(); | ||
for (int i = 0 ; i < 5000; i++) { | ||
heterozygousStr.append(ThreadLocalRandom.current().nextInt(0, 10)); | ||
} | ||
variantMasks.heterozygousMask = new BigInteger(heterozygousStr.toString()); | ||
|
||
StringBuilder homozygousNoCallStr = new StringBuilder(); | ||
for (int i = 0 ; i < 5000; i++) { | ||
homozygousNoCallStr.append(ThreadLocalRandom.current().nextInt(0, 10)); | ||
} | ||
variantMasks.homozygousNoCallMask = new BigInteger(homozygousNoCallStr.toString()); | ||
|
||
StringBuilder heterozygousNoCallStr = new StringBuilder(); | ||
for (int i = 0 ; i < 5000; i++) { | ||
heterozygousNoCallStr.append(ThreadLocalRandom.current().nextInt(0, 10)); | ||
} | ||
variantMasks.heterozygousNoCallMask = new BigInteger(heterozygousNoCallStr.toString()); | ||
|
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
String serialized = objectMapper.writeValueAsString(variantMasks); | ||
VariantMasks deserialized = objectMapper.readValue(serialized, VariantMasks.class); | ||
|
||
assertEquals(variantMasks, deserialized); | ||
} | ||
} |