コード例 #1
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @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);
    }
  }
コード例 #2
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
 @Test
 public void testResetAlreadyInDatabase() throws Exception {
   parentSpc.persist();
   String old = parentSpc.getInventoryId();
   parentSpc.setInventoryId("toto");
   parentSpc.reset();
   Assert.assertEquals(old, parentSpc.getInventoryId());
 }
コード例 #3
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
 @Test
 public void testResetNew() throws Exception {
   SpecimenWrapper newSpec = SpecimenHelper.newSpecimen(parentSpc.getSpecimenType());
   newSpec.setInventoryId("toto");
   newSpec.reset();
   Assert.assertEquals(null, newSpec.getInventoryId());
 }
コード例 #4
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @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?");
  }
コード例 #5
0
ファイル: TestSpecimen.java プロジェクト: cbsrbiobank/biobank
  @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);
    }
  }