コード例 #1
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @Test
  public void testSetQuantityFromType() throws Exception {
    SpecimenTypeWrapper type = parentSpc.getSpecimenType();
    Assert.assertNull(parentSpc.getQuantity());

    parentSpc.setSpecimenType(null);
    parentSpc.setQuantityFromType();
    // no specimen type, no change
    Assert.assertNull(parentSpc.getQuantity());

    parentSpc.setSpecimenType(type);
    parentSpc.setQuantityFromType();
    // no aliquotedspecimen with this type in study, no change
    Assert.assertNull(parentSpc.getQuantity());

    StudyWrapper study = parentSpc.getCollectionEvent().getPatient().getStudy();
    AliquotedSpecimenWrapper as =
        AliquotedSpecimenHelper.addAliquotedSpecimen(study, parentSpc.getSpecimenType());
    study.reload();
    Assert.assertNotNull(as.getVolume());
    Assert.assertTrue(!as.getVolume().equals(BigDecimal.ZERO));

    parentSpc.setQuantityFromType();

    Assert.assertTrue(as.getVolume().equals(parentSpc.getQuantity()));
  }
コード例 #2
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @Test
  public void testGetSetSpecimenType() throws BiobankCheckException, Exception {
    SpecimenTypeWrapper stw = parentSpc.getSpecimenType();
    SpecimenTypeWrapper newType = SpecimenTypeHelper.addSpecimenType("newStw");
    stw.persist();
    Assert.assertTrue(stw.getId() != newType.getId());
    parentSpc.setSpecimenType(newType);
    Assert.assertTrue(newType.getId() == parentSpc.getSpecimenType().getId());

    SpecimenWrapper sample1 = new SpecimenWrapper(appService);
    sample1.setSpecimenType(null);
    Assert.assertNull(sample1.getSpecimenType());
  }
コード例 #3
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @Test
  public void testPersistCheckParentAcceptSpecimenType() throws BiobankCheckException, Exception {
    SpecimenTypeWrapper oldSpecimenType = childSpc.getSpecimenType();

    SpecimenTypeWrapper type2 = SpecimenTypeHelper.addSpecimenType("sampletype_2");
    childSpc.setSpecimenType(type2);
    try {
      childSpc.persist();
      Assert.fail("Container can't hold this type !");
    } catch (InvalidOptionException e) {
      Assert.assertTrue(true);
    }

    childSpc.setSpecimenType(oldSpecimenType);
    childSpc.persist();
  }
コード例 #4
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @Test
  public void testDelete() throws Exception {
    String name = "testDelete" + r.nextInt();
    SpecimenTypeWrapper type1 = childSpc.getSpecimenType();

    try {
      type1.delete();
      Assert.fail("cannot delete a type in use by a specimen");
    } catch (ModelIsUsedException e) {
      Assert.assertTrue(true);
    }

    SpecimenTypeWrapper type2 = SpecimenTypeHelper.addSpecimenType(name + "_st2");
    SpecimenTypeHelper.removeFromCreated(type2);

    ContainerTypeWrapper typeChild = childSpc.getParentContainer().getContainerType();

    typeChild.addToSpecimenTypeCollection(Arrays.asList(type2));
    typeChild.persist();

    childSpc.reload();
    childSpc.setSpecimenType(type2);
    childSpc.persist();

    try {
      type2.delete();
      Assert.fail("cannot delete a type in use by a specimen");
    } catch (ModelIsUsedException e) {
      Assert.assertTrue(true);
    }

    childSpc.setSpecimenType(type1);
    childSpc.persist();

    typeChild.removeFromSpecimenTypeCollectionWithCheck(Arrays.asList(type2));
    typeChild.persist();

    type2.delete();
  }
コード例 #5
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
 @Test
 public void testHasUnknownImportType() throws ApplicationException {
   Assert.assertFalse(childSpc.hasUnknownImportType());
   SpecimenTypeWrapper unknownType = null;
   for (SpecimenTypeWrapper type :
       SpecimenTypeWrapper.getAllSourceOnlySpecimenTypes(appService, false)) {
     if (type.isUnknownImport()) {
       unknownType = type;
       break;
     }
   }
   childSpc.setSpecimenType(unknownType);
   Assert.assertTrue(childSpc.hasUnknownImportType());
 }