Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
fb07083b
Commit
fb07083b
authored
13 years ago
by
tpylak
Browse files
Options
Downloads
Patches
Plain Diff
test method to compare that 2 enums have the same values
SVN: 21304
parent
755e58f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/source/java/ch/systemsx/cisd/common/test/AssertionUtil.java
+30
-0
30 additions, 0 deletions
...urce/java/ch/systemsx/cisd/common/test/AssertionUtil.java
with
30 additions
and
0 deletions
common/source/java/ch/systemsx/cisd/common/test/AssertionUtil.java
+
30
−
0
View file @
fb07083b
...
...
@@ -19,6 +19,10 @@ package ch.systemsx.cisd.common.test;
import
static
org
.
testng
.
AssertJUnit
.
assertEquals
;
import
static
org
.
testng
.
AssertJUnit
.
assertTrue
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* Utilities for making assertions in unit tests.
*
...
...
@@ -79,4 +83,30 @@ public class AssertionUtil
}
}
/**
* asserts that two enums have the same values. Usage example:
*
* <pre>
* List<MyEnum1> values1 = Arrays.asList(MyEnum1.values());
* List<MyEnum2> values2 = Arrays.asList(MyEnum2.values());
* AssertionUtil.assertEnumsEqual(values1, values2);
* </pre>
*/
public
static
void
assertEnumsEqual
(
List
<?
extends
Enum
<?>>
values1
,
List
<?
extends
Enum
<?>>
values2
)
{
Set
<
String
>
valuesSet1
=
asSet
(
values1
);
Set
<
String
>
valuesSet2
=
asSet
(
values2
);
assertEquals
(
valuesSet1
,
valuesSet2
);
}
private
static
Set
<
String
>
asSet
(
List
<?
extends
Enum
<?>>
enumValues
)
{
Set
<
String
>
stringValues
=
new
HashSet
<
String
>();
for
(
Enum
<?>
enumInst
:
enumValues
)
{
stringValues
.
add
(
enumInst
.
name
());
}
return
stringValues
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment