Skip to content
Snippets Groups Projects
Commit b2a57cf8 authored by Rafi's avatar Rafi
Browse files

Added test code for creating schedules (adding shifts). Also added sleep...

Added test code for creating schedules (adding shifts). Also added sleep statements for the client to receive the server responses. Changed getting the number of employees to the new employeeSize method in the model (should use the correct size now).
parent aeec1305
No related branches found
No related tags found
No related merge requests found
package com.example.schedulerapp;
import java.util.concurrent.TimeUnit;
public class TestModel {
//needs a fresh or empty database to run tests
public static void main(String[] args) {
Model testModel = new Model("localhost", 8989);
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException exception) {
System.out.println("Sleep");
}
//test underlying database methods
//add first employee
System.out.println("New Model\nemployees size: " + testModel.employees.size());
System.out.println("New Model\nemployees size: " + testModel.employeeSize());
testModel.printAllEmployees();
testModel.addEmployee("Alex", "Abend");
System.out.println("Employee Alex Abend added.\nPrinting all employees:");
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException exception) {
System.out.println("Sleep");
}
testModel.printAllEmployees();
System.out.println("Removing Alex");
testModel.removeEmployee("18");
testModel.removeEmployee("1");
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException exception) {
System.out.println("Sleep");
}
testModel.printAllEmployees();
System.out.println("employees size: " + testModel.employees.size());
System.out.println("employees size: " + testModel.employeeSize());
// Make the schedule (Add shifts)
System.out.println();
System.out.println("Making the schedule (Add shifts) Test Suite:\nAdding Freya and Mike as employees.");
testModel.addEmployee("Freya", "Fulltime");
testModel.addEmployee("Mike", "Parttime");
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException exception) {
System.out.println("Sleep");
}
System.out.println();
System.out.println("Adding a shift for Freya from 9-5 on March-03-2022.");
testModel.addShift(2, "2022-03-13", 900, 1700);
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException exception) {
System.out.println("Sleep");
}
System.out.println("Expected output: [allShifts, 2.2022-03-13.900.1700.1] ");
System.out.println("Actual output: ...");
testModel.printAllShifts();
System.out.println();
System.out.println("Adding a shift for Mike from 5-9 on March-03-2022.");
testModel.addShift(3, "2022-03-13", 1700, 2100);
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException exception) {
System.out.println("Sleep");
}
System.out.println("Expected output: [allShifts, 2.2022-03-13.900.1700.1, 3.2022-03-13.1700.2100.2] ");
System.out.println("Actual output: ...");
testModel.printAllShifts();
testModel.removeEmployee("2");
testModel.removeEmployee("3");
// End the program
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException exception) {
System.out.println("Sleep");
}
testModel.logOut();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment