HomeCommunityMap { public static String getCommunityIdFromAssertion(AssertionType assertion) { String communityId = null; if (assertion != null && assertion.getUserInfo() != null) { UserType userInfo = assertion.getUserInfo(); if (userInfo != null && userInfo.getOrg() != null) { if (StringUtils.isNotEmpty(userInfo.getOrg().getHomeCommunityId())) { communityId = userInfo.getOrg().getHomeCommunityId(); } } } if (communityId == null) { communityId = getHomeCommunityIdFromAssertion(assertion); } return formatHomeCommunityId(communityId); }  static String getSNIName(String exchangeName); static String getHomeCommunityName(String sHomeCommunityId); static String getCommunityIdFromTargetCommunities(NhinTargetCommunitiesType target); static String getCommunityIdFromTargetSystem(NhinTargetSystemType target); static String getCommunityIdFromAssertion(AssertionType assertion); static String getHomeCommunityIdFromAssertion(AssertionType assertion); static String getCommunityId(AdhocQueryType body); static String getCommunityIdForDeferredQDResponse(AdhocQueryResponse body); static String getCommunityIdForRDRequest(RetrieveDocumentSetRequestType body); static String getCommunityIdForDeferredRDResponse(RetrieveDocumentSetResponseType body); static String formatHomeCommunityId(String communityId); static String getLocalHomeCommunityId(); static String getHomeCommunityIdWithPrefix(String communityId); static String getHomeCommunityWithoutPrefix(String hcid); static String appendPrefixHomeCommunityID(final String homeCommunityId); static boolean equalsIgnoreCaseForHCID(final String communityId, final String hcidValue); static String checkPrefixBeforeAppend(final String checkValue, final String checkPrefix);  }
@Test(expected = NullPointerException.class) public void testGetCommunityIdFromAssertion() { String communityId; AssertionType assertion = new AssertionType(); assertion.getUserInfo().getOrg().setHomeCommunityId("1.1"); communityId = HomeCommunityMap.getCommunityIdFromAssertion(assertion); assertEquals("1.1", communityId); HomeCommunityType home = new HomeCommunityType(); home.setHomeCommunityId("1.1"); assertion.setHomeCommunity(home); assertion.setUserInfo(null); communityId = HomeCommunityMap.getCommunityIdFromAssertion(assertion); assertEquals("1.1", communityId); UserType info = new UserType(); HomeCommunityType org1 = new HomeCommunityType(); org1.setHomeCommunityId(""); info.setOrg(org1); assertion.setUserInfo(info); HomeCommunityType homecommunity = new HomeCommunityType(); homecommunity.setHomeCommunityId("1.1"); communityId = HomeCommunityMap.getCommunityIdFromAssertion(assertion); assertEquals("1.1", communityId); }