From 3928c386259c2df4d0837838c87b57974051ff44 Mon Sep 17 00:00:00 2001 From: Taher Ghaleb Date: Thu, 24 Aug 2023 03:52:31 -0400 Subject: [PATCH] [WICKET-7069] Refactor `assertTrue(equals())` using `assertEquals` (#601) * Refactor assertTrue(equals()) using assertEquals * Refactor throws Exception using assertThrows * Revert "Refactor throws Exception using assertThrows" This reverts commit d667bafbb8081b87fc6dc764f7fc895b066b96d7. * Fix assertEquals parameters as (expected, actual) * Fix test case failures by converting tokens into strings --- .../apache/wicket/markup/MarkupParserTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/MarkupParserTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/MarkupParserTest.java index 1cd4514b640..7019184d064 100644 --- a/wicket-core/src/test/java/org/apache/wicket/markup/MarkupParserTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/markup/MarkupParserTest.java @@ -67,7 +67,7 @@ void tagParsing() throws Exception final ComponentTag aOpen = (ComponentTag)markupStream.next(); log.info("", aOpen); - assertTrue(aOpen.getName().equals("a")); + assertEquals("a", aOpen.getName()); assertEquals("foo.html", aOpen.getAttributes().getString("href")); markupStream.next(); @@ -75,7 +75,7 @@ void tagParsing() throws Exception final ComponentTag boldOpen = (ComponentTag)markupStream.next(); log.info("", boldOpen); - assertTrue(boldOpen.getName().equals("b")); + assertEquals("b", boldOpen.getName()); assertEquals(TagType.OPEN, boldOpen.getType()); markupStream.next(); @@ -83,7 +83,7 @@ void tagParsing() throws Exception final ComponentTag boldClose = (ComponentTag)markupStream.next(); log.info("", boldClose); - assertTrue(boldClose.getName().equals("b")); + assertEquals("b", boldClose.getName()); assertEquals(TagType.CLOSE, boldClose.getType()); markupStream.next(); @@ -91,7 +91,7 @@ void tagParsing() throws Exception final ComponentTag img = (ComponentTag)markupStream.next(); log.info("", img); - assertTrue(img.getName().equals("img")); + assertEquals("img", img.getName()); assertEquals(9, img.getAttributes().getInt("width")); assertEquals(10, img.getAttributes().getInt("height")); assertEquals(TagType.OPEN, img.getType()); @@ -101,7 +101,7 @@ void tagParsing() throws Exception final ComponentTag marker = (ComponentTag)markupStream.next(); log.info("", marker); - assertTrue(marker.getName().equals("marker")); + assertEquals("marker", marker.getName()); assertEquals(TagType.OPEN_CLOSE, marker.getType()); markupStream.next(); @@ -109,7 +109,7 @@ void tagParsing() throws Exception final ComponentTag aClose = (ComponentTag)markupStream.next(); log.info("", aClose); - assertTrue(aClose.getName().equals("a")); + assertEquals("a", aClose.getName()); assertNull(markupStream.next()); } @@ -133,12 +133,12 @@ final void test1() throws Exception log.info("tok(4)=" + tokens.get(4)); log.info("tok(5)=" + tokens.get(5)); - assertTrue(tokens.get(0).equals("This is a test ")); + assertEquals("This is a test ", tokens.get(0).toString()); final ComponentTag a = (ComponentTag)tokens.get(1); assertEquals(9, a.getAttributes().getInt("componentName:id")); - assertTrue(tokens.get(2).equals(" bold ")); + assertEquals(" bold ", tokens.get(2).toString()); final ComponentTag b = (ComponentTag)tokens.get(3); @@ -147,7 +147,7 @@ final void test1() throws Exception final ComponentTag closeA = (ComponentTag)tokens.get(5); assertEquals("a", closeA.getName()); - assertTrue(tokens.get(6).equals(" of the emergency broadcasting system")); + assertEquals(" of the emergency broadcasting system", tokens.get(6).toString()); } /**