Skip to content

Commit 9f594e3

Browse files
committed
Adding tests
1 parent 295a6f7 commit 9f594e3

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ repositories {
1717
}
1818

1919
dependencies {
20+
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.16.0'
2021
testImplementation platform('org.junit:junit-bom:5.9.1')
2122
testImplementation 'org.junit.jupiter:junit-jupiter'
2223
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.labelzoom.api;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.labelzoom.api.model.components.CLabel;
5+
import org.junit.jupiter.api.Disabled;
6+
import org.junit.jupiter.api.Test;
7+
8+
import static org.junit.jupiter.api.Assertions.*;
9+
10+
/**
11+
* TODO: This test was succeeding when I ran it, but since I don't think the ordering of fields can be guaranteed, I
12+
* disabled the test so that it won't interrupt CI/CD. But this is something we should expand on in the future. The
13+
* goal is to ensure that if a developer adds a new field to a component, that they also update the cloning / deep copy
14+
* logic. May look to use reflection to randomize the data in each field of the component.
15+
*/
16+
public class DeepCopyTests
17+
{
18+
final ObjectMapper objectMapper = new ObjectMapper();
19+
20+
@Test
21+
@Disabled
22+
void testSimpleClone()
23+
{
24+
final CLabel label = new CLabel();
25+
final CLabel clone = label.clone();
26+
final String labelSerialized = assertDoesNotThrow(() -> objectMapper.writeValueAsString(label));
27+
final String cloneSerialized = assertDoesNotThrow(() -> objectMapper.writeValueAsString(clone));
28+
assertEquals(labelSerialized, cloneSerialized);
29+
}
30+
}

0 commit comments

Comments
 (0)