Ditch Google Truth from web-api 76/100876/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 28 Apr 2022 18:07:31 +0000 (20:07 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 28 Apr 2022 18:07:31 +0000 (20:07 +0200)
Use plain JUnit/Hamcrest matchers instead. Also improve a few
assertions.

Change-Id: I2539e01bd441cbd7e72a8a911de89929fc91949a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
web/api/pom.xml
web/api/src/test/java/org/opendaylight/aaa/web/tests/WebContextApiTest.java

index 3fa8a57d3bd835138a5d8ff5362221573066be25..cc5223e523a61cfbcc60a4629ae2b97d98ea7f79 100644 (file)
       <artifactId>value</artifactId>
       <classifier>annotations</classifier>
     </dependency>
-
-    <dependency>
-      <groupId>com.google.truth</groupId>
-      <artifactId>truth</artifactId>
-    </dependency>
   </dependencies>
-
 </project>
index ff6371759d72966bd7be30455b9672df9a50ec12..9e225941d873690b43be13b7b74f03671eea2d26 100644 (file)
@@ -7,10 +7,15 @@
  */
 package org.opendaylight.aaa.web.tests;
 
-import static com.google.common.truth.Truth.assertThat;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 
+import java.util.Map;
 import javax.servlet.Filter;
 import javax.servlet.Servlet;
 import javax.servlet.ServletContextListener;
@@ -30,7 +35,6 @@ import org.opendaylight.aaa.web.WebServer;
  * @author Michael Vorburger.ch
  */
 public class WebContextApiTest {
-
     @Test
     public void testEmptyBuilder() {
         final WebContextBuilder builder = WebContext.builder();
@@ -39,9 +43,8 @@ public class WebContextApiTest {
 
     @Test
     public void testMinimalBuilder() {
-        assertThat(WebContext.builder().contextPath("test").build().supportsSessions()).isTrue();
-        assertThat(WebContext.builder().contextPath("test").supportsSessions(false).build().contextPath())
-                .isEqualTo("test");
+        assertTrue(WebContext.builder().contextPath("test").build().supportsSessions());
+        assertEquals("test", WebContext.builder().contextPath("test").supportsSessions(false).build().contextPath());
     }
 
     @Test
@@ -49,11 +52,10 @@ public class WebContextApiTest {
         WebContext webContext = WebContext.builder().contextPath("test")
                 .addServlet(ServletDetails.builder().servlet(mock(Servlet.class)).addUrlPattern("test").build())
                 .build();
-        assertThat(webContext.servlets()).hasSize(1);
+        assertThat(webContext.servlets(), hasSize(1));
         ServletDetails firstServletDetail = webContext.servlets().get(0);
-        assertThat(firstServletDetail.name())
-                .startsWith("org.mockito.codegen.Servlet$MockitoMock$");
-        assertThat(firstServletDetail.initParams()).isEmpty();
+        assertThat(firstServletDetail.name(), startsWith("org.mockito.codegen.Servlet$MockitoMock$"));
+        assertEquals(Map.of(), firstServletDetail.initParams());
     }
 
     @Test
@@ -72,13 +74,13 @@ public class WebContextApiTest {
     @Test
     public void testAddListener() {
         assertThat(WebContext.builder().contextPath("test").addListener(mock(ServletContextListener.class)).build()
-                .listeners()).isNotEmpty();
+                .listeners(), hasSize(1));
     }
 
     @Test
     public void testContextParam() {
-        assertThat(WebContext.builder().contextPath("test").putContextParam("key", "value").build().contextParams())
-                .containsExactly("key", "value").inOrder();
+        assertEquals(Map.of("key", "value"),
+            WebContext.builder().contextPath("test").putContextParam("key", "value").build().contextParams());
     }
 
     @Test