Calender test file
unknown
java
3 years ago
5.2 kB
12
Indexable
package edu.sc.cse4495.MeetingPlanner;
import static org.junit.Assert.*;
import static org.junit.Assert.fail;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
public class CalendarTest {
Calendar calendarUnderTest = new Calendar();
// Add test methods here.
// You are not required to write tests for all classes.
@Test
public void testAddMeeting_ThrowsTimeConflictException() throws Exception {
final Meeting toAdd = new Meeting(1, 1, 0, 0, new ArrayList<>(List.of(new Person("name"))), new Room("ID"),
"description");
assertThrows(TimeConflictException.class, () -> calendarUnderTest.addMeeting(toAdd));
}
@Test
public void testCheckTimes_ThrowsTimeConflictException() throws Exception {
assertThrows(TimeConflictException.class, () -> Calendar.checkTimes(1, 1, 0, 0));
}
@Test
public void testClearSchedule() throws Exception {
calendarUnderTest.clearSchedule(1, 1);
}
@Test
public void testIsBusy_ThrowsTimeConflictException() throws Exception {
// Setup
// Run the test
assertThrows(TimeConflictException.class, () -> calendarUnderTest.isBusy(1, 1, 0, 0));
}
@Test
public void testAddMeeting_holiday() {
// Create Midsommar holiday
Meeting christmas = new Meeting(6, 26, "Midsommar");
Calendar calendar = new Calendar();
// Add to calendar object.
try {
calendar.addMeeting(christmas);
// Verify that it was added.
Boolean added = calendar.isBusy(6, 26, 0, 23);
assertTrue("Midsommar should be marked as busy on the calendar",added);
} catch(TimeConflictException e) {
fail("Should not throw exception: " + e.getMessage());
}
}
@Test
public void testGetMeeting() {
Meeting christmas = new Meeting(6, 26, "Midsommar");
Calendar calendar = new Calendar();
// Add to calendar object.
try {
calendar.addMeeting(christmas);
// Verify that it was added.
Boolean added = calendar.isBusy(6, 26, 0, 23);
assertTrue("Midsommar should be marked as busy on the calendar",added);
} catch(TimeConflictException e) {
fail("Should not throw exception: " + e.getMessage());
}
}
@Test
public void isBusy(){
try {
boolean expectedValue=false;
int month=0;
int day=0;
int start=0;
int end=0;
Calendar calendar =new Calendar();
boolean actualValue=calendar.isBusy( month ,day ,start ,end);
System.out.println("Expected Value="+ expectedValue +" . Actual Value="+actualValue);
assertEquals(expectedValue, actualValue);
} catch (Exception exception) {
exception.printStackTrace();
assertFalse(false);
}
}
@Test
public void checkTimes(){
try {
int mMonth=0;
int mDay=0;
int mStart=0;
int mEnd=0;
Calendar.checkTimes( mMonth ,mDay ,mStart ,mEnd);
assertTrue(true);
} catch (Exception exception) {
exception.printStackTrace();
assertFalse(false);
}
}
@Test
public void addMeeting(){
try {
Meeting toAdd = null;
Calendar calendar =new Calendar();
calendar.addMeeting( toAdd);
assertTrue(true);
} catch (Exception exception) {
exception.printStackTrace();
assertFalse(false);
}
}
@Test
public void clearSchedule(){
try {
int month=0;
int day=0;
Calendar calendar =new Calendar();
calendar.clearSchedule( month ,day);
assertTrue(true);
} catch (Exception exception) {
exception.printStackTrace();
assertFalse(false);
}
}
@Test
public void printAgenda6(){
try {
String expectedValue="";
int month=0;
Calendar calendar =new Calendar();
String actualValue=calendar.printAgenda( month);
System.out.println("Expected Value="+ expectedValue +" . Actual Value="+actualValue);
assertEquals(expectedValue, actualValue);
} catch (Exception exception) {
exception.printStackTrace();
assertFalse(false);
}
}
@Test
public void printAgenda(){
try {
String expectedValue="";
int month=0;
int day=0;
Calendar calendar =new Calendar();
String actualValue=calendar.printAgenda( month ,day);
System.out.println("Expected Value="+ expectedValue +" . Actual Value="+actualValue);
assertEquals(expectedValue, actualValue);
} catch (Exception exception) {
exception.printStackTrace();
assertFalse(false);
}
}
@Test
public void getMeeting(){
try {
Meeting expectedValue = null;
int month=0;
int day=0;
int index=0;
Calendar calendar =new Calendar();
Meeting actualValue=calendar.getMeeting( month ,day ,index);
System.out.println("Expected Value="+ expectedValue +" . Actual Value="+actualValue);
assertEquals(expectedValue, actualValue);
} catch (Exception exception) {
exception.printStackTrace();
assertFalse(false);
}
}
@Test
public void removeMeeting(){
try {
int month=0;
int day=0;
int index=0;
Calendar calendar =new Calendar();
calendar.removeMeeting( month ,day ,index);
assertTrue(true);
} catch (Exception exception) {
exception.printStackTrace();
assertFalse(false);
}
}
}
Editor is loading...