Пример #1
0
  @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();
  }
Пример #2
0
  @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
  @Test
  public void testGetSetQuantityFromType() throws Exception {
    BigDecimal quantity = parentSpc.getQuantity();
    parentSpc.setQuantityFromType();
    // no sample storages defined yet, should be null
    Assert.assertTrue(quantity == null);

    ActivityStatus activeStatus = ActivityStatus.ACTIVE;

    AliquotedSpecimenWrapper ss1 = new AliquotedSpecimenWrapper(appService);
    ss1.setSpecimenType(SpecimenTypeHelper.addSpecimenType("ss1"));
    ss1.setVolume(new BigDecimal(1.0));
    ss1.setStudy(parentSpc.getCollectionEvent().getPatient().getStudy());
    ss1.setActivityStatus(activeStatus);
    ss1.persist();
    AliquotedSpecimenWrapper ss2 = new AliquotedSpecimenWrapper(appService);
    ss2.setSpecimenType(SpecimenTypeHelper.addSpecimenType("ss2"));
    ss2.setVolume(new BigDecimal(2.0));
    ss2.setStudy(parentSpc.getCollectionEvent().getPatient().getStudy());
    ss2.setActivityStatus(activeStatus);
    ss2.persist();
    AliquotedSpecimenWrapper ss3 = new AliquotedSpecimenWrapper(appService);
    ss3.setSpecimenType(parentSpc.getSpecimenType());
    ss3.setVolume(new BigDecimal(3.0));
    ss3.setStudy(parentSpc.getCollectionEvent().getPatient().getStudy());
    ss3.setActivityStatus(activeStatus);
    ss3.persist();
    parentSpc
        .getCollectionEvent()
        .getPatient()
        .getStudy()
        .addToAliquotedSpecimenCollection(Arrays.asList(ss1, ss2, ss3));
    // should be 3
    parentSpc.setQuantityFromType();
    Assert.assertTrue(parentSpc.getQuantity().equals(3.0));
  }
Пример #4
0
  @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();
  }