-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted UUID item type to be a child type of IStringItem to allow fa…
…llback compairison as a string. (#103)
- Loading branch information
1 parent
61a978d
commit 39c7974
Showing
3 changed files
with
60 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
40 changes: 40 additions & 0 deletions
40
core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IUUIDItemTest.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,40 @@ | ||
/* | ||
* SPDX-FileCopyrightText: none | ||
* SPDX-License-Identifier: CC0-1.0 | ||
*/ | ||
|
||
package gov.nist.secauto.metaschema.core.metapath.item.atomic; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.UUID; | ||
import java.util.stream.Stream; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
|
||
class IUuidItemTest { | ||
private static Stream<Arguments> testCompare() { // NOPMD - false positive | ||
UUID uuidRandom = UUID.randomUUID(); | ||
UUID uuid1 = UUID.fromString("4cfa2c52-9345-4012-8055-0bc9ac9b03fa"); | ||
UUID uuid2 = UUID.fromString("25a6d916-f179-4550-ad2b-7e7cd9df35d2"); | ||
String uuid2String = uuid2.toString(); | ||
|
||
return Stream.of( | ||
Arguments.of(IUuidItem.valueOf(uuidRandom), IUuidItem.valueOf(uuidRandom), IIntegerItem.ZERO), | ||
Arguments.of(IUuidItem.valueOf(uuid1), IUuidItem.valueOf(uuid2), IIntegerItem.valueOf(2)), | ||
Arguments.of(IUuidItem.valueOf(uuid2), IStringItem.valueOf(uuid2String), IIntegerItem.ZERO), | ||
Arguments.of(IStringItem.valueOf(uuid2String), IUuidItem.valueOf(uuid2), IIntegerItem.ZERO)); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource | ||
void testCompare(@NonNull IAnyAtomicItem left, @NonNull IAnyAtomicItem right, @NonNull IIntegerItem expectedResult) { | ||
IIntegerItem result = IIntegerItem.valueOf(left.compareTo(right)); | ||
assertEquals(expectedResult, result); | ||
} | ||
|
||
} |