Esempio n. 1
0
  @Test
  public void testPersistPositionAlreadyUsed() throws BiobankCheckException, Exception {
    parentSpc.persist();
    RowColPos pos = childSpc.getPosition();

    SpecimenWrapper duplicate =
        SpecimenHelper.newSpecimen(
            parentSpc,
            childSpc.getSpecimenType(),
            ActivityStatus.ACTIVE,
            childSpc.getProcessingEvent(),
            childSpc.getParentContainer(),
            pos.getRow(),
            pos.getCol());

    try {
      duplicate.persist();
      Assert.fail("should not be allowed to add an specimen in a position that is not empty");
    } catch (BiobankSessionException bce) {
      Assert.assertTrue(true);
    }

    duplicate.setParent(duplicate.getParentContainer(), new RowColPos(2, 3));
    duplicate.persist();

    duplicate.setInventoryId(Utils.getRandomString(5));
    duplicate.persist();
  }
Esempio n. 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);
  }
Esempio n. 3
0
  @Test
  public void testGetSpecimen() throws Exception {
    SpecimenWrapper foundSpecimen =
        SpecimenWrapper.getSpecimen(appService, childSpc.getInventoryId());
    Assert.assertNotNull(foundSpecimen);
    Assert.assertEquals(foundSpecimen, childSpc);

    foundSpecimen = SpecimenWrapper.getSpecimen(appService, Utils.getRandomString(5));
    Assert.assertNull(foundSpecimen);
    Assert.fail("how to test the exception throwing?");
  }
Esempio n. 4
0
 public static String getNewInventoryId(Random r) {
   if (inventoryIds == null) {
     inventoryIds = new ArrayList<String>();
   }
   String id;
   do {
     id = Utils.getRandomString(10, 20);
   } while (inventoryIds.contains(id));
   inventoryIds.add(id);
   return id;
 }
Esempio n. 5
0
  public static String getUniqueWorksheet(Random r) {
    if (usedWorksheets == null) {
      usedWorksheets = new ArrayList<String>();
    }

    String worksheet;
    do {
      worksheet = Utils.getRandomString(20);
    } while (usedWorksheets.contains(worksheet));
    usedWorksheets.add(worksheet);
    return worksheet;
  }
Esempio n. 6
0
  public static String getNewWaybill(Random r) {
    if (usedWaybills == null) {
      usedWaybills = new ArrayList<String>();
    }

    String waybill;
    do {
      waybill = Utils.getRandomString(10);
    } while (usedWaybills.contains(waybill));
    usedWaybills.add(waybill);
    return waybill;
  }
Esempio n. 7
0
  public static String getNewBarcode(Random r) {
    if (usedBarcodes == null) {
      usedBarcodes = new ArrayList<String>();
    }

    String newBarcode;
    do {
      newBarcode = Utils.getRandomString(10, 12);
    } while (usedBarcodes.contains(newBarcode));
    usedBarcodes.add(newBarcode);
    return newBarcode;
  }
Esempio n. 8
0
  @Test
  public void testAddUserFailAndCsmUser() throws Exception {
    UserWrapper user = new UserWrapper(appService);
    String login = Utils.getRandomString(300, 400);
    user.setLogin(login);
    // FIXME should use another test because I should set login length to be
    // the same between csm_user and our user table. Maybe in using a
    // WrapperTransation with something sending an error to make the commit
    // fail
    try {
      user.persist();
      Assert.fail();
    } catch (Exception ex) {
      Assert.assertTrue("should fail because login is too long", true);
    }
    // check csm user
    UserProvisioningManager upm =
        SecurityServiceProvider.getUserProvisioningManager(
            BiobankCSMSecurityUtil.APPLICATION_CONTEXT_NAME);

    gov.nih.nci.security.authorization.domainobjects.User csmUser = upm.getUser(login);
    Assert.assertNull(csmUser);
  }
Esempio n. 9
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();
    }
  }