Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-18114/fallback-login
Browse files Browse the repository at this point in the history
  • Loading branch information
Chisomchima authored Oct 25, 2024
2 parents 12f8aed + 2e0a08b commit 1650f66
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ default String getGlobalShellAppName() {
*/

default boolean isEmailConfigured() {
return !getEmailHostName().isBlank() && getEmailUsername().isBlank();
return !getEmailHostName().isBlank() && !getEmailUsername().isBlank();
}

default boolean isHideUnapprovedDataInAnalytics() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ attribute=Attribute
category_option=Category Option
category=\u0ea5\u0ea7\u0e87\u0e99\u0ead\u0e99
category_combo=Category Combination
category_option_combo=Category option combination
category_option_combo=\u0e81\u0eb2\u0e99\u0ea5\u0ea7\u0ea1\u0e95\u0ebb\u0ea7\u0ec0\u0ea5\u0eb7\u0ead\u0e81\u0edd\u0ea7\u0e94\u0edd\u0eb9\u0ec8
category_option_group_set=Category Option Group Set
indicator_type=Indicator Type
data_set=Data Set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1792,11 +1792,11 @@ email_invite_1_3rd_paragraph=\u4f60\u5fc5\u987b\u57283\u6708\u5185\u54cd\u5e94\u

#-- Verify email -------------------------------------------------------------#

email_verify_1_1st_paragraph_before_application_title=This is a message to verify a
email_verify_1_1st_paragraph_after_application_title=, user account email.
email_verify_1_2nd_paragraph=Please click the link below to verify the email address of your account.
email_verify_1_3rd_paragraph=You must respond to this email within one hour. If you take no action, the email address will not be verified.
verify_email_subject=Verify email address
email_verify_1_1st_paragraph_before_application_title=\u8fd9\u662f\u4e00\u6761\u6d88\u606f\u9a8c\u8bc1
email_verify_1_1st_paragraph_after_application_title=, \u7528\u6237\u5e10\u6237\u7535\u5b50\u90ae\u4ef6\u3002
email_verify_1_2nd_paragraph=\u8bf7\u70b9\u51fb\u4e0b\u9762\u7684\u94fe\u63a5\u9a8c\u8bc1\u60a8\u7684\u8d26\u6237\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002
email_verify_1_3rd_paragraph=\u60a8\u5fc5\u987b\u5728\u4e00\u5c0f\u65f6\u5185\u56de\u590d\u6b64\u7535\u5b50\u90ae\u4ef6\u3002\u5982\u679c\u60a8\u6ca1\u6709\u91c7\u53d6\u4efb\u4f55\u884c\u52a8\uff0c\u8be5\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u5c06\u65e0\u6cd5\u901a\u8fc7\u9a8c\u8bc1\u3002
verify_email_subject=\u9a8c\u8bc1\u7535\u5b50\u90ae\u4ef6\u5730\u5740

#-- Cache strategy display strings --------------------------------------------#

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,13 @@ void testIsValid_Date() {
assertFalse(settings.isValid("keyLastMonitoringRun", "hello"));
assertFalse(settings.isValid("keyLastMonitoringRun", "true"));
}

@Test
void testEmailIsConfigured() {
SystemSettings settings = SystemSettings.of(Map.of());
assertFalse(settings.isEmailConfigured());
settings =
SystemSettings.of(Map.of("keyEmailHostName", "localhost", "keyEmailUsername", "user"));
assertTrue(settings.isEmailConfigured());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public class EventOperationParams {
@Builder.Default private Set<UID> events = new HashSet<>();

/** Data element filters per data element UID. */
@Builder.Default private Map<String, List<QueryFilter>> dataElementFilters = new HashMap<>();
@Builder.Default private Map<UID, List<QueryFilter>> dataElementFilters = new HashMap<>();

/** Tracked entity attribute filters per attribute UID. */
@Builder.Default private Map<String, List<QueryFilter>> attributeFilters = new HashMap<>();
@Builder.Default private Map<UID, List<QueryFilter>> attributeFilters = new HashMap<>();

private boolean includeDeleted;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ private void validateAttributeOptionCombo(
}

private void mapDataElementFilters(
EventQueryParams params, Map<String, List<QueryFilter>> dataElementFilters)
EventQueryParams params, Map<UID, List<QueryFilter>> dataElementFilters)
throws BadRequestException {
for (Entry<String, List<QueryFilter>> dataElementFilter : dataElementFilters.entrySet()) {
DataElement de = dataElementService.getDataElement(dataElementFilter.getKey());
for (Entry<UID, List<QueryFilter>> dataElementFilter : dataElementFilters.entrySet()) {
DataElement de = dataElementService.getDataElement(dataElementFilter.getKey().getValue());
if (de == null) {
throw new BadRequestException(
String.format(
Expand All @@ -215,11 +215,12 @@ private void mapDataElementFilters(
}

private void mapAttributeFilters(
EventQueryParams params, Map<String, List<QueryFilter>> attributeFilters)
EventQueryParams params, Map<UID, List<QueryFilter>> attributeFilters)
throws BadRequestException {
for (Map.Entry<String, List<QueryFilter>> attributeFilter : attributeFilters.entrySet()) {
for (Map.Entry<UID, List<QueryFilter>> attributeFilter : attributeFilters.entrySet()) {
TrackedEntityAttribute tea =
trackedEntityAttributeService.getTrackedEntityAttribute(attributeFilter.getKey());
trackedEntityAttributeService.getTrackedEntityAttribute(
attributeFilter.getKey().getValue());
if (tea == null) {
throw new BadRequestException(
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ void shouldMapAttributeFilters() throws BadRequestException, ForbiddenException
eventBuilder
.attributeFilters(
Map.of(
TEA_1_UID,
UID.of(TEA_1_UID),
List.of(new QueryFilter(QueryOperator.EQ, "2")),
TEA_2_UID,
UID.of(TEA_2_UID),
List.of(new QueryFilter(QueryOperator.LIKE, "foo"))))
.build();

Expand All @@ -273,11 +273,12 @@ void shouldMapAttributeFilters() throws BadRequestException, ForbiddenException

@Test
void shouldFailWhenAttributeInGivenAttributeFilterDoesNotExist() {
String filterName = "filter";
UID filterName = UID.of(CodeGenerator.generateUid());
EventOperationParams operationParams =
eventBuilder.attributeFilters(Map.of(filterName, List.of())).build();

when(trackedEntityAttributeService.getTrackedEntityAttribute(filterName)).thenReturn(null);
when(trackedEntityAttributeService.getTrackedEntityAttribute(filterName.getValue()))
.thenReturn(null);

Exception exception =
assertThrows(BadRequestException.class, () -> mapper.map(operationParams, user));
Expand Down Expand Up @@ -364,9 +365,9 @@ void shouldMapDataElementFilters() throws BadRequestException, ForbiddenExceptio
eventBuilder
.dataElementFilters(
Map.of(
DE_1_UID,
UID.of(DE_1_UID),
List.of(new QueryFilter(QueryOperator.EQ, "2")),
DE_2_UID,
UID.of(DE_2_UID),
List.of(new QueryFilter(QueryOperator.LIKE, "foo"))))
.build();

Expand All @@ -385,11 +386,11 @@ void shouldMapDataElementFilters() throws BadRequestException, ForbiddenExceptio

@Test
void shouldFailWhenDataElementInGivenDataElementFilterDoesNotExist() {
String filterName = "filter";
UID filterName = UID.of(CodeGenerator.generateUid());
EventOperationParams operationParams =
eventBuilder.dataElementFilters(Map.of(filterName, List.of())).build();

when(dataElementService.getDataElement(filterName)).thenReturn(null);
when(dataElementService.getDataElement(filterName.getValue())).thenReturn(null);

Exception exception =
assertThrows(BadRequestException.class, () -> mapper.map(operationParams, user));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@ void testExportEventsWithDatesIncludingTimeStamp()
@Test
void testExportEventsWhenFilteringByDataElementsLike()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00001");
DataElement dataElement = dataElement(UID.of("DATAEL00001"));
EventOperationParams params =
operationParamsBuilder
.enrollments(Set.of(UID.of("nxP7UnKhomJ")))
.programStage(UID.of(programStage))
.dataElementFilters(
Map.of("DATAEL00001", List.of(new QueryFilter(QueryOperator.LIKE, "%val%"))))
Map.of(UID.of(dataElement), List.of(new QueryFilter(QueryOperator.LIKE, "%val%"))))
.build();

List<String> events = getEvents(params);
Expand All @@ -368,15 +368,15 @@ void testExportEventsWhenFilteringByDataElementsLike()
@Test
void testExportEventsWhenFilteringByDataElementsWithStatusFilter()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00001");
DataElement dataElement = dataElement(UID.of("DATAEL00001"));

EventOperationParams params =
operationParamsBuilder
.enrollments(Set.of(UID.of("nxP7UnKhomJ")))
.programStage(UID.of(programStage))
.enrollmentStatus(EnrollmentStatus.ACTIVE)
.dataElementFilters(
Map.of(dataElement.getUid(), List.of(new QueryFilter(QueryOperator.LIKE, "%val%"))))
Map.of(UID.of(dataElement), List.of(new QueryFilter(QueryOperator.LIKE, "%val%"))))
.build();

List<String> events = getEvents(params);
Expand All @@ -387,15 +387,15 @@ void testExportEventsWhenFilteringByDataElementsWithStatusFilter()
@Test
void testExportEventsWhenFilteringByDataElementsWithProgramTypeFilter()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00001");
DataElement dataElement = dataElement(UID.of("DATAEL00001"));

EventOperationParams params =
operationParamsBuilder
.enrollments(Set.of(UID.of("nxP7UnKhomJ")))
.programStage(UID.of(programStage))
.programType(ProgramType.WITH_REGISTRATION)
.dataElementFilters(
Map.of(dataElement.getUid(), List.of(new QueryFilter(QueryOperator.LIKE, "%val%"))))
Map.of(UID.of(dataElement), List.of(new QueryFilter(QueryOperator.LIKE, "%val%"))))
.build();

List<String> events = getEvents(params);
Expand All @@ -406,15 +406,15 @@ void testExportEventsWhenFilteringByDataElementsWithProgramTypeFilter()
@Test
void testExportEventsWhenFilteringByDataElementsEqual()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00001");
DataElement dataElement = dataElement(UID.of("DATAEL00001"));

EventOperationParams params =
operationParamsBuilder
.enrollments(Set.of(UID.of("nxP7UnKhomJ")))
.programStage(UID.of(programStage))
.dataElementFilters(
Map.of(
dataElement.getUid(),
UID.of(dataElement),
List.of(new QueryFilter(QueryOperator.LIKE, "%value00001%"))))
.build();

Expand All @@ -426,15 +426,15 @@ void testExportEventsWhenFilteringByDataElementsEqual()
@Test
void testExportEventsWhenFilteringByDataElementsIn()
throws ForbiddenException, BadRequestException {
DataElement datael00001 = dataElement("DATAEL00001");
DataElement dataElement = dataElement(UID.of("DATAEL00001"));

EventOperationParams params =
operationParamsBuilder
.enrollments(UID.of("nxP7UnKhomJ", "TvctPPhpD8z"))
.programStage(UID.of(programStage))
.dataElementFilters(
Map.of(
datael00001.getUid(),
UID.of(dataElement),
List.of(new QueryFilter(QueryOperator.IN, "value00001;value00002"))))
.build();

Expand All @@ -446,7 +446,7 @@ void testExportEventsWhenFilteringByDataElementsIn()
@Test
void testExportEventsWhenFilteringByDataElementsWithCategoryOptionSuperUser()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00001");
DataElement dataElement = dataElement(UID.of("DATAEL00001"));

EventOperationParams params =
operationParamsBuilder
Expand All @@ -457,7 +457,7 @@ void testExportEventsWhenFilteringByDataElementsWithCategoryOptionSuperUser()
.attributeCategoryOptions(Set.of(UID.of("xYerKDKCefk")))
.dataElementFilters(
Map.of(
dataElement.getUid(), List.of(new QueryFilter(QueryOperator.EQ, "value00001"))))
UID.of(dataElement), List.of(new QueryFilter(QueryOperator.EQ, "value00001"))))
.build();

List<String> events = getEvents(params);
Expand Down Expand Up @@ -630,7 +630,7 @@ void testExportEventsWhenFilteringByDataElementsWithCategoryOptionNotSuperUser()
throws ForbiddenException, BadRequestException {
injectSecurityContextUser(
createAndAddUser(false, "user", Set.of(orgUnit), Set.of(orgUnit), "F_EXPORT_DATA"));
DataElement dataElement = dataElement("DATAEL00002");
DataElement dataElement = dataElement(UID.of("DATAEL00002"));

EventOperationParams params =
operationParamsBuilder
Expand All @@ -641,7 +641,7 @@ void testExportEventsWhenFilteringByDataElementsWithCategoryOptionNotSuperUser()
.attributeCategoryOptions(Set.of(UID.of("xYerKDKCefk")))
.dataElementFilters(
Map.of(
dataElement.getUid(), List.of(new QueryFilter(QueryOperator.EQ, "value00002"))))
UID.of(dataElement), List.of(new QueryFilter(QueryOperator.EQ, "value00002"))))
.build();

List<String> events = getEvents(params);
Expand All @@ -652,13 +652,13 @@ void testExportEventsWhenFilteringByDataElementsWithCategoryOptionNotSuperUser()
@Test
void testExportEventsWhenFilteringByDataElementsWithOptionSetEqual()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00005");
DataElement dataElement = dataElement(UID.of("DATAEL00005"));
EventOperationParams params =
operationParamsBuilder
.enrollments(Set.of(UID.of("nxP7UnKhomJ")))
.programStage(UID.of(programStage))
.dataElementFilters(
Map.of(dataElement.getUid(), List.of(new QueryFilter(QueryOperator.EQ, "option1"))))
Map.of(UID.of(dataElement), List.of(new QueryFilter(QueryOperator.EQ, "option1"))))
.build();

List<String> events = getEvents(params);
Expand All @@ -669,14 +669,14 @@ void testExportEventsWhenFilteringByDataElementsWithOptionSetEqual()
@Test
void testExportEventsWhenFilteringByDataElementsWithOptionSetIn()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00005");
DataElement dataElement = dataElement(UID.of("DATAEL00005"));
EventOperationParams params =
operationParamsBuilder
.enrollments(UID.of("nxP7UnKhomJ", "TvctPPhpD8z"))
.programStage(UID.of(programStage))
.dataElementFilters(
Map.of(
dataElement.getUid(),
UID.of(dataElement),
List.of(new QueryFilter(QueryOperator.IN, "option1;option2"))))
.build();

Expand All @@ -688,13 +688,13 @@ void testExportEventsWhenFilteringByDataElementsWithOptionSetIn()
@Test
void testExportEventsWhenFilteringByDataElementsWithOptionSetLike()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00005");
DataElement dataElement = dataElement(UID.of("DATAEL00005"));
EventOperationParams params =
operationParamsBuilder
.enrollments(Set.of(UID.of("nxP7UnKhomJ")))
.programStage(UID.of(programStage))
.dataElementFilters(
Map.of(dataElement.getUid(), List.of(new QueryFilter(QueryOperator.LIKE, "%opt%"))))
Map.of(UID.of(dataElement), List.of(new QueryFilter(QueryOperator.LIKE, "%opt%"))))
.build();

List<String> events = getEvents(params);
Expand All @@ -705,14 +705,14 @@ void testExportEventsWhenFilteringByDataElementsWithOptionSetLike()
@Test
void testExportEventsWhenFilteringByNumericDataElements()
throws ForbiddenException, BadRequestException {
DataElement dataElement = dataElement("DATAEL00006");
DataElement dataElement = dataElement(UID.of("DATAEL00006"));
EventOperationParams params =
operationParamsBuilder
.enrollments(UID.of("nxP7UnKhomJ", "TvctPPhpD8z"))
.programStage(UID.of(programStage))
.dataElementFilters(
Map.of(
dataElement.getUid(),
UID.of(dataElement),
List.of(
new QueryFilter(QueryOperator.LT, "77"),
new QueryFilter(QueryOperator.GT, "8"))))
Expand Down Expand Up @@ -906,7 +906,7 @@ void testEnrollmentOccurredAfterEqualToLastOccurredAtDate()
EventOperationParams params =
operationParamsBuilder
.orgUnit(UID.of(orgUnit))
.attributeFilters(Map.of("notUpdated0", List.of()))
.attributeFilters(Map.of(UID.of("notUpdated0"), List.of()))
.build();

List<String> trackedEntities =
Expand All @@ -924,7 +924,7 @@ void testEnrollmentFilterNumericAttributes() throws ForbiddenException, BadReque
.orgUnit(UID.of(orgUnit))
.attributeFilters(
Map.of(
"numericAttr",
UID.of("numericAttr"),
List.of(
new QueryFilter(QueryOperator.LT, "77"),
new QueryFilter(QueryOperator.GT, "8"))))
Expand All @@ -944,7 +944,9 @@ void testEnrollmentFilterAttributes() throws ForbiddenException, BadRequestExcep
operationParamsBuilder
.orgUnit(UID.of(orgUnit))
.attributeFilters(
Map.of("toUpdate000", List.of(new QueryFilter(QueryOperator.EQ, "summer day"))))
Map.of(
UID.of("toUpdate000"),
List.of(new QueryFilter(QueryOperator.EQ, "summer day"))))
.build();

List<String> trackedEntities =
Expand All @@ -963,9 +965,9 @@ void testEnrollmentFilterAttributesWithMultipleFiltersOnDifferentAttributes()
.orgUnit(UID.of(orgUnit))
.attributeFilters(
Map.of(
"toUpdate000",
UID.of("toUpdate000"),
List.of(new QueryFilter(QueryOperator.EQ, "rainy day")),
"notUpdated0",
UID.of("notUpdated0"),
List.of(new QueryFilter(QueryOperator.EQ, "winter day"))))
.build();

Expand All @@ -985,7 +987,7 @@ void testEnrollmentFilterAttributesWithMultipleFiltersOnTheSameAttribute()
.orgUnit(UID.of(orgUnit))
.attributeFilters(
Map.of(
"toUpdate000",
UID.of("toUpdate000"),
List.of(
new QueryFilter(QueryOperator.LIKE, "day"),
new QueryFilter(QueryOperator.LIKE, "in"))))
Expand Down Expand Up @@ -1064,8 +1066,8 @@ private void assertNote(User expectedLastUpdatedBy, String expectedNote, Note ac
assertEquals(expectedLastUpdatedBy, actual.getLastUpdatedBy());
}

private DataElement dataElement(String uid) {
return dataElementService.getDataElement(uid);
private DataElement dataElement(UID uid) {
return dataElementService.getDataElement(uid.getValue());
}

private <T extends IdentifiableObject> T get(Class<T> type, String uid) {
Expand Down
Loading

0 comments on commit 1650f66

Please sign in to comment.