@Override @Before public void setUp() throws Exception { super.setUp(); parentSpc = SpecimenHelper.addParentSpecimen(); site = SiteHelper.addSite("testsite" + r.nextInt()); ContainerTypeWrapper typeChild = ContainerTypeHelper.addContainerType( site, "ctTypeChild" + r.nextInt(), "ctChild", 1, 4, 5, false); typeChild.addToSpecimenTypeCollection( Arrays.asList( DbHelper.chooseRandomlyInList( SpecimenTypeWrapper.getAllSpecimenTypes(appService, false)))); typeChild.persist(); ContainerTypeWrapper topType = ContainerTypeHelper.addContainerType(site, "topType" + r.nextInt(), "ct", 1, 4, 5, true); topType.addToChildContainerTypeCollection(Arrays.asList(typeChild)); topType.persist(); topContainer = ContainerHelper.addContainer("top" + r.nextInt(), "cc", site, topType); ContainerWrapper container = ContainerHelper.addContainer(null, "2nd", topContainer, site, typeChild, 3, 3); childSpc = SpecimenHelper.addSpecimens(parentSpc, container, 0, 0, 1).get(0); }
@Test public void testGetCenterString() throws Exception { String name = "testGetCenterString" + r.nextInt(); ClinicWrapper clinic = ClinicHelper.addClinic(name); StudyWrapper study = StudyHelper.addStudy(name); PatientWrapper patient = PatientHelper.addPatient(name, study); SpecimenWrapper spc = SpecimenHelper.addParentSpecimen(clinic, study, patient); Assert.assertTrue(spc.getCenterString().equals(clinic.getNameShort())); spc.setCurrentCenter(null); spc.persist(); Assert.assertFalse(spc.getCenterString().equals(clinic.getNameShort())); Assert.assertNotNull(spc.getCenterString()); Assert.assertFalse("".equals(spc.getCenterString())); }