Using Java Given Code Interface Custom Arraylist Write Junit Test Cases Testing Functional Q43901903
Using JAVA: Given the Code for the Interface & the CustomArrayList; write junit test cases for testing all thefunctionality.
——-
Interface code:
public interface Interface { boolean add (T item); boolean add (int index, T item) throws IndexOutOfBoundsException; int getSize(); T get(int index) throws IndexOutOfBoundsException; T remove(int index) throws IndexOutOfBoundsException;}
—————————————————————————————————————————————————————————————
Custom ArrayList
import java.util.*;public class CustomArrayList implements Interface{ ArrayList arrayList = new ArrayList(); public boolean add(String item) { arrayList.add(item); return true; } public boolean add(int index, String item) { arrayList.add(index, item); return true; } public int getSize() { int size = arrayList.size(); return size; } public String get(int index) { String value = (arrayList.get(index)).toString(); return value; } public String remove(int index) { String removeitem = (arrayList.remove(index)).toString(); return removeitem; } public void printArray() { for (String element: arrayList) { System.out.println(element); } } public static void main(String args[]) { CustomArrayList object = new CustomArrayList(); System.out.println(“the value added : ” + object.add(“a”)); System.out.println(“the value added : ” + object.add(“b”)); System.out.println(“the value added : ” + object.add(“c”)); System.out.println(“the value added : ” + object.add(2, “d”)); System.out.println(“n——–Printing the Array——–“); object.printArray(); System.out.println(“nArray Size: ” + object.getSize()); System.out.println(“Getting the Value at Index1 : ” + object.get(1)); System.out.println(“Removing the Value at Index1: ” + object.remove(1)); System.out.println(“n——–Printing the Array——–“); object.printArray(); System.out.println(“nArray Size: ” + object.getSize());
Expert Answer
Answer to Using JAVA: Given the Code for the Interface & the Custom ArrayList; write junit test cases for testing all the function…
OR