示例#1
0
 @Test
 public void testAbbreviationNotLongerThan255() {
   String[] invalidValue = {stringUtil.getWithLength(256), stringUtil.getWithLength(600)};
   for (String s : invalidValue) {
     validTrial.setAbbreviation(s);
     assertEquals(s, validTrial.getAbbreviation());
     assertInvalid(validTrial);
   }
 }
示例#2
0
 @Test
 public void testAbbreviationCorrect() {
   String[] validValue = {
     stringUtil.getWithLength(255), stringUtil.getWithLength(1), stringUtil.getWithLength(136)
   };
   for (String s : validValue) {
     validTrial.setAbbreviation(s);
     assertEquals(s, validTrial.getAbbreviation());
     assertValid(validTrial);
   }
 }
示例#3
0
 @Test
 public void testConstructor() {
   final Trial t = new Trial();
   assertEquals("", t.getName());
   assertEquals("", t.getDescription());
   assertEquals("", t.getAbbreviation());
   assertNull(t.getStartDate());
   assertNull(t.getEndDate());
   assertEquals(TrialStatus.IN_PREPARATION, t.getStatus());
   assertNull(t.getProtocol());
   assertEquals(0, t.getParticipatingSites().size());
 }
示例#4
0
  @Override
  @Transactional(propagation = Propagation.REQUIRED)
  public void logTrialChange(
      LogEntry.ActionType action, String username, Trial oldTrial, Trial changedTrial) {
    LogEntry entry = new LogEntry();
    entry.setAction(action);
    entry.setUsername(username);
    entry.setClazz(Trial.class);
    entry.setIdentifier(changedTrial.getId());

    StringBuilder sb = new StringBuilder();
    if (!oldTrial.getName().equals(changedTrial.getName())) {
      sb.append("Name: ")
          .append(oldTrial.getName())
          .append(" -> ")
          .append(changedTrial.getName())
          .append(" | ");
    }
    if (!oldTrial.getAbbreviation().equals(changedTrial.getAbbreviation())) {
      sb.append("Abbreviation: ")
          .append(oldTrial.getAbbreviation())
          .append(" -> ")
          .append(changedTrial.getAbbreviation())
          .append(" | ");
    }
    if (!oldTrial.getDescription().equals(changedTrial.getDescription())) {
      sb.append("Description: ")
          .append(oldTrial.getDescription())
          .append(" -> ")
          .append(changedTrial.getDescription())
          .append(" | ");
    }
    if (!oldTrial.getStartDate().equals(changedTrial.getStartDate())) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      sb.append("Start-Date: ")
          .append(sdf.format(oldTrial.getStartDate().getTime()))
          .append(" -> ")
          .append(sdf.format(changedTrial.getStartDate().getTime()))
          .append(" | ");
    }
    if (!oldTrial.getEndDate().equals(changedTrial.getEndDate())) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      sb.append("End-Date: ")
          .append(sdf.format(oldTrial.getEndDate().getTime()))
          .append(" -> ")
          .append(sdf.format(changedTrial.getEndDate().getTime()))
          .append(" | ");
    }
    if (!oldTrial.getLeadingSite().equals(changedTrial.getLeadingSite())) {
      sb.append("Leading Site: ")
          .append(oldTrial.getLeadingSite().getName())
          .append(" -> ")
          .append(changedTrial.getLeadingSite().getName())
          .append(" | ");
    }
    if (!oldTrial.getSponsorInvestigator().equals(changedTrial.getSponsorInvestigator())) {
      sb.append("Sponsor investigator: ")
          .append(oldTrial.getSponsorInvestigator().getUIName())
          .append(" -> ")
          .append(changedTrial.getSponsorInvestigator().getUIName())
          .append(" | ");
    }
    if (!(oldTrial.getStatus() == changedTrial.getStatus())) {
      sb.append("Status: ")
          .append(oldTrial.getStatus())
          .append(" -> ")
          .append(changedTrial.getStatus());
    }
    if (sb.length() == 0) {
      sb.append(changedTrial.getAbbreviation());
    }
    entry.setUiName(sb.toString());
    entry.setValue(sb.toString());
    entityManager.persist(entry);
  }
示例#5
0
 @Test
 public void testAbbreviationEmpty() {
   validTrial.setAbbreviation("");
   assertEquals("", validTrial.getAbbreviation());
   assertValid(validTrial);
 }
示例#6
0
 @Test
 public void testAbbreviationNull() {
   validTrial.setAbbreviation(null);
   assertNull(validTrial.getAbbreviation());
   assertValid(validTrial);
 }