Skip to content

Commit

Permalink
Reduce visibility of some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lincmba committed Sep 20, 2024
1 parent e04fcff commit 138a2d4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.smartregister.model.practitioner.PractitionerDetails;
import org.springframework.lang.Nullable;

import com.google.common.annotations.VisibleForTesting;

import ca.uhn.fhir.rest.api.SearchStyleEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.gclient.ReferenceClientParam;
Expand Down Expand Up @@ -88,7 +90,8 @@ public Bundle getSupervisorPractitionerDetailsByKeycloakId(String keycloakUuid)
return bundle;
}

public Bundle getAttributedPractitionerDetailsByPractitioner(Practitioner practitioner) {
@VisibleForTesting
protected Bundle getAttributedPractitionerDetailsByPractitioner(Practitioner practitioner) {
Bundle responseBundle = new Bundle();
List<Practitioner> attributedPractitioners = new ArrayList<>();
PractitionerDetails practitionerDetails =
Expand Down Expand Up @@ -189,7 +192,8 @@ public static Set<String> getAttributedLocations(List<LocationHierarchy> locatio
.collect(Collectors.toSet());
}

public List<String> getOrganizationIdsByLocationIds(Set<String> attributedLocationsList) {
@VisibleForTesting
protected List<String> getOrganizationIdsByLocationIds(Set<String> attributedLocationsList) {
if (attributedLocationsList == null || attributedLocationsList.isEmpty()) {
return new ArrayList<>();
}
Expand Down Expand Up @@ -376,7 +380,8 @@ private Set<String> getOrganizationIdsByPractitionerRoles(
.collect(Collectors.toSet());
}

public Practitioner getPractitionerByIdentifier(String identifier) {
@VisibleForTesting
protected Practitioner getPractitionerByIdentifier(String identifier) {
Bundle resultBundle =
getFhirClientForR4()
.search()
Expand All @@ -391,7 +396,8 @@ public Practitioner getPractitionerByIdentifier(String identifier) {
: null;
}

public List<CareTeam> getCareTeamsByOrganizationIds(List<String> organizationIds) {
@VisibleForTesting
protected List<CareTeam> getCareTeamsByOrganizationIds(List<String> organizationIds) {
if (organizationIds.isEmpty()) return new ArrayList<>();

Bundle bundle =
Expand Down Expand Up @@ -450,7 +456,8 @@ private static String getReferenceIDPart(String reference) {
reference.lastIndexOf(org.smartregister.utils.Constants.FORWARD_SLASH) + 1);
}

public Bundle getOrganizationsById(Set<String> organizationIds) {
@VisibleForTesting
protected Bundle getOrganizationsById(Set<String> organizationIds) {
return organizationIds.isEmpty()
? EMPTY_BUNDLE
: getFhirClientForR4()
Expand All @@ -464,7 +471,8 @@ public Bundle getOrganizationsById(Set<String> organizationIds) {
.execute();
}

public @Nullable List<Location> getLocationsByIds(List<String> locationIds) {
@VisibleForTesting
protected @Nullable List<Location> getLocationsByIds(List<String> locationIds) {
if (locationIds == null || locationIds.isEmpty()) {
return new ArrayList<>();
}
Expand All @@ -485,7 +493,8 @@ public Bundle getOrganizationsById(Set<String> organizationIds) {
.collect(Collectors.toList());
}

public List<OrganizationAffiliation> getOrganizationAffiliationsByOrganizationIds(
@VisibleForTesting
protected List<OrganizationAffiliation> getOrganizationAffiliationsByOrganizationIds(
Set<String> organizationIds) {
if (organizationIds == null || organizationIds.isEmpty()) {
return new ArrayList<>();
Expand All @@ -495,7 +504,9 @@ public List<OrganizationAffiliation> getOrganizationAffiliationsByOrganizationId
return mapBundleToOrganizationAffiliation(organizationAffiliationsBundle);
}

public Bundle getOrganizationAffiliationsByOrganizationIdsBundle(Set<String> organizationIds) {
@VisibleForTesting
protected Bundle getOrganizationAffiliationsByOrganizationIdsBundle(
Set<String> organizationIds) {
return organizationIds.isEmpty()
? EMPTY_BUNDLE
: getFhirClientForR4()
Expand All @@ -509,7 +520,8 @@ public Bundle getOrganizationAffiliationsByOrganizationIdsBundle(Set<String> org
.execute();
}

public List<String> getLocationIdsByOrganizationAffiliations(
@VisibleForTesting
protected List<String> getLocationIdsByOrganizationAffiliations(
List<OrganizationAffiliation> organizationAffiliations) {

return organizationAffiliations.stream()
Expand All @@ -523,7 +535,8 @@ public List<String> getLocationIdsByOrganizationAffiliations(
.collect(Collectors.toList());
}

public Set<String> getManagingOrganizationsOfCareTeamIds(List<CareTeam> careTeamsList) {
@VisibleForTesting
protected Set<String> getManagingOrganizationsOfCareTeamIds(List<CareTeam> careTeamsList) {
return careTeamsList.stream()
.filter(CareTeam::hasManagingOrganization)
.flatMap(it -> it.getManagingOrganization().stream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.slf4j.LoggerFactory;
import org.smartregister.fhir.gateway.plugins.interfaces.ResourceFinder;

import com.google.common.annotations.VisibleForTesting;
import com.google.fhir.gateway.ExceptionUtil;
import com.google.fhir.gateway.interfaces.RequestDetailsReader;

Expand All @@ -30,7 +31,8 @@ private ResourceFinderImp(FhirContext fhirContext) {
this.fhirContext = fhirContext;
}

public IBaseResource createResourceFromRequest(RequestDetailsReader request) {
@VisibleForTesting
protected IBaseResource createResourceFromRequest(RequestDetailsReader request) {
byte[] requestContentBytes = request.loadRequestContents();
Charset charset = request.getCharset();
if (charset == null) {
Expand Down

0 comments on commit 138a2d4

Please sign in to comment.