예제 #1
0
  public void testGetCourse() throws Exception {

    ______TS("failure: course doesn't exist");

    assertNull(coursesLogic.getCourse("nonexistant-course"));

    ______TS("success: typical case");

    CourseAttributes c = new CourseAttributes();
    c.id = "Computing101-getthis";
    c.name = "Basic Computing Getting";
    coursesDb.createEntity(c);

    assertEquals(c.id, coursesLogic.getCourse(c.id).id);
    assertEquals(c.name, coursesLogic.getCourse(c.id).name);

    coursesDb.deleteEntity(c);
    ______TS("Null parameter");

    try {
      coursesLogic.getCourse(null);
      signalFailureToDetectException();
    } catch (AssertionError e) {
      assertEquals("Supplied parameter was null\n", e.getMessage());
    }
  }
예제 #2
0
  public void testSetArchiveStatusOfCourse() throws Exception {

    CourseAttributes course = new CourseAttributes("CLogicT.new-course", "New course");
    coursesDb.createEntity(course);

    ______TS("success: archive a course");

    coursesLogic.setArchiveStatusOfCourse(course.id, true);

    CourseAttributes courseRetrieved = coursesLogic.getCourse(course.id);
    assertEquals(true, courseRetrieved.isArchived);

    ______TS("success: unarchive a course");

    coursesLogic.setArchiveStatusOfCourse(course.id, false);

    courseRetrieved = coursesLogic.getCourse(course.id);
    assertEquals(false, courseRetrieved.isArchived);

    ______TS("fail: course doesn't exist");

    coursesDb.deleteCourse(course.id);

    try {
      coursesLogic.setArchiveStatusOfCourse(course.id, true);
      signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
      AssertHelper.assertContains("Course does not exist: CLogicT.new-course", e.getMessage());
    }

    ______TS("Null parameter");

    try {
      coursesLogic.setArchiveStatusOfCourse(null, true);
      signalFailureToDetectException();
    } catch (AssertionError e) {
      assertEquals("Supplied parameter was null\n", e.getMessage());
    }
  }