package DataStructures; import Exceptions.ElementNotFoundException; import Exceptions.EmptyCollectionException; import Exceptions.InvalidArgumentException; import org.junit.Test; import static org.junit.Assert.*; /** * * @author ITSC 2214 Q * @version 1.0 */ public

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

package DataStructures;

import Exceptions.ElementNotFoundException;
import Exceptions.EmptyCollectionException;
import Exceptions.InvalidArgumentException;
import org.junit.Test;
import static org.junit.Assert.*;

/**
*
* @author ITSC 2214 Q
* @version 1.0
*/
public class CircularDoublyLinkedListTest {

public CircularDoublyLinkedListTest() {
}

/**
* Test of first method, of class CircularDoublyLinkedList.
*/
@Test(expected=EmptyCollectionException.class)
public void testFirst1() throws Exception {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();
circle.first();
}

/**
* Test of first method, of class CircularDoublyLinkedList.
*/
@Test
public void testFirst2() throws Exception {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();
circle.addFirst(10);
assertEquals(circle.first().intValue(), 10);
}

/**
* Test of current method, of class CircularDoublyLinkedList.
*/
@Test
public void testCurrent() {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();
assertNull(circle.current());

circle.addFirst(10);
assertEquals(circle.current().intValue(), 10);
}

/**
* Test of last method, of class CircularDoublyLinkedList.
*/
@Test(expected=EmptyCollectionException.class)
public void testLast() throws Exception {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();
circle.addLast(10);
assertEquals(circle.last().intValue(), 10);
circle.removeLast();
circle.last();
}

/**
* Test of next method, of class CircularDoublyLinkedList.
*/
@Test
public void testNext() {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();
circle.next();

circle.addFirst(10);
circle.addLast(17);
circle.next();
assertEquals(circle.current().intValue(), 17);
assertEquals(circle.size(), 2);
try{
assertEquals(circle.getNode(1).getElement().intValue(), 10);
}
catch (Exception ex){
fail("testNext");
}
}

/**
* Test of isEmpty method, of class CircularDoublyLinkedList.
*/
@Test
public void testIsEmpty() {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();
assertTrue(circle.isEmpty());
circle.addFirst(10);
assertFalse(circle.isEmpty());
}

/**
* Test of printList method, of class CircularDoublyLinkedList.
*/
@Test
public void testPrintList() {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();
circle.printList();
circle.addFirst(10);
circle.printList();
}

/**
* TODO Test of addLast method, of class CircularDoublyLinkedList.
*/
@Test
public void testAddLast() {


}

/**
* Test of addFirst method, of class CircularDoublyLinkedList.
*/
@Test
public void testAddFirst() {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();

circle.addFirst(10);
assertEquals(circle.size(), 1);
assertEquals(circle.current().intValue(), 10);

circle.addFirst(17);
assertEquals(circle.size(), 2);
try {
assertEquals(circle.getNode(0).getElement().intValue(), 17);
assertEquals(circle.getNode(1).getElement().intValue(), 10);
}
catch (Exception ex){
ex.printStackTrace();
}
}

/**
* Test of addAfter method, of class CircularDoublyLinkedList.
*/
@Test
public void testAddAfter() throws Exception {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();

circle.addFirst(10);
circle.addAfter(10, 17);
assertEquals(circle.size(), 2);
try {
assertEquals(circle.getNode(0).getElement().intValue(), 10);
assertEquals(circle.getNode(1).getElement().intValue(), 17);
}
catch (Exception ex){
ex.printStackTrace();
}
}

/**
* Test of remove method, of class CircularDoublyLinkedList.
*/
@Test(expected=EmptyCollectionException.class)
public void testRemove1() throws Exception {
//TODO complete the Unit testing
//of the EmptyCollectionException in Remove() method


}

/**
* Test of remove method, of class CircularDoublyLinkedList.
*/
@Test(expected=ElementNotFoundException.class)
public void testRemove2() throws Exception {
//TODO complete the Unit testing
//of the ElementNotFoundException in Remove() method


}

/**
* Test of remove method, of class CircularDoublyLinkedList.
*/
@Test
public void testRemove3() throws Exception {
//TODO complete the Unit testing of
//logic correctness of the remove() method

 


}

/**
* Test of removeFirst method, of class CircularDoublyLinkedList.
*/
@Test(expected=EmptyCollectionException.class)
public void testRemoveFirst1() throws Exception {
CircularDoublyLinkedList<Integer> circle = new CircularDoublyLinkedList<Integer>();
circle.removeFirst();

Step 3: Open CircularDoublyLinkedListTest.java in the test package and complete Unit
testing methods of CircularDoublyLinkedList.java
• Complete the Unit testing of the AddLast() method:
public void testAddlast)
Test the addLast method of class CircularDoublyLinkedList.
• Complete the Unit testing of the remove() method and handle exceptions individually:
• Test the case of EmptyCollectionException
@Test(expected-EmptyCollectionException.class)
public void testRemove10 throws Exception{
o Test the case of ElementNotFoundException
@Testlexpected-ElementNotFoundException.class)
public void testRemove20 throws Exception {
• Test the logic correctness of the remove() method:
@Test
public void testRemove30 throws Exception {
Transcribed Image Text:Step 3: Open CircularDoublyLinkedListTest.java in the test package and complete Unit testing methods of CircularDoublyLinkedList.java • Complete the Unit testing of the AddLast() method: public void testAddlast) Test the addLast method of class CircularDoublyLinkedList. • Complete the Unit testing of the remove() method and handle exceptions individually: • Test the case of EmptyCollectionException @Test(expected-EmptyCollectionException.class) public void testRemove10 throws Exception{ o Test the case of ElementNotFoundException @Testlexpected-ElementNotFoundException.class) public void testRemove20 throws Exception { • Test the logic correctness of the remove() method: @Test public void testRemove30 throws Exception {
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Exception Handling Keywords
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education