/** Test the replacement of data given the same id */ @Test public void testIdReplacement() { log.debug("Entering PseudonymMapTest.testIdReplacement"); // pseudonymMap for this Id should previously exist and return the old one PseudonymMap prevMap = PseudonymMapManager.addPseudonymMap(pseudonymMap_2); assertNotNull(prevMap); // and should be the same as what we created previously assertEquals(pseudonymMap_1.toString(), prevMap.toString()); // pseudonymMap for this Id should not previously exist PseudonymMap newMap = PseudonymMapManager.addPseudonymMap(pseudonymMap_3); assertNull(newMap); PseudonymMapManager.writeMap(); PseudonymMapManager.readMap(); PseudonymMap searchMap = PseudonymMapManager.findPseudonymMap(pseudoAuthorityId_2, pseudoPatientId_2); // pseudonymMap should be located assertNotNull(searchMap); // and should be the same as what we created previously as 2 assertEquals(pseudonymMap_2.toString(), searchMap.toString()); searchMap = PseudonymMapManager.findPseudonymMap(pseudoAuthorityId_3, pseudoPatientId_3); // pseudonymMap should be located assertNotNull(searchMap); // and should be the same as what we created previously as 3 assertEquals(pseudonymMap_3.toString(), searchMap.toString()); log.debug("Exiting PseudonymMapTest.testIdReplacement"); }
/** Test the creation of a Pseudonym Map XML file and the extraction of a stored map */ @Test public void testStoreRetrieve() { log.debug("Entering PseudonymMapTest.testStoreRetrieve"); // pseudonymMap should not previously exist assertNull(PseudonymMapManager.addPseudonymMap(pseudonymMap_1)); PseudonymMapManager.writeMap(); PseudonymMapManager.readMap(); PseudonymMap searchMap = PseudonymMapManager.findPseudonymMap(pseudoAuthorityId_1, pseudoPatientId_1); // pseudonymMap should be located assertNotNull(searchMap); // and should be the same as what we created previously assertEquals(pseudonymMap_1.toString(), searchMap.toString()); log.debug("Exiting PseudonymMapTest.testStoreRetrieve"); }
/** Test the removal of maps */ @Test public void testRemoval() { log.debug("Entering PseudonymMapTest.testRemoval"); // pseudonymMap_2 should exist and can be removed assertTrue(PseudonymMapManager.removePseudonymMap(pseudonymMap_2)); // pseudonymMap_3 should exist and can be removed assertTrue(PseudonymMapManager.removePseudonymMap(pseudonymMap_3)); PseudonymMapManager.writeMap(); PseudonymMapManager.readMap(); // neither 1, 2, or 3 should exist now assertFalse(PseudonymMapManager.removePseudonymMap(pseudonymMap_1)); assertFalse(PseudonymMapManager.removePseudonymMap(pseudonymMap_2)); assertFalse(PseudonymMapManager.removePseudonymMap(pseudonymMap_3)); log.debug("Exiting PseudonymMapTest.testRemoval"); }
@After public void tearDown() { // reset external memory PseudonymMapManager.writeMap(); }