-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional IBDO parameter diff options.
- Loading branch information
James Cover jdcove2
committed
Oct 5, 2023
1 parent
ef13f6a
commit d2ac679
Showing
4 changed files
with
287 additions
and
3 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
134 changes: 134 additions & 0 deletions
134
src/test/java/emissary/core/DiffCheckConfigurationTest.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,134 @@ | ||
package emissary.core; | ||
|
||
import emissary.core.DiffCheckConfiguration.DiffCheckBuilder; | ||
import emissary.core.DiffCheckConfiguration.DiffCheckOptions; | ||
import emissary.test.core.junit5.UnitTest; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class DiffCheckConfigurationTest extends UnitTest { | ||
@Test | ||
void testNonParameter() { | ||
final DiffCheckBuilder diffCheckBuilder = DiffCheckConfiguration.configure(); | ||
final DiffCheckConfiguration emptyConfiguration = diffCheckBuilder.build(); | ||
|
||
assertEquals(0, emptyConfiguration.getEnabled().size(), "Configuration should be empty!"); | ||
|
||
diffCheckBuilder.enableData(); | ||
diffCheckBuilder.enableInternalId(); | ||
diffCheckBuilder.enableTimestamp(); | ||
diffCheckBuilder.enableTransformHistory(); | ||
|
||
final DiffCheckConfiguration nonParameterConfiguration = diffCheckBuilder.build(); | ||
|
||
assertTrue(nonParameterConfiguration.checkData()); | ||
assertTrue(nonParameterConfiguration.checkInternalId()); | ||
assertTrue(nonParameterConfiguration.checkTimestamp()); | ||
assertTrue(nonParameterConfiguration.checkTransformHistory()); | ||
assertFalse(nonParameterConfiguration.checkDetailedParameterDiff()); | ||
assertFalse(nonParameterConfiguration.checkKeyValueParameterDiff()); | ||
|
||
diffCheckBuilder.disableData(); | ||
diffCheckBuilder.disableInternalId(); | ||
diffCheckBuilder.disableTimestamp(); | ||
diffCheckBuilder.disableTransformHistory(); | ||
|
||
assertEquals(0, diffCheckBuilder.build().getEnabled().size(), "Configuration should be empty!"); | ||
} | ||
|
||
@Test | ||
void testKeyValueDetailed() { | ||
final DiffCheckBuilder diffCheckBuilder = DiffCheckConfiguration.configure(); | ||
|
||
diffCheckBuilder.enableDetailedParameterDiff(); | ||
|
||
final DiffCheckConfiguration detailedParameterConfiguration = diffCheckBuilder.build(); | ||
|
||
assertTrue(detailedParameterConfiguration.checkDetailedParameterDiff()); | ||
assertFalse(detailedParameterConfiguration.checkKeyValueParameterDiff()); | ||
|
||
diffCheckBuilder.enableKeyValueParameterDiff(); | ||
|
||
final DiffCheckConfiguration keyValueParameterConfiguration = diffCheckBuilder.build(); | ||
|
||
assertFalse(keyValueParameterConfiguration.checkDetailedParameterDiff()); | ||
assertTrue(keyValueParameterConfiguration.checkKeyValueParameterDiff()); | ||
|
||
diffCheckBuilder.disableKeyValueParameterDiff(); | ||
|
||
assertEquals(0, diffCheckBuilder.build().getEnabled().size(), "Configuration should be empty!"); | ||
|
||
diffCheckBuilder.enableKeyValueParameterDiff(); | ||
|
||
final DiffCheckConfiguration KeyValueParameterConfiguration2 = diffCheckBuilder.build(); | ||
|
||
assertFalse(KeyValueParameterConfiguration2.checkDetailedParameterDiff()); | ||
assertTrue(KeyValueParameterConfiguration2.checkKeyValueParameterDiff()); | ||
|
||
diffCheckBuilder.enableDetailedParameterDiff(); | ||
|
||
final DiffCheckConfiguration detailedParameterConfiguration2 = diffCheckBuilder.build(); | ||
|
||
assertTrue(detailedParameterConfiguration2.checkDetailedParameterDiff()); | ||
assertFalse(detailedParameterConfiguration2.checkKeyValueParameterDiff()); | ||
|
||
diffCheckBuilder.disableDetailedParameterDiff(); | ||
|
||
assertEquals(0, diffCheckBuilder.build().getEnabled().size(), "Configuration should be empty!"); | ||
} | ||
|
||
@Test | ||
void checkReset() { | ||
final DiffCheckBuilder diffCheckBuilder = DiffCheckConfiguration.configure(); | ||
|
||
diffCheckBuilder.enableData(); | ||
diffCheckBuilder.enableInternalId(); | ||
diffCheckBuilder.enableTimestamp(); | ||
diffCheckBuilder.enableTransformHistory(); | ||
diffCheckBuilder.enableDetailedParameterDiff(); | ||
diffCheckBuilder.reset(); | ||
|
||
assertEquals(0, diffCheckBuilder.build().getEnabled().size(), "Configuration should be empty!"); | ||
} | ||
|
||
@Test | ||
void checkExplicit() { | ||
final DiffCheckBuilder diffCheckBuilder = DiffCheckConfiguration.configure(); | ||
final DiffCheckConfiguration explicitDetailedConfiguration = diffCheckBuilder.explicit( | ||
DiffCheckOptions.DATA, | ||
DiffCheckOptions.DETAILED_PARAMETER_DIFF, | ||
DiffCheckOptions.INTERNAL_ID, | ||
DiffCheckOptions.TIMESTAMP, | ||
DiffCheckOptions.TRANSFORM_HISTORY); | ||
|
||
assertTrue(explicitDetailedConfiguration.checkData()); | ||
assertTrue(explicitDetailedConfiguration.checkInternalId()); | ||
assertTrue(explicitDetailedConfiguration.checkTimestamp()); | ||
assertTrue(explicitDetailedConfiguration.checkTransformHistory()); | ||
assertTrue(explicitDetailedConfiguration.checkDetailedParameterDiff()); | ||
assertFalse(explicitDetailedConfiguration.checkKeyValueParameterDiff()); | ||
|
||
final DiffCheckConfiguration explicitKeyValueConfiguration = diffCheckBuilder.explicit( | ||
DiffCheckOptions.DATA, | ||
DiffCheckOptions.KEY_VALUE_PARAMETER_DIFF, | ||
DiffCheckOptions.INTERNAL_ID, | ||
DiffCheckOptions.TIMESTAMP, | ||
DiffCheckOptions.TRANSFORM_HISTORY); | ||
|
||
assertTrue(explicitKeyValueConfiguration.checkData()); | ||
assertTrue(explicitKeyValueConfiguration.checkInternalId()); | ||
assertTrue(explicitKeyValueConfiguration.checkTimestamp()); | ||
assertTrue(explicitKeyValueConfiguration.checkTransformHistory()); | ||
assertFalse(explicitKeyValueConfiguration.checkDetailedParameterDiff()); | ||
assertTrue(explicitKeyValueConfiguration.checkKeyValueParameterDiff()); | ||
|
||
assertThrows(IllegalArgumentException.class, () -> diffCheckBuilder.explicit( | ||
DiffCheckOptions.DETAILED_PARAMETER_DIFF, | ||
DiffCheckOptions.KEY_VALUE_PARAMETER_DIFF)); | ||
} | ||
} |
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