Skip to content

Instantly share code, notes, and snippets.

@sfpprxy
Created March 20, 2016 16:46
Show Gist options
  • Save sfpprxy/e3f61b01ef4447fd5c70 to your computer and use it in GitHub Desktop.
Save sfpprxy/e3f61b01ef4447fd5c70 to your computer and use it in GitHub Desktop.
package eventmanage;
import java.util.Date;
/**
* This class is used to test Operations methods
*
* @author Joe Cui
* @version 1.0
*/
public class EventOperationsMain {
public static void main(String[] args) {
// Print start-of-testing timestamp
System.out.println("\n*** Begin testing on " + new Date());
// Create new concrete class implementing EventList interface for testing
// populate it with at least 10 event objects...
EventSchedule es = new EventSchedule();
// Test implemented EventList methods add(), remove() and get()
System.out.println("\n** Begin testing event list methods");
// testing goes here...
System.out.println("\nTesting add()...");
System.out.println("\nDemonstrating wrong inputting condition while adding...");
boolean result1 = es.add("name", "layout", "id", EventHelper.createDate("30/04/2016"), 11);
System.out.println("Inputting wrong hall number(11): " + result1);
boolean result2 = es.add("name", "layout", "id", EventHelper.createDate("01/01/2015"), 9);
System.out.println("Inputting wrong date(01/01/2015): " + result2);
// normal condition: add 10 events
System.out.println("\nAdding 10 acceptable events using loop...");
for (int i = 0; i < 10; i++) {
es.add("name" + String.valueOf(i),
"layout" + String.valueOf(i),
EventHelper.generateEventId(),
EventHelper.createDate("30/04/2016"),
5);
}
System.out.println("Current list:\n" + es);
System.out.println("\nTesting get() and remove()...");
String fId = es.eventList.get(0).getId();
System.out.println("\nGetting the first one by its id: " + fId);
System.out.println(es.get(fId));
System.out.println("Removing the first one by its id: " + fId);
es.remove(fId);
System.out.println("Current list:\n" + es);
System.out.println("\n** Finish testing event list methods");
// Test implemented EventList method sort()
System.out.println("\n** Begin testing sort method");
// testing goes here...
System.out.println("Sorting by id...");
es.sort();
System.out.println("Current list:\n" + es);
System.out.println("\n*** Finish testing sort method");
System.out.println("\n*** Finish testing on " + new Date());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment