Ejemplo n.º 1
0
  @Before
  public void setUp() {
    System.setProperty("nhinc.properties.dir", System.getenv("NHINC_PROPERTIES_DIR"));
    // create first test PseudonymMap
    pseudonymMap_1 = new PseudonymMap();
    pseudonymMap_1.setPseudonymPatientId(pseudoPatientId_1);
    pseudonymMap_1.setPseudonymPatientIdAssigningAuthority(pseudoAuthorityId_1);
    pseudonymMap_1.setRealPatientId(realPatientId_1);
    pseudonymMap_1.setRealPatientIdAssigningAuthority(realAuthorityId_1);

    // create second test PseudonymMap - only difference is pseudoPatientId
    pseudonymMap_2 = new PseudonymMap();
    pseudonymMap_2.setPseudonymPatientId(pseudoPatientId_2);
    pseudonymMap_2.setPseudonymPatientIdAssigningAuthority(pseudoAuthorityId_2);
    pseudonymMap_2.setRealPatientId(realPatientId_2);
    pseudonymMap_2.setRealPatientIdAssigningAuthority(realAuthorityId_2);

    // create third test PseudonymMap - Ids are different
    pseudonymMap_3 = new PseudonymMap();
    pseudonymMap_3.setPseudonymPatientId(pseudoPatientId_3);
    pseudonymMap_3.setPseudonymPatientIdAssigningAuthority(pseudoAuthorityId_3);
    pseudonymMap_3.setRealPatientId(realPatientId_3);
    pseudonymMap_3.setRealPatientIdAssigningAuthority(realAuthorityId_3);

    // initialize contents of internal memory
    PseudonymMapManager.readMap();
  }
Ejemplo n.º 2
0
  /** 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");
  }
Ejemplo n.º 3
0
  /** 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");
  }
Ejemplo n.º 4
0
  /** 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");
  }
Ejemplo n.º 5
0
 @After
 public void tearDown() {
   // reset external memory
   PseudonymMapManager.writeMap();
 }