From fedd095db42afc289641a943212aa3d5803d62fc Mon Sep 17 00:00:00 2001 From: Mykhailo_Beheka Date: Tue, 29 Nov 2022 17:19:58 +0200 Subject: [PATCH] Improved test of CrazyGenerics exercise. The test won't crash if change order of bound parameters --- .../com/bobocode/basics/CrazyGenericsTest.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/1-0-java-basics/1-3-1-crazy-generics/src/test/java/com/bobocode/basics/CrazyGenericsTest.java b/1-0-java-basics/1-3-1-crazy-generics/src/test/java/com/bobocode/basics/CrazyGenericsTest.java index 6a9df6eb..cf8807f5 100644 --- a/1-0-java-basics/1-3-1-crazy-generics/src/test/java/com/bobocode/basics/CrazyGenericsTest.java +++ b/1-0-java-basics/1-3-1-crazy-generics/src/test/java/com/bobocode/basics/CrazyGenericsTest.java @@ -288,14 +288,12 @@ void strictProcessorTypeParameterIsCalledT() { void strictProcessorTypeParameterIsBoundBySerializableAndComparable() { var typeParameters = StrictProcessor.class.getTypeParameters(); var typeParam = typeParameters[0]; - assert (typeParam.getBounds().length == 2); - var serializableBoundType = typeParam.getBounds()[0]; - var comparableBoundType = typeParam.getBounds()[1]; - - assertThat(serializableBoundType.getTypeName()) - .isEqualTo(Serializable.class.getTypeName()); - assertThat(comparableBoundType.getTypeName()) - .isEqualTo(String.format("%s<%s>", Comparable.class.getTypeName(), TYPE_PARAMETER_NAME)); + + assertThat(typeParam.getBounds()) + .hasSize(2) + .extracting(Type::getTypeName) + .containsExactlyInAnyOrder(Serializable.class.getTypeName(), + String.format("%s<%s>", Comparable.class.getTypeName(), TYPE_PARAMETER_NAME)); } @Test