From acb5ce6a2243c9c517caf7449225f3cfc219f39a Mon Sep 17 00:00:00 2001 From: Andrei Arlou Date: Wed, 14 Sep 2022 23:44:35 +0300 Subject: [PATCH] Use Hamcrest assertions instead of JUnit in common/common - backport helidon-2.x (#1749) --- .../java/io/helidon/common/ErrorsTest.java | 4 ++-- .../helidon/common/GenericTypeUtilTest.java | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/common/common/src/test/java/io/helidon/common/ErrorsTest.java b/common/common/src/test/java/io/helidon/common/ErrorsTest.java index d05fa82ae44..166f4e8aaf5 100644 --- a/common/common/src/test/java/io/helidon/common/ErrorsTest.java +++ b/common/common/src/test/java/io/helidon/common/ErrorsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ class ErrorsTest { private static final Logger LOGGER = Logger.getLogger(ErrorsTest.class.getName()); private static void assertErrorMessage(Optional actual, String expected, String message) { - assertThat(actual, not(Optional.empty())); + assertThat(message, actual, not(Optional.empty())); assertThat(actual.get().getMessage(), is(expected)); } diff --git a/common/common/src/test/java/io/helidon/common/GenericTypeUtilTest.java b/common/common/src/test/java/io/helidon/common/GenericTypeUtilTest.java index b275308e62f..90cbb5cf3de 100644 --- a/common/common/src/test/java/io/helidon/common/GenericTypeUtilTest.java +++ b/common/common/src/test/java/io/helidon/common/GenericTypeUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021 Oracle and/or its affiliates. + * Copyright (c) 2019, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ 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.hamcrest.CoreMatchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.hamcrest.MatcherAssert.assertThat; /** * Unit tests for class {@link GenericTypeUtil}. @@ -34,14 +34,14 @@ public class GenericTypeUtilTest{ public void testRawClass() { Class claszResult = GenericTypeUtil.rawClass(Object.class); - assertFalse(claszResult.isInterface()); - assertFalse(claszResult.isArray()); - assertEquals("class java.lang.Object", claszResult.toString()); - assertEquals(1, claszResult.getModifiers()); - assertFalse(claszResult.isEnum()); - assertFalse(claszResult.isSynthetic()); - assertFalse(claszResult.isAnnotation()); - assertFalse(claszResult.isPrimitive()); + assertThat(claszResult.isInterface(), is(false)); + assertThat(claszResult.isArray(), is(false)); + assertThat(claszResult.toString(), is("class java.lang.Object")); + assertThat(claszResult.getModifiers(), is(1)); + assertThat(claszResult.isEnum(), is(false)); + assertThat(claszResult.isSynthetic(), is(false)); + assertThat(claszResult.isAnnotation(), is(false)); + assertThat(claszResult.isPrimitive(), is(false)); } @Test