Пример #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();
  }
Пример #2
0
  @Test
  public void testGetSetPosition() throws Exception {
    RowColPos position = new RowColPos(1, 3);
    childSpc.setParent(childSpc.getParentContainer(), position);
    RowColPos newPosition = childSpc.getPosition();
    Assert.assertEquals(position.getRow(), newPosition.getRow());
    Assert.assertEquals(position.getCol(), newPosition.getCol());

    // ensure position remains after persist
    childSpc.persist();
    childSpc.reload();
    newPosition = childSpc.getPosition();
    Assert.assertEquals(position.getRow(), newPosition.getRow());
    Assert.assertEquals(position.getCol(), newPosition.getCol());

    // test setting position to null
    childSpc.setParent(null, null);
    childSpc.persist();
    childSpc.reload();
    Assert.assertEquals(null, childSpc.getPosition());
    Assert.assertEquals(null, childSpc.getParentContainer());
  }
Пример #3
0
  @Test
  public void testSetSpecimenPositionFromString() throws Exception {
    childSpc.setParentFromPositionString("A1", childSpc.getParentContainer());
    childSpc.persist();
    Assert.assertTrue(childSpc.getPositionString(false, false).equals("A1"));
    RowColPos pos = childSpc.getPosition();
    Assert.assertTrue((pos.getCol() == 0) && (pos.getRow() == 0));

    childSpc.setParentFromPositionString("C2", childSpc.getParentContainer());
    childSpc.persist();
    Assert.assertTrue(childSpc.getPositionString(false, false).equals("C2"));
    pos = childSpc.getPosition();
    Assert.assertTrue((pos.getCol() == 1) && (pos.getRow() == 2));

    try {
      childSpc.setParentFromPositionString("79", childSpc.getParentContainer());
      Assert.fail("invalid position");
    } catch (Exception bce) {
      Assert.assertTrue(true);
    }

    SpecimenWrapper specimen = new SpecimenWrapper(appService);
    Assert.assertNull(specimen.getPositionString());
  }