Exemplo n.º 1
0
  @Test
  public void testPersistCheckInventoryIdUnique() throws BiobankCheckException, Exception {

    SpecimenWrapper duplicate =
        SpecimenHelper.newSpecimen(
            parentSpc,
            childSpc.getSpecimenType(),
            ActivityStatus.ACTIVE,
            childSpc.getProcessingEvent(),
            childSpc.getParentContainer(),
            2,
            2);
    duplicate.setInventoryId(parentSpc.getInventoryId());

    try {
      duplicate.persist();
      Assert.fail("same inventory id !");
    } catch (DuplicatePropertySetException e) {
      Assert.assertTrue(true);
    }
    duplicate.setInventoryId("qqqq" + r.nextInt());
    duplicate.persist();

    duplicate.setInventoryId(parentSpc.getInventoryId());
    try {
      duplicate.persist();
      Assert.fail(
          "still can't save it with  the same inventoryId after a first add with anotehr inventoryId!");
    } catch (DuplicatePropertySetException e) {
      Assert.assertTrue(true);
    }
  }
Exemplo n.º 2
0
 @Test
 public void testResetAlreadyInDatabase() throws Exception {
   parentSpc.persist();
   String old = parentSpc.getInventoryId();
   parentSpc.setInventoryId("toto");
   parentSpc.reset();
   Assert.assertEquals(old, parentSpc.getInventoryId());
 }
Exemplo n.º 3
0
 @Test
 public void testResetNew() throws Exception {
   SpecimenWrapper newSpec = SpecimenHelper.newSpecimen(parentSpc.getSpecimenType());
   newSpec.setInventoryId("toto");
   newSpec.reset();
   Assert.assertEquals(null, newSpec.getInventoryId());
 }
Exemplo n.º 4
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?");
  }
Exemplo n.º 5
0
  @Test
  public void testCheckInventoryIdUnique() throws BiobankCheckException, Exception {
    SpecimenWrapper duplicate =
        SpecimenHelper.newSpecimen(
            parentSpc,
            childSpc.getSpecimenType(),
            ActivityStatus.ACTIVE,
            childSpc.getProcessingEvent(),
            childSpc.getParentContainer(),
            2,
            2);

    duplicate.setInventoryId(parentSpc.getInventoryId());
    try {
      duplicate.checkInventoryIdUnique();
      Assert.fail("The check should detect that this is the same");
    } catch (DuplicateEntryException e) {
      Assert.assertTrue(true);
    }
  }