Skip to content

Commit

Permalink
Adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RobFaustLZ committed Dec 6, 2023
1 parent 295a6f7 commit 9f594e3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repositories {
}

dependencies {
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.16.0'
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
Expand Down
30 changes: 30 additions & 0 deletions src/test/java/com/labelzoom/api/DeepCopyTests.java
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);
}
}

0 comments on commit 9f594e3

Please sign in to comment.