Skip to content

Commit fedd095

Browse files
Improved test of CrazyGenerics exercise. The test won't crash if change order of bound parameters
1 parent 268f5f9 commit fedd095

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

1-0-java-basics/1-3-1-crazy-generics/src/test/java/com/bobocode/basics/CrazyGenericsTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,12 @@ void strictProcessorTypeParameterIsCalledT() {
288288
void strictProcessorTypeParameterIsBoundBySerializableAndComparable() {
289289
var typeParameters = StrictProcessor.class.getTypeParameters();
290290
var typeParam = typeParameters[0];
291-
assert (typeParam.getBounds().length == 2);
292-
var serializableBoundType = typeParam.getBounds()[0];
293-
var comparableBoundType = typeParam.getBounds()[1];
294-
295-
assertThat(serializableBoundType.getTypeName())
296-
.isEqualTo(Serializable.class.getTypeName());
297-
assertThat(comparableBoundType.getTypeName())
298-
.isEqualTo(String.format("%s<%s>", Comparable.class.getTypeName(), TYPE_PARAMETER_NAME));
291+
292+
assertThat(typeParam.getBounds())
293+
.hasSize(2)
294+
.extracting(Type::getTypeName)
295+
.containsExactlyInAnyOrder(Serializable.class.getTypeName(),
296+
String.format("%s<%s>", Comparable.class.getTypeName(), TYPE_PARAMETER_NAME));
299297
}
300298

301299
@Test

0 commit comments

Comments
 (0)