コード例 #1
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @Test
  public void testGetFormattedLinkDate() throws Exception {
    Date date = Utils.getRandomDate();
    parentSpc.setCreatedAt(date);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    Assert.assertTrue(sdf.format(date).equals(parentSpc.getFormattedCreatedAt()));
  }
コード例 #2
0
ファイル: TestCommon.java プロジェクト: cbsrbiobank/biobank
 public static Date getUniqueDate(Random r) {
   if (usedDates == null) {
     usedDates = new ArrayList<Date>();
   }
   Date id;
   do {
     id = Utils.getRandomDate();
   } while (usedDates.contains(id));
   usedDates.add(id);
   return id;
 }
コード例 #3
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @Test
  public void testDebugRandomMethods() throws Exception {
    System.out.println(parentSpc.getProcessingEvent());
    System.out.println(childSpc.getProcessingEvent());

    ContainerWrapper container = childSpc.getParentContainer();
    ContainerTypeWrapper containerType = container.getContainerType();
    SpecimenTypeWrapper spcType = containerType.getSpecimenTypeCollection(false).get(0);
    Assert.assertNotNull(spcType);

    System.out.println(parentSpc.getProcessingEvent());
    System.out.println(childSpc.getProcessingEvent());

    ProcessingEventWrapper pevent =
        ProcessingEventHelper.addProcessingEvent(
            childSpc.getCurrentCenter(), Utils.getRandomDate());

    // add aliquoted specimen
    SpecimenWrapper specimen =
        SpecimenHelper.newSpecimen(
            parentSpc,
            childSpc.getSpecimenType(),
            ActivityStatus.ACTIVE,
            childSpc.getProcessingEvent(),
            childSpc.getParentContainer(),
            2,
            3);
    specimen.setInventoryId(Utils.getRandomString(5));
    specimen.persist();

    pevent.addToSpecimenCollection(Arrays.asList(parentSpc));
    pevent.persist();

    SpecimenWrapper s2 =
        SpecimenHelper.newSpecimen(
            childSpc,
            childSpc.getSpecimenType(),
            ActivityStatus.ACTIVE,
            childSpc.getProcessingEvent(),
            childSpc.getParentContainer(),
            2,
            4);
    s2.setParent(null, null);
    s2.setParentSpecimen(null);
    s2.persist();

    try {
      // should find at least one specimen with a parent that is inside a
      // processing event
      Assert.assertTrue(
          DebugUtil.getRandomLinkedAliquotedSpecimens(appService, site.getId()).size() > 0);
      Assert.assertTrue(DebugUtil.getRandomAssignedSpecimens(appService, site.getId()).size() > 0);
      List<SpecimenWrapper> randomNonAssociatedNonDispatchedSpecimens =
          DebugUtil.getRandomNonAssignedNonDispatchedSpecimens(appService, site.getId(), 10);
      Assert.assertTrue(randomNonAssociatedNonDispatchedSpecimens.size() > 0);
    } catch (Exception e) {
      Assert.fail(e.getCause().getMessage());
    }

    try {
      s2.delete();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }