示例#1
0
  @Test
  public void testGetPositionString() throws Exception {
    childSpc.setParentFromPositionString("A1", childSpc.getParentContainer());
    Assert.assertTrue(childSpc.getPositionString(false, false).equals("A1"));
    String parentLabel = childSpc.getParentContainer().getLabel();
    Assert.assertTrue(childSpc.getPositionString(true, false).equals(parentLabel + "A1"));
    // getPositionString with no parameters is equivalent to
    // getPositionString(true, true)
    Assert.assertTrue(
        childSpc
            .getPositionString()
            .equals(parentLabel + "A1 (" + topContainer.getContainerType().getNameShort() + ")"));

    childSpc.setParent(null, null);
    Assert.assertNull(childSpc.getPositionString(false, false));
  }
示例#2
0
  @Test
  public void testGetSpecimensInSiteWithPositionLabel() throws Exception {
    ContainerWrapper container = childSpc.getParentContainer();
    ContainerTypeWrapper containerType = container.getContainerType();
    SpecimenTypeWrapper sampleType = containerType.getSpecimenTypeCollection(false).get(0);
    Assert.assertNotNull(sampleType);
    childSpc.setInventoryId(Utils.getRandomString(5));
    childSpc.persist();

    SpecimenHelper.newSpecimen(
        childSpc,
        childSpc.getSpecimenType(),
        ActivityStatus.ACTIVE,
        childSpc.getProcessingEvent(),
        childSpc.getParentContainer(),
        0,
        1);

    SpecimenHelper.newSpecimen(
        childSpc,
        childSpc.getSpecimenType(),
        ActivityStatus.ACTIVE,
        childSpc.getProcessingEvent(),
        childSpc.getParentContainer(),
        1,
        0);

    childSpc =
        SpecimenHelper.newSpecimen(
            childSpc,
            childSpc.getSpecimenType(),
            ActivityStatus.ACTIVE,
            childSpc.getProcessingEvent(),
            childSpc.getParentContainer(),
            0,
            2);
    childSpc.setInventoryId(Utils.getRandomString(5));
    childSpc.persist();

    List<SpecimenWrapper> specimens =
        SpecimenWrapper.getSpecimensInSiteWithPositionLabel(
            appService, site, childSpc.getPositionString(true, false));
    Assert.assertEquals(1, specimens.size());
    Assert.assertEquals(specimens.get(0), childSpc);
  }
示例#3
0
  @Test
  public void testGetSpecimensNonActive() throws Exception {
    ContainerWrapper container = childSpc.getParentContainer();
    ContainerTypeWrapper containerType = container.getContainerType();
    SpecimenTypeWrapper sampleType = containerType.getSpecimenTypeCollection(false).get(0);
    Assert.assertNotNull(sampleType);

    ActivityStatus activityStatusNonActive = ActivityStatus.CLOSED;

    List<SpecimenWrapper> activeSpecimens = new ArrayList<SpecimenWrapper>();
    List<SpecimenWrapper> nonActiveSpecimens = new ArrayList<SpecimenWrapper>();

    activeSpecimens.add(childSpc);
    for (int i = 1, n = container.getColCapacity(); i < n; ++i) {
      activeSpecimens.add(
          SpecimenHelper.newSpecimen(
              parentSpc,
              childSpc.getSpecimenType(),
              ActivityStatus.ACTIVE,
              childSpc.getProcessingEvent(),
              childSpc.getParentContainer(),
              0,
              i));

      SpecimenWrapper a =
          SpecimenHelper.newSpecimen(
              parentSpc,
              childSpc.getSpecimenType(),
              ActivityStatus.ACTIVE,
              childSpc.getProcessingEvent(),
              childSpc.getParentContainer(),
              1,
              i);
      a.setActivityStatus(activityStatusNonActive);
      a.persist();
      nonActiveSpecimens.add(a);
    }

    List<SpecimenWrapper> specimens =
        SpecimenWrapper.getSpecimensNonActiveInCenter(appService, site);
    Assert.assertEquals(nonActiveSpecimens.size(), specimens.size());
    Assert.assertTrue(specimens.containsAll(nonActiveSpecimens));
    Assert.assertFalse(specimens.containsAll(activeSpecimens));
  }
示例#4
0
  @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();
    }
  }