Skip to content
Snippets Groups Projects
TestModel.java 3.53 KiB
Newer Older
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.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("1");
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException exception) {
            System.out.println("Sleep");
        }
        testModel.printAllEmployees();
        System.out.println("employees size: " + testModel.employeeSize());

        // Make the schedule (Add shifts) Rafi's Test Suite

        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();

        System.out.println();
        System.out.println("Adding the same 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");
        }