Beispiel #1
0
  @Test
  public void testCheckPosition() throws Exception {
    ContainerWrapper container = childSpc.getParentContainer();

    Assert.assertFalse(container.isPositionFree(childSpc.getPosition()));
    Assert.assertTrue(container.isPositionFree(new RowColPos(2, 3)));
  }
Beispiel #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);
  }
Beispiel #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));
  }
Beispiel #4
0
  @Test
  public void testGetSetParent() throws Exception {
    Assert.assertTrue(childSpc.hasParent());
    ContainerWrapper oldParent = childSpc.getParentContainer();
    ContainerTypeWrapper type =
        ContainerTypeHelper.addContainerType(site, "newCtType", "ctNew", 1, 4, 5, true);
    type.addToSpecimenTypeCollection(Arrays.asList(childSpc.getSpecimenType()));
    type.persist();
    ContainerWrapper parent =
        ContainerHelper.addContainer("newcontainerParent", "ccNew", site, type);

    childSpc.setParent(parent, childSpc.getPosition());
    childSpc.persist();
    // check to make sure gone from old parent
    oldParent.reload();
    Assert.assertTrue(oldParent.getSpecimens().size() == 0);
    // check to make sure added to new parent
    parent.reload();
    Assert.assertTrue(childSpc.getParentContainer() != null);
    Collection<SpecimenWrapper> sampleWrappers = parent.getSpecimens().values();
    boolean found = false;
    for (SpecimenWrapper sampleWrapper : sampleWrappers) {
      if (sampleWrapper.getId().equals(childSpc.getId())) found = true;
    }
    Assert.assertTrue(found);

    // test for no parent
    SpecimenWrapper specimen2 = new SpecimenWrapper(appService);
    Assert.assertFalse(specimen2.hasParent());
  }
Beispiel #5
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));
  }
Beispiel #6
0
  /*
   * childSpc created in setUp()
   */
  @Test
  public void testGetDispatches() throws Exception {
    String name = "testGetDispatches" + r.nextInt();
    SiteWrapper destSite = SiteHelper.addSite(name);
    ShippingMethodWrapper method = ShippingMethodWrapper.getShippingMethods(appService).get(0);
    DispatchWrapper d = DispatchHelper.addDispatch(site, destSite, method);

    d.addSpecimens(Arrays.asList(childSpc), DispatchSpecimenState.NONE);
    d.persist();
    childSpc.reload();

    List<DispatchWrapper> specimenDispatches = childSpc.getDispatches();
    Assert.assertEquals(1, specimenDispatches.size());
    Assert.assertTrue(specimenDispatches.contains(d));

    Assert.assertTrue(d.isInCreationState());

    // site send specimens
    d.setState(DispatchState.IN_TRANSIT);
    d.persist();
    Assert.assertTrue(d.isInTransitState());

    // dest site receive specimen
    d.setState(DispatchState.RECEIVED);
    d.receiveSpecimens(Arrays.asList(childSpc));
    d.persist();
    Assert.assertTrue(d.isInReceivedState());

    // make sure spc now belongs to destSite
    destSite.reload();
    childSpc.reload();
    Assert.assertEquals(destSite, childSpc.getCurrentCenter());

    // dispatch specimen to second site
    SiteWrapper destSite2 = SiteHelper.addSite(name + "_2");

    DispatchWrapper d2 = DispatchHelper.addDispatch(destSite, destSite2, method);
    d2.addSpecimens(Arrays.asList(childSpc), DispatchSpecimenState.NONE);

    parentSpc.reload();
    // assign a position to this specimen
    ContainerTypeWrapper topType =
        ContainerTypeHelper.addContainerType(destSite, "ct11", "ct11", 1, 5, 6, true);
    ContainerWrapper topCont = ContainerHelper.addContainer("11", "11", destSite, topType);
    ContainerTypeWrapper childType =
        ContainerTypeHelper.addContainerType(destSite, "ct22", "ct22", 2, 4, 7, false);
    topType.addToChildContainerTypeCollection(Arrays.asList(childType));
    topType.persist();
    ContainerWrapper cont =
        ContainerHelper.addContainer("22", "22", topCont, destSite, childType, 4, 5);
    childType.addToSpecimenTypeCollection(Arrays.asList(childSpc.getSpecimenType()));
    childType.persist();
    cont.reload();
    cont.addSpecimen(2, 3, childSpc);
    parentSpc.persist();

    // add to new dispatch
    d2.addSpecimens(Arrays.asList(childSpc), DispatchSpecimenState.NONE);
    d2.persist();

    // make sure spc still belongs to destSite
    destSite2.reload();
    childSpc.reload();
    Assert.assertEquals(destSite2, childSpc.getCurrentCenter());

    childSpc.reload();
    specimenDispatches = childSpc.getDispatches();
    Assert.assertEquals(2, specimenDispatches.size());
    Assert.assertTrue(specimenDispatches.contains(d));
    Assert.assertTrue(specimenDispatches.contains(d2));
  }
Beispiel #7
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();
    }
  }