PatientDiscovery201306Processor { public void storeMapping(PRPAIN201306UV02 request) { LOG.debug("Begin storeMapping"); String hcid = getHcid(request); LOG.debug("Begin storeMapping: hcid" + hcid); List<String> assigningAuthorityIds; assigningAuthorityIds = extractAAListFrom201306(request); for (String assigningAuthority : assigningAuthorityIds) { mapAssigningAuthorityHomeCommunity(hcid, assigningAuthority); } LOG.debug("End storeMapping"); }  PRPAIN201306UV02 createNewRequest(PRPAIN201306UV02 request, String targetCommunityId); void storeMapping(PRPAIN201306UV02 request);  }
@Test public void testStoreMappingHappy() { try { PatientDiscovery201306Processor storage = new PatientDiscovery201306Processor() { @Override protected AssigningAuthorityHomeCommunityMappingDAO getAssigningAuthorityHomeCommunityMappingDAO() { return new AssigningAuthorityHomeCommunityMappingDAO() { @Override public boolean storeMapping(String hcid, String assigningAuthorityId) { return true; } }; } @Override protected String getHcid(PRPAIN201306UV02 request) { return "hcid"; } @Override protected List<String> extractAAListFrom201306(PRPAIN201306UV02 request) { List<String> assigningAuthorityIds = new ArrayList<>(); assigningAuthorityIds.add("aa"); return assigningAuthorityIds; } }; storage.storeMapping(mockMessage); } catch (Throwable t) { System.out.println("Error running testStoreMappingHappy: " + t.getMessage()); t.printStackTrace(); fail("Error running testStoreMappingHappy: " + t.getMessage()); } }
@Test public void testStoreMappingNullHcid() { try { PatientDiscovery201306Processor storage = new PatientDiscovery201306Processor() { @Override protected AssigningAuthorityHomeCommunityMappingDAO getAssigningAuthorityHomeCommunityMappingDAO() { return mockMappingDao; } @Override protected String getHcid(PRPAIN201306UV02 request) { return null; } @Override protected List<String> extractAAListFrom201306(PRPAIN201306UV02 request) { List<String> assigningAuthorityIds = new ArrayList<>(); assigningAuthorityIds.add("aa"); return assigningAuthorityIds; } }; storage.storeMapping(mockMessage); } catch (Throwable t) { System.out.println("Error running testStoreMappingNullHcid: " + t.getMessage()); t.printStackTrace(); fail("Error running testStoreMappingNullHcid: " + t.getMessage()); } }
@Test public void testStoreMappingNullAssigningAuthority() { try { PatientDiscovery201306Processor storage = new PatientDiscovery201306Processor() { @Override protected AssigningAuthorityHomeCommunityMappingDAO getAssigningAuthorityHomeCommunityMappingDAO() { return mockMappingDao; } @Override protected String getHcid(PRPAIN201306UV02 request) { return "hcid"; } @Override protected List<String> extractAAListFrom201306(PRPAIN201306UV02 request) { List<String> assigningAuthorityIds = new ArrayList<>(); assigningAuthorityIds.add(null); return assigningAuthorityIds; } }; storage.storeMapping(mockMessage); } catch (Throwable t) { System.out.println("Error running testStoreMappingNullAssigningAuthority: " + t.getMessage()); t.printStackTrace(); fail("Error running testStoreMappingNullAssigningAuthority: " + t.getMessage()); } }
@Test public void testStoreMappingNullMappingDao() { try { PatientDiscovery201306Processor storage = new PatientDiscovery201306Processor() { @Override protected AssigningAuthorityHomeCommunityMappingDAO getAssigningAuthorityHomeCommunityMappingDAO() { return null; } @Override protected String getHcid(PRPAIN201306UV02 request) { return "hcid"; } @Override protected List<String> extractAAListFrom201306(PRPAIN201306UV02 request) { List<String> assigningAuthorityIds = new ArrayList<>(); assigningAuthorityIds.add("aa"); return assigningAuthorityIds; } }; storage.storeMapping(mockMessage); } catch (Throwable t) { System.out.println("Error running testStoreMappingNullMappingDao: " + t.getMessage()); t.printStackTrace(); fail("Error running testStoreMappingNullMappingDao: " + t.getMessage()); } }
@Test public void testStoreMappingFailedStorage() { try { PatientDiscovery201306Processor storage = new PatientDiscovery201306Processor() { @Override protected AssigningAuthorityHomeCommunityMappingDAO getAssigningAuthorityHomeCommunityMappingDAO() { return new AssigningAuthorityHomeCommunityMappingDAO() { @Override public boolean storeMapping(String hcid, String assigningAuthorityId) { return false; } }; } @Override protected String getHcid(PRPAIN201306UV02 request) { return "hcid"; } @Override protected List<String> extractAAListFrom201306(PRPAIN201306UV02 request) { List<String> assigningAuthorityIds = new ArrayList<>(); assigningAuthorityIds.add("aa"); return assigningAuthorityIds; } }; storage.storeMapping(mockMessage); } catch (Throwable t) { System.out.println("Error running testStoreMappingFailedStorage: " + t.getMessage()); t.printStackTrace(); fail("Error running testStoreMappingFailedStorage: " + t.getMessage()); } }