Skip to content

Commit

Permalink
adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdyrod committed Nov 28, 2024
1 parent a2760b1 commit 367a4e3
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/org/dhis2/bindings/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import java.text.DecimalFormat

fun <T : Any?> MutableLiveData<T>.default(initialValue: T) = this.apply { setValue(initialValue) }

@Deprecated("Use ProfilePictureProvider instead")
fun TrackedEntityInstance.profilePicturePath(d2: D2, programUid: String?): String {
var path: String? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.dhis2.metadata.usecases.FileResourceConfiguration;
import org.dhis2.metadata.usecases.ProgramConfiguration;
import org.dhis2.metadata.usecases.TrackedEntityInstanceConfiguration;
import org.dhis2.tracker.data.ProfilePictureProvider;
import org.dhis2.tracker.relationships.model.RelationshipDirection;
import org.dhis2.tracker.relationships.model.RelationshipModel;
import org.dhis2.tracker.relationships.model.RelationshipOwnerType;
Expand Down Expand Up @@ -121,6 +122,7 @@ public class SearchRepositoryImpl implements SearchRepository {
private HashMap<String, List<String>> trackedEntityTypeAttributesUidsCache = new HashMap();

private final MetadataIconProvider metadataIconProvider;
private final ProfilePictureProvider profilePictureProvider;

SearchRepositoryImpl(String teiType,
@Nullable String initialProgram,
Expand All @@ -134,7 +136,8 @@ public class SearchRepositoryImpl implements SearchRepository {
NetworkUtils networkUtils,
SearchTEIRepository searchTEIRepository,
ThemeManager themeManager,
MetadataIconProvider metadataIconProvider
MetadataIconProvider metadataIconProvider,
ProfilePictureProvider profilePictureProvider
) {
this.teiType = teiType;
this.d2 = d2;
Expand All @@ -155,6 +158,7 @@ public class SearchRepositoryImpl implements SearchRepository {
currentProgram,
resources);
this.metadataIconProvider = metadataIconProvider;
this.profilePictureProvider = profilePictureProvider;
}


Expand Down Expand Up @@ -746,7 +750,7 @@ public SearchTeiModel transform(TrackedEntitySearchItem searchItem, @Nullable Pr
} else {
searchTei.setEnrolledOrgUnit(orgUnitName(searchTei.getTei().organisationUnit()));
}
searchTei.setProfilePicture(profilePicturePath(dbTei, selectedProgram));
searchTei.setProfilePicture(profilePictureProvider.invoke(dbTei, selectedProgram != null ? selectedProgram.uid() : null));
} else {
searchTei.setTei(teiFromItem);
searchTei.setEnrolledOrgUnit(orgUnitName(searchTei.getTei().organisationUnit()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ SearchRepository searchRepository(@NonNull D2 d2,
SearchTEIRepository searchTEIRepository,
ThemeManager themeManager,
MetadataIconProvider metadataIconProvider) {
ProfilePictureProvider profilePictureProvider = new ProfilePictureProvider(d2);
return new SearchRepositoryImpl(teiType,
initialProgram,
d2,
Expand All @@ -167,7 +168,8 @@ SearchRepository searchRepository(@NonNull D2 d2,
networkUtils,
searchTEIRepository,
themeManager,
metadataIconProvider);
metadataIconProvider,
profilePictureProvider);
}

@Provides
Expand Down
Loading

0 comments on commit 367a4e3

Please sign in to comment.