Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are just two variations- the first (no-arg) method will return a Student object with all basic data fields filled in. It will also populate enrollment profile information for the current term (based on a simple current date calculation). The second method, taking term code as an argument builds a similar Student object, but it uses the supplied term code for any term-specific data like enrollment profile.

The builder methods will randomly generate values for the student name, mit id, pidm, kerb name, etc, so that each student object returned by the builder methods will be different.

So a unit test needing Student objects for test data now only needs to do this for each student object:

Code Block
CoreDataFactory builder = new CoreDataFactory();
Student student = builder.buildStudent();

and no longer needs to do this:

Code Block
        PersonName personName = new PersonName("David", "Lee", "Roth");
        String kerbName = nameGenerator.getName()"dlr";
        String emailAddress = kerbName + "@mit.edu";
        
        Random random = new Random();
        int pidm = 12212871;  // should be int between 100,000 and 199,999
        int mitId = 90002312; // should be int between 900,000,000 and 990,000,000
        
        Student student = new Student(String.valueOf(pidm), String.valueOf(mitId), kerbName, personName, emailAddress);
        Calendar now = Calendar.getInstance();
        
        student.setCitizenship(new Citizenship("US", "United States"));
        student.setEthnicity(new StudentEthnicity());
        Calendar birthDate = Calendar.getInstance();
        birthDate.set(Calendar.YEAR, birthDate.get(Calendar.YEAR) - 20);   // Born 20 years ago
        student.setBirthDate(birthDate.getTime());
        student.setDeceased(false);
        student.setGender(Gender.FEMALE);
        student.setStudentHolds(new ArrayList<StudentHold>());
        student.setVersion(1l);
        student.setCreateBy("testuser");
        student.setCreateDate(now.getTime());
        student.setModifyBy("testuser2");
        student.setModifyDate(now.getTime());

        // Enrollment profile:
        
        Set enrollProfiles = new HashSet();
        

// ... more code that builds enrollment profile objects...

        student.setStudentEnrollProfiles(enrollProfiles);