-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
295a6f7
commit 9f594e3
Showing
2 changed files
with
31 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.labelzoom.api; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.labelzoom.api.model.components.CLabel; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* TODO: This test was succeeding when I ran it, but since I don't think the ordering of fields can be guaranteed, I | ||
* disabled the test so that it won't interrupt CI/CD. But this is something we should expand on in the future. The | ||
* goal is to ensure that if a developer adds a new field to a component, that they also update the cloning / deep copy | ||
* logic. May look to use reflection to randomize the data in each field of the component. | ||
*/ | ||
public class DeepCopyTests | ||
{ | ||
final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
@Test | ||
@Disabled | ||
void testSimpleClone() | ||
{ | ||
final CLabel label = new CLabel(); | ||
final CLabel clone = label.clone(); | ||
final String labelSerialized = assertDoesNotThrow(() -> objectMapper.writeValueAsString(label)); | ||
final String cloneSerialized = assertDoesNotThrow(() -> objectMapper.writeValueAsString(clone)); | ||
assertEquals(labelSerialized, cloneSerialized); | ||
} | ||
} |