Example #1
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());
 }
Example #2
0
 @Test
 public void testDescriptionAnyLengt() {
   String[] validValues = {
     stringUtil.getWithLength(8941),
     stringUtil.getWithLength(2),
     stringUtil.getWithLength(10000000)
   };
   for (String s : validValues) {
     validTrial.setDescription(s);
     assertEquals(s, validTrial.getDescription());
     assertValid(validTrial);
   }
 }
Example #3
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);
  }
Example #4
0
 @Test
 public void testDescriptionEmpty() {
   validTrial.setDescription("");
   assertEquals("", validTrial.getDescription());
   assertValid(validTrial);
 }
Example #5
0
 @Test
 public void testDescriptionNull() {
   validTrial.setDescription(null);
   assertNull(validTrial.getDescription());
   assertValid(validTrial);
 }