Exemplo n.º 1
0
  @Test
  public void canSetUsername() {

    student.setUsername(USERNAME);

    assertEquals(USERNAME, student.getUsername());
  }
Exemplo n.º 2
0
 @Test
 public void testGetOrderedPreferences() throws Exception {
   for (Project str : testProject_rest) {
     s.addProject(str);
   }
   assertEquals("expect equal", testProject_rest, s.getOrderedPreferences());
 }
Exemplo n.º 3
0
 @Test
 public void testPreassignProject() throws Exception {
   s.preassignProject(testProject_1);
   s.preassignProject(s.getRandomPreference());
   assertEquals("there shouldn't be 2 preassigned project", 1, s.getOrderedPreferences().size());
   assertEquals("expect true", true, s.hasPreassignedProject());
 }
Exemplo n.º 4
0
  @Test
  public void getNameReturnsFullNameIfItIsSet() {

    student.setFullName(FULLNAME);

    assertEquals(FULLNAME, student.getName());
  }
Exemplo n.º 5
0
  @Test
  public void setLoginSetsUsername() {

    student.setLogin(USERNAME);

    assertEquals(USERNAME, student.getUsername());
  }
Exemplo n.º 6
0
  @Test
  public void canSetPlainId() {

    student.setPlainId(PLAIN_ID);

    assertEquals(PLAIN_ID, student.getPlainId());
  }
Exemplo n.º 7
0
 @Test
 public void gradeTest() {
   System.out.println("StudentTest");
   Student instance = new Student();
   double expResult = 0.0;
   double result = instance.getGrade();
   assertEquals(expResult, result, 0.0);
 }
Exemplo n.º 8
0
  @Test
  public void studentWithNullUsernameIsNotEqualToStudentWithNonNullUsername() {

    final Student other = new Student();
    other.setUsername(USERNAME);

    assertFalse(student.equals(other));
  }
Exemplo n.º 9
0
  @Test
  public void getNameReturnsConcatenatedFirstAndLastNameIfNoFullNameSet() {

    student.setFirstName(FIRSTNAME);
    student.setLastName(LASTNAME);

    assertEquals(FIRSTNAME + " " + LASTNAME, student.getName());
  }
Exemplo n.º 10
0
  @Test
  public void idIsSetBasedOnUsername() {

    final String expectedId = Base64.encodeBase64URLSafeString(USERNAME.getBytes());
    student.setUsername(USERNAME);

    assertEquals(expectedId, student.getId());
  }
Exemplo n.º 11
0
 @Test
 public void namevalueTest() {
   System.out.println("StudentTest");
   Student instance = new Student();
   String expResult = "Bill Smith";
   instance.setName(expResult);
   String result = instance.getName();
   assertEquals(expResult, result);
 }
Exemplo n.º 12
0
 @Test
 public void nameStudentTest() {
   System.out.println("StudentTest");
   Student instance = new Student("Bill Smith", "c0123456", "male", 89.3);
   assertEquals("Bill Smith", instance.getName());
   assertEquals("c0123456", instance.getId());
   assertEquals("male", instance.getGender());
   assertEquals(89.3, instance.getGrade(), 0.0);
 }
Exemplo n.º 13
0
 @Test
 public void gendervalueTest() {
   System.out.println("StudentTest");
   Student instance = new Student();
   String expResult = "male";
   instance.setGender(expResult);
   String result = instance.getGender();
   assertEquals(expResult, result);
 }
Exemplo n.º 14
0
 @Test
 public void idvalueTest() {
   System.out.println("StudentTest");
   Student instance = new Student();
   String expResult = "c0123456";
   instance.setId(expResult);
   String result = instance.getId();
   assertEquals(expResult, result);
 }
Exemplo n.º 15
0
  @Test
  public void test() {
    // fail("Not yet implemented");

    Student student1 = new Student("Jon");
    assertEquals("Jon", student1.getName());

    Student student2 = new Student("Joy");
    assertEquals("Joy", student2.getName());
  }
Exemplo n.º 16
0
 /** Test of getLoanDuration method, of class Student. */
 @Test
 public void testGetLoanDuration() {
   System.out.println("getLoanDuration");
   Student instance = new Student();
   int expResult = 0;
   int result = instance.getLoanDuration();
   assertEquals(expResult, result);
   // TODO review the generated test code and remove the default call to fail.
   fail("The test case is a prototype.");
 }
Exemplo n.º 17
0
  @Test
  public void studentIsEqualToStudentWithSameUsername() {

    student.setUsername(USERNAME);

    final Student other = new Student();
    other.setUsername(USERNAME);

    assertTrue(student.equals(other));
  }
Exemplo n.º 18
0
 @Test
 public void testAddMajor() {
   assertTrue(controller.addStudent("testAddMajor"));
   Iterator i = controller.getStudents().iterator();
   Student s = null;
   while (i.hasNext()) s = (Student) i.next();
   assertNotNull(s);
   assertTrue(controller.setMajor(s, new Major()));
   assertTrue(s.getMajor().getId() == 0);
 }
Exemplo n.º 19
0
  @Test
  public void studentIsNotEqualToStudentWithOtherUsername() {

    student.setUsername(USERNAME);

    final Student other = new Student();
    other.setUsername("NotSame");

    assertFalse(student.equals(other));
  }
  /** Test of findStudents method, of class SimpleStudentRepository. */
  @Test
  public void testFindStudents() {
    System.out.println("findStudents");
    Student getS = instance.find(3);
    try {
      System.out.println(getS.getFirstName());

    } catch (NullPointerException e) {
      Assert.fail("Wrong execute");
    }
  }
Exemplo n.º 21
0
  @Test
  public void testStudentPruefungsleistung() {

    Student student = new Student("Justus", "Jonas", 11111111);
    Pruefungsleistung pruefungsleistung = new Pruefungsleistung(10, "Mathe");
    Pruefungsleistung pruefungsleistung2 = new Pruefungsleistung(9, "Mathe");
    student.addPruefungsleistung(pruefungsleistung);
    student.addPruefungsleistung(pruefungsleistung2);
    String result = "Mathe, 10";
    String result2 = "Mathe, 9";
    assertEquals(student.getPruefungsleistung()[0].toString(), result);
    assertEquals(student.getPruefungsleistung()[1].toString(), result2);
  }
Exemplo n.º 22
0
 @Test
 public void testdifferentiddifferentnameEquals() {
   System.out.println("equals");
   Student instance1 = new Student();
   instance1.setName("Ranjith");
   instance1.setId("c0663421");
   Student instance2 = new Student();
   instance2.setName("surya");
   instance2.setId("c0664573");
   assertFalse(
       instance1.getName().equals(instance2.getName())
           && instance1.getId().equals(instance2.getId()));
 }
Exemplo n.º 23
0
 @Test
 public void testAddProject() {
   int lastIndex = s.getNumberOfPreferences() - 1;
   s.addProject(testProject_1);
   assertEquals(
       "expected addProject to append object at the end of the array.",
       lastIndex + 1,
       s.getProjects().indexOf(testProject_1));
   for (Project project : testProject_rest) {
     s.addProject(project);
   }
   assertEquals(
       "expect to add %d projects.", testProject_rest.size() + 1, s.getNumberOfPreferences());
 }
Exemplo n.º 24
0
  @Test
  public void studentWithNullUsernameIsEqualToStudentWithNullUsername() {

    final Student other = new Student();

    assertTrue(student.equals(other));
  }
Exemplo n.º 25
0
 @Test
 public void bstSize() {
   BST tree = new BST();
   Student s = new Student("HeyySurname", "HeyyName", 2, 300, 10.1f, "HeyyStreet");
   tree.insert(s.getId(), s);
   assertEquals(1, tree.size());
   Student s1 = new Student("HeyySurname1", "HeyyName1", 2, 101, 10.1f, "HeyyStreet");
   tree.insert(s1.getId(), s1);
   Student s2 = new Student("HeyySurname2", "HeyyName2", 2, 102, 10.1f, "HeyyStreet");
   tree.insert(s2.getId(), s2);
   Student s3 = new Student("HeyySurname3", "HeyyName3", 2, 103, 10.1f, "HeyyStreet");
   tree.insert(s3.getId(), s3);
   Student s4 = new Student("HeyySurname4", "HeyyName4", 2, 99, 10.1f, "HeyyStreet");
   tree.insert(s4.getId(), s4);
   assertEquals(5, tree.size());
 }
Exemplo n.º 26
0
 @Test
 public void testGetNumberOfStatedPreferences() {
   assertEquals(0, s.getNumberOfStatedPreferences());
   s.addProject(testProject_1);
   assertEquals(0, s.getNumberOfStatedPreferences());
   for (Project p : testProject_rest) {
     s.addProject(p);
   }
   assertEquals(0, s.getNumberOfStatedPreferences());
   s.setNumberOfStatedPreferences(100);
   assertEquals(100, s.getNumberOfStatedPreferences());
   s.preassignProject(testProject_1);
   assertEquals(1, s.getNumberOfStatedPreferences());
 }
Exemplo n.º 27
0
 @Test
 public void testGetRandomPreference() throws Exception {
   int seed = 123;
   int num = 1;
   List<Project> expected = TheRNG().TestRandomPreferenceUtility(preped_s, seed, num);
   TheRNG().setSeed(seed);
   Project got = preped_s.getRandomPreference();
   assertEquals("should equal", expected.get(0), got);
 }
Exemplo n.º 28
0
 @Test
 public void bstInOrderTraverse() {
   BST tree = new BST();
   Student s = new Student("HeyySurname", "HeyyName", 2, 120, 10.1f, "HeyyStreet");
   tree.insert(s.getId(), s);
   assertEquals(1, tree.size());
   Student s1 = new Student("HeyySurname1", "HeyyName1", 2, 99, 10.1f, "HeyyStreet");
   tree.insert(s1.getId(), s1);
   Student s2 = new Student("HeyySurname2", "HeyyName2", 2, 97, 10.1f, "HeyyStreet");
   tree.insert(s2.getId(), s2);
   Student s3 = new Student("HeyySurname3", "HeyyName3", 2, 98, 10.1f, "HeyyStreet");
   tree.insert(s3.getId(), s3);
   Student s4 = new Student("HeyySurname4", "HeyyName4", 2, 131, 10.1f, "HeyyStreet");
   tree.insert(s4.getId(), s4);
   java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
   System.setOut(new java.io.PrintStream(out));
   tree.traverse();
   System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
   String outputStringTraversal = out.toString().split("\n")[2];
   assertEquals("97 98 99 120 131 ", outputStringTraversal);
 }
Exemplo n.º 29
0
 @Before
 public void setUp() throws Exception {
   testProject_1 = new Project("Test The Project of the First Non-Sense");
   s = new Student("test student");
   testProject_rest = new ArrayList<Project>();
   Random r = new Random();
   for (int i = 0; i < 50; i++)
     testProject_rest.add(new Project("test project another " + r.nextInt()));
   preped_s = new Student("I'm prepared");
   for (Project p : testProject_rest) {
     preped_s.addProject(p);
   }
 }
Exemplo n.º 30
0
  @Test
  public void hashCodeIsSameForTwoUsersWithSameUsernames() {

    final Student student1 = new Student();
    student1.setUsername(USERNAME);

    final Student student2 = new Student();
    student2.setUsername(USERNAME);

    assertEquals(student1.hashCode(), student2.hashCode());
  }