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

    ______TS("typical case");

    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    CourseSummaryBundle courseSummary = coursesLogic.getCourseSummaryWithoutStats(course.id);
    assertEquals(course.id, courseSummary.course.id);
    assertEquals(course.name, courseSummary.course.name);
    assertEquals(false, courseSummary.course.isArchived);

    assertEquals(0, courseSummary.evaluations.size());
    assertEquals(0, courseSummary.sections.size());

    ______TS("course without students");

    StudentProfileAttributes spa = new StudentProfileAttributes();
    spa.googleId = "instructor1";

    AccountsLogic.inst()
        .createAccount(
            new AccountAttributes(
                "instructor1",
                "Instructor 1",
                true,
                "*****@*****.**",
                "TEAMMATES Test Institute 1",
                spa));
    coursesLogic.createCourseAndInstructor("instructor1", "course1", "course 1");
    courseSummary = coursesLogic.getCourseSummaryWithoutStats("course1");
    assertEquals("course1", courseSummary.course.id);
    assertEquals("course 1", courseSummary.course.name);

    assertEquals(0, courseSummary.evaluations.size());
    assertEquals(0, courseSummary.sections.size());

    coursesLogic.deleteCourseCascade("course1");
    accountsDb.deleteAccount("instructor1");

    ______TS("non-existent");

    try {
      coursesLogic.getCourseSummaryWithoutStats("non-existent-course");
      signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
      AssertHelper.assertContains("The course does not exist:", e.getMessage());
    }

    ______TS("null parameter");

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

    ______TS("typical case");

    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    List<TeamDetailsBundle> teams = coursesLogic.getTeamsForCourse(course.id);

    assertEquals(2, teams.size());
    assertEquals("Team 1.1", teams.get(0).name);
    assertEquals("Team 1.2", teams.get(1).name);

    ______TS("course without students");

    StudentProfileAttributes spa = new StudentProfileAttributes();
    spa.googleId = "instructor1";

    AccountsLogic.inst()
        .createAccount(
            new AccountAttributes(
                "instructor1",
                "Instructor 1",
                true,
                "*****@*****.**",
                "TEAMMATES Test Institute 1",
                spa));
    coursesLogic.createCourseAndInstructor("instructor1", "course1", "course 1");
    teams = coursesLogic.getTeamsForCourse("course1");

    assertEquals(0, teams.size());

    coursesLogic.deleteCourseCascade("course1");
    accountsDb.deleteAccount("instructor1");

    ______TS("non-existent");

    try {
      coursesLogic.getTeamsForCourse("non-existent-course");
      signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
      AssertHelper.assertContains("does not exist", e.getMessage());
    }

    ______TS("null parameter");

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