예제 #1
0
  @Test
  public void testEqualsHashCode() {
    Trial trial1 = new Trial();
    Trial trial2 = new Trial();
    trial1.setId(0);
    trial2.setId(0);
    trial1.setVersion(0);
    trial2.setVersion(0);
    assertEquals(trial1, trial2);
    assertEquals(trial1.hashCode(), trial2.hashCode());
    trial1.setId(1);

    assertFalse(trial1.equals(trial2));
    trial1.setId(0);
    assertEquals(trial1, trial2);
    assertEquals(trial1.hashCode(), trial2.hashCode());

    trial1.setVersion(1);
    assertFalse(trial1.equals(trial2));
    trial1.setVersion(0);
    assertEquals(trial1, trial2);
    assertEquals(trial1.hashCode(), trial2.hashCode());

    trial1.setName("test");
    assertFalse(trial1.equals(trial2));
    trial2.setName("test");
    assertEquals(trial1, trial2);
    assertEquals(trial1.hashCode(), trial2.hashCode());

    assertFalse(trial1.equals(null));
    assertFalse(trial1.equals(new TreatmentArm()));
  }
예제 #2
0
 @Test
 public void testNameLongerThan255() {
   String[] invalidValues = {stringUtil.getWithLength(256), stringUtil.getWithLength(650)};
   for (String s : invalidValues) {
     validTrial.setName(s);
     assertEquals(s, validTrial.getName());
     assertInvalid(validTrial);
   }
 }
예제 #3
0
 @Test
 public void testNameCorrect() {
   String[] validValues = {
     stringUtil.getWithLength(254),
     stringUtil.getWithLength(2),
     "Name",
     stringUtil.getWithLength(132)
   };
   for (String s : validValues) {
     validTrial.setName(s);
     assertEquals(s, validTrial.getName());
     assertValid(validTrial);
   }
 }
예제 #4
0
 @Test
 public void testNameNotEmpty() {
   validTrial.setName("");
   assertEquals("", validTrial.getName());
   assertInvalid(validTrial);
 }
예제 #5
0
 @Test
 public void testNameNotNull() {
   validTrial.setName(null);
   assertNull(validTrial.getName());
   assertInvalid(validTrial);
 }