How to write JUnit test code in Java for the function of checking whether a given String is eligible for Palindrome or not?

This is the JUnit 5 solution to cover all kinds of inputs provided to check whether a given String is eligible for a palindrome or not. This Unit test executes tests for the ‘RdInput’ function available in the class ‘EligiblePalindromeJ8’.

package pack1;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class JUnitTestEligiblePalindromeJ8 {

	PalindromEligibility_Using_CoreLogic PEUCL;
	PalindromEligibility_Using_Hashmap PEUCHM;
	PalindromEligibility_Using_StringBuffer PEUCSB;

	@BeforeEach
	void setUp() throws Exception {

		PEUCL = new PalindromEligibility_Using_CoreLogic();
		PEUCHM = new PalindromEligibility_Using_Hashmap();
		PEUCSB = new PalindromEligibility_Using_StringBuffer();
	}

	@Test
	@DisplayName("Positive inputs - Exp value and Actual matches")
	void test1() {

		Assertions.assertTrue(PEUCL.RdInput("aaaa"));
		Assertions.assertTrue(PEUCHM.RdInput("aaaabbc"));
		Assertions.assertTrue(PEUCSB.RdInput("aaabbbb"));
	}

	@Test
	@DisplayName("Negative inputs - Exp value and Actual not matches")
	void test2() {

		Assertions.assertFalse(PEUCL.RdInput("aaabbb"));
		Assertions.assertFalse(PEUCHM.RdInput("aaaaabbccc"));
		Assertions.assertFalse(PEUCSB.RdInput("aaabbb"));
	}

	@Test
	@DisplayName("Null inputs")
	void test3() {

		Assertions.assertFalse(PEUCL.RdInput(null));
		Assertions.assertFalse(PEUCHM.RdInput(null));
		Assertions.assertFalse(PEUCSB.RdInput(null));
	}
}
Output:
Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_CoreLogic RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_CoreLogic'
The given input String is aaaa
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: The provided Input validated Successfully
The Hashmap of each character occurences are: {a=4}
The respective Character key=a and number of occurances is=4
The Even count of Character keys are=1
The Odd count of Character keys are=0
The String aaaa can become a Palindrome

Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_Hashmap RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_Hashmap'
The given input String is aaaabbc
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: The provided Input validated Successfully
The String aaaabbc can become a Palindrome

Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_StringBuffer RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_StringBuffer'
The given input String is aaabbbb
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: The provided Input validated Successfully
The String aaabbbb can become a Palindrome

Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_CoreLogic RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_CoreLogic'
The given input String is aaabbb
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: The provided Input validated Successfully
The Hashmap of each character occurences are: {a=3, b=3}
The respective Character key=a and number of occurances is=3
The respective Character key=b and number of occurances is=3
The Even count of Character keys are=0
The Odd count of Character keys are=2
The String aaabbb can Not become a Palindrome

Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_Hashmap RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_Hashmap'
The given input String is aaaaabbccc
The String aaaaabbccc can Not become a Palindrome

Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: The provided Input validated Successfully
Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_StringBuffer RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_StringBuffer'
The given input String is aaabbb
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: The provided Input validated Successfully
The String aaabbb can Not become a Palindrome

Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_CoreLogic RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_CoreLogic'
Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_CoreLogic RdInput
INFO: The given Input number is null
The String null can Not become a Palindrome

Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_Hashmap RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_Hashmap'
Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_Hashmap RdInput
INFO: The given Input number is null
The String null can Not become a Palindrome

Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_StringBuffer RdInput
INFO: This method 'RdInput' called from the Class 'pack1.JUnitTestEligiblePalindromeJ8'
Apr 09, 2023 3:35:56 PM pack1.InputTheString validateInputs
INFO: This method 'validateInputs()' called from the Class 'pack1.PalindromEligibility_Using_StringBuffer'
Apr 09, 2023 3:35:56 PM pack1.PalindromEligibility_Using_StringBuffer RdInput
INFO: The given Input number is null
The String null can Not become a Palindrome