Skip to content

Commit

Permalink
output failed tests in /testresult
Browse files Browse the repository at this point in the history
  • Loading branch information
cproof committed Jul 22, 2024
1 parent 36ba63a commit c5d6c4f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/at/rtr/rmbt/constant/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ public interface Config {
List<String> SIGNAL_RESULT_STATUSES = List.of(TestStatus.SIGNAL_STARTED.toString(), TestStatus.SIGNAL.toString());
List<String> TEST_RESULT_DETAIL_STATUSES = List.of(TestStatus.FINISHED.toString());
List<String> TEST_RESULT_STATUSES = List.of(TestStatus.FINISHED.toString());
List<String> TEST_RESULT_STATUSES_INCLUDE_ERROR = List.of(TestStatus.FINISHED.toString(), TestStatus.ERROR.toString());
Integer SIGNIFICANT_PLACES = 2;
}
3 changes: 3 additions & 0 deletions src/main/java/at/rtr/rmbt/response/TestResultResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ public class TestResultResponse {

@JsonProperty(value = "qoe_classification")
private final List<QoeClassificationResponse> qoeClassificationResponses;

@JsonProperty(value = "status")
private final String status;
}
3 changes: 2 additions & 1 deletion src/main/java/at/rtr/rmbt/service/impl/TestServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public TestResultDetailResponse getTestResultDetailByTestUUID(TestResultDetailRe

@Override
public TestResultContainerResponse getTestResult(TestResultRequest testResultRequest) {
Test test = testRepository.findByUuidAndStatusesIn(testResultRequest.getTestUUID(), Config.TEST_RESULT_STATUSES)
Test test = testRepository.findByUuidAndStatusesIn(testResultRequest.getTestUUID(), Config.TEST_RESULT_STATUSES_INCLUDE_ERROR)
.orElseThrow(() -> new TestNotFoundException(String.format(ErrorMessage.TEST_NOT_FOUND, testResultRequest.getTestUUID())));
Locale locale = MessageUtils.getLocaleFormLanguage(testResultRequest.getLanguage(), applicationProperties.getLanguage());
String timeString = TimeUtils.getTimeStringFromTest(test, locale);
Expand All @@ -142,6 +142,7 @@ public TestResultContainerResponse getTestResult(TestResultRequest testResultReq
.shareSubject(MessageFormat.format(getStringFromBundle("RESULT_SHARE_SUBJECT", locale), timeString))
.shareText(getShareText(test, timeString, locale))
.timeString(timeString)
.status(test.getStatus().name().toLowerCase())
.qoeClassificationResponses(getQoeClassificationResponse(test));
setGeoLocationFields(testResultResponseBuilder, test, locale);
setNetFields(testResultResponseBuilder, test, locale);
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/at/rtr/rmbt/TestConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public interface TestConstants {
Integer DEFAULT_TELEPHONY_SIM_COUNT = 2;
ClientStatus DEFAULT_LAST_CLIENT_STATUS = ClientStatus.SPEEDTEST_END;
QosStatus DEFAULT_LAST_QOS_STATUS = QosStatus.QOS_END;
TestStatus DEFAULT_STATUS_FINISHED = TestStatus.FINISHED;
Integer DEFAULT_TEST_SUBMISSION_RETRY_COUNT = 22;
String DEFAULT_TEST_RESULT_DETAIL_SIGNAL_STRENGTH_VALUE = DEFAULT_SIGNAL_STRENGTH_FIRST + " dBm";
String DEFAULT_TEST_RESULT_DETAIL_SIGNAL_RSRP_VALUE = DEFAULT_LTE_RSRP_FIRST + " dBm";
Expand Down Expand Up @@ -409,8 +410,8 @@ public interface TestConstants {
String DEFAULT_FORMATTED_PING = "58";
String DEFAULT_FORMATTED_PING_SHORTEST = "58";
String DEFAULT_HISTORY_RESPONSE_ITEM_LOOP_UUID = "L2458713e-9362-11eb-a8b3-0242ac130003";
String DEFAULT_TEST_HISTORY_FINAL_QUERY = "SELECT DISTINCT t.uuid, t.open_test_uuid, time, timezone, speed_upload, speed_download, ping_median, lte_rsrp, signal_strength, dual_sim, sim_count, network_type, nt.group_name network_type_group_name, l.loop_uuid loop_uuid, COALESCE(adm.fullname, t.model) model FROM test t LEFT JOIN device_map adm ON adm.codename=t.model LEFT JOIN network_type nt ON t.network_type=nt.uid LEFT JOIN test_loopmode l ON (l.test_uuid = t.uuid) WHERE t.deleted = false AND t.implausible = false AND t.status IN (?) AND client_id = ? AND (COALESCE(adm.fullname, t.model) IN (?)) AND nt.group_name IN (?) ORDER BY time DESC LIMIT 1 OFFSET 2";
String DEFAULT_TEST_HISTORY_FINAL_QUERY_CLIENT_SYNCED = "SELECT DISTINCT t.uuid, t.open_test_uuid, time, timezone, speed_upload, speed_download, ping_median, lte_rsrp, signal_strength, dual_sim, sim_count, network_type, nt.group_name network_type_group_name, l.loop_uuid loop_uuid, COALESCE(adm.fullname, t.model) model FROM test t LEFT JOIN device_map adm ON adm.codename=t.model LEFT JOIN network_type nt ON t.network_type=nt.uid LEFT JOIN test_loopmode l ON (l.test_uuid = t.uuid) WHERE t.deleted = false AND t.implausible = false AND t.status IN (?) AND (t.client_id IN (SELECT ? UNION SELECT uid FROM client WHERE sync_group_id = ? )) AND (COALESCE(adm.fullname, t.model) IN (?)) AND nt.group_name IN (?) ORDER BY time DESC LIMIT 1 OFFSET 2";
String DEFAULT_TEST_HISTORY_FINAL_QUERY = "SELECT DISTINCT t.status, t.uuid, t.open_test_uuid, time, timezone, speed_upload, speed_download, ping_median, lte_rsrp, signal_strength, dual_sim, sim_count, network_type, nt.group_name network_type_group_name, l.loop_uuid loop_uuid, COALESCE(adm.fullname, t.model) model FROM test t LEFT JOIN device_map adm ON adm.codename=t.model LEFT JOIN network_type nt ON t.network_type=nt.uid LEFT JOIN test_loopmode l ON (l.test_uuid = t.uuid) WHERE t.deleted = false AND t.implausible = false AND t.status IN (?) AND client_id = ? AND (COALESCE(adm.fullname, t.model) IN (?)) AND nt.group_name IN (?) ORDER BY time DESC LIMIT 1 OFFSET 2";
String DEFAULT_TEST_HISTORY_FINAL_QUERY_CLIENT_SYNCED = "SELECT DISTINCT t.status, t.uuid, t.open_test_uuid, time, timezone, speed_upload, speed_download, ping_median, lte_rsrp, signal_strength, dual_sim, sim_count, network_type, nt.group_name network_type_group_name, l.loop_uuid loop_uuid, COALESCE(adm.fullname, t.model) model FROM test t LEFT JOIN device_map adm ON adm.codename=t.model LEFT JOIN network_type nt ON t.network_type=nt.uid LEFT JOIN test_loopmode l ON (l.test_uuid = t.uuid) WHERE t.deleted = false AND t.implausible = false AND t.status IN (?) AND (t.client_id IN (SELECT ? UNION SELECT uid FROM client WHERE sync_group_id = ? )) AND (COALESCE(adm.fullname, t.model) IN (?)) AND nt.group_name IN (?) ORDER BY time DESC LIMIT 1 OFFSET 2";
Integer DEFAULT_CLIENT_SYNC_GROUP_ID = 5;
MeasurementType DEFAULT_MEASUREMENT_TYPE_FLAG = MeasurementType.REGULAR;
String DEFAULT_SYNC_CODE = "DEFAULT_SYNC_CODE";
Expand Down
18 changes: 12 additions & 6 deletions src/test/java/at/rtr/rmbt/service/impl/TestServiceImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void getTestResult_whenSignalStrengthNotNullAndUseSignalTrueAndDualSimTru
when(testResultRequest.getCapabilitiesRequest()).thenReturn(capabilitiesRequest);
when(capabilitiesRequest.getClassification()).thenReturn(classificationRequest);
when(classificationRequest.getCount()).thenReturn(TestConstants.DEFAULT_CLASSIFICATION_COUNT);
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES)).thenReturn(Optional.of(test));
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES_INCLUDE_ERROR)).thenReturn(Optional.of(test));
when(test.getDualSim()).thenReturn(Boolean.TRUE);
when(test.getTime()).thenReturn(TestConstants.DEFAULT_ZONED_DATE_TIME);
when(test.getTimezone()).thenReturn(TestConstants.DEFAULT_TIMEZONE);
Expand All @@ -283,6 +283,7 @@ public void getTestResult_whenSignalStrengthNotNullAndUseSignalTrueAndDualSimTru
when(test.getPingMedian()).thenReturn(TestConstants.DEFAULT_TEST_PING_MEDIAN);
when(test.getSignalStrength()).thenReturn(TestConstants.DEFAULT_SIGNAL_STRENGTH_FIRST);
when(test.getLteRsrp()).thenReturn(null);
when(test.getStatus()).thenReturn(TestConstants.DEFAULT_STATUS_FINISHED);

var result = testService.getTestResult(testResultRequest);
assertEquals(1, result.getTestResultResponses().size());
Expand All @@ -301,7 +302,7 @@ public void getTestResult_whenLteRSRPNotNullAndUseSignalTrueAndDualSimFalse_expe
when(testResultRequest.getCapabilitiesRequest()).thenReturn(capabilitiesRequest);
when(capabilitiesRequest.getClassification()).thenReturn(classificationRequest);
when(classificationRequest.getCount()).thenReturn(TestConstants.DEFAULT_CLASSIFICATION_COUNT);
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES)).thenReturn(Optional.of(test));
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES_INCLUDE_ERROR)).thenReturn(Optional.of(test));
when(test.getDualSim()).thenReturn(Boolean.FALSE);
when(test.getTime()).thenReturn(TestConstants.DEFAULT_ZONED_DATE_TIME);
when(test.getTimezone()).thenReturn(TestConstants.DEFAULT_TIMEZONE);
Expand All @@ -314,6 +315,7 @@ public void getTestResult_whenLteRSRPNotNullAndUseSignalTrueAndDualSimFalse_expe
when(test.getLteRsrp()).thenReturn(TestConstants.DEFAULT_LTE_RSRP_FIRST);
when(test.getNetworkOperatorName()).thenReturn(TestConstants.DEFAULT_TELEPHONY_NETWORK_OPERATOR_NAME);
when(test.getRoamingType()).thenReturn(TestConstants.DEFAULT_ROAMING_TYPE_ID);
when(test.getStatus()).thenReturn(TestConstants.DEFAULT_STATUS_FINISHED);

var result = testService.getTestResult(testResultRequest);
assertEquals(1, result.getTestResultResponses().size());
Expand All @@ -332,14 +334,15 @@ public void getTestResult_whenDualSimFalseAndBrowser_expectTestResultContainerRe
when(testResultRequest.getCapabilitiesRequest()).thenReturn(capabilitiesRequest);
when(capabilitiesRequest.getClassification()).thenReturn(classificationRequest);
when(classificationRequest.getCount()).thenReturn(TestConstants.DEFAULT_CLASSIFICATION_COUNT);
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES)).thenReturn(Optional.of(test));
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES_INCLUDE_ERROR)).thenReturn(Optional.of(test));
when(test.getTime()).thenReturn(TestConstants.DEFAULT_ZONED_DATE_TIME);
when(test.getTimezone()).thenReturn(TestConstants.DEFAULT_TIMEZONE);
when(test.getDualSim()).thenReturn(Boolean.TRUE);
when(test.getNetworkType()).thenReturn(TestConstants.DEFAULT_NETWORK_TYPE_WLAN_ID);
when(test.getSimCount()).thenReturn(null);
when(test.getWifiSsid()).thenReturn(TestConstants.DEFAULT_WIFI_SSID);
when(test.getProvider()).thenReturn(getProvider());
when(test.getStatus()).thenReturn(TestConstants.DEFAULT_STATUS_FINISHED);

var result = testService.getTestResult(testResultRequest);

Expand All @@ -363,12 +366,13 @@ public void getTestResult_whenDualSimFalseAndNotBrowserAndNotWLAN_expectTestResu
when(testResultRequest.getCapabilitiesRequest()).thenReturn(capabilitiesRequest);
when(capabilitiesRequest.getClassification()).thenReturn(classificationRequest);
when(classificationRequest.getCount()).thenReturn(TestConstants.DEFAULT_CLASSIFICATION_COUNT);
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES)).thenReturn(Optional.of(test));
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES_INCLUDE_ERROR)).thenReturn(Optional.of(test));
when(test.getTime()).thenReturn(TestConstants.DEFAULT_ZONED_DATE_TIME);
when(test.getTimezone()).thenReturn(TestConstants.DEFAULT_TIMEZONE);
when(test.getDualSim()).thenReturn(Boolean.FALSE);
when(test.getNetworkOperatorName()).thenReturn(TestConstants.DEFAULT_TELEPHONY_NETWORK_OPERATOR_NAME);
when(test.getRoamingType()).thenReturn(TestConstants.DEFAULT_ROAMING_TYPE_ID);
when(test.getStatus()).thenReturn(TestConstants.DEFAULT_STATUS_FINISHED);

var result = testService.getTestResult(testResultRequest);

Expand All @@ -389,14 +393,15 @@ public void getTestResult_whenQoeClassificaitonNotNull_expectTestResultContainer
when(testResultRequest.getCapabilitiesRequest()).thenReturn(capabilitiesRequest);
when(capabilitiesRequest.getClassification()).thenReturn(classificationRequest);
when(classificationRequest.getCount()).thenReturn(TestConstants.DEFAULT_CLASSIFICATION_COUNT);
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES)).thenReturn(Optional.of(test));
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES_INCLUDE_ERROR)).thenReturn(Optional.of(test));
when(test.getTime()).thenReturn(TestConstants.DEFAULT_ZONED_DATE_TIME);
when(test.getTimezone()).thenReturn(TestConstants.DEFAULT_TIMEZONE);
when(test.getPingMedian()).thenReturn(TestConstants.DEFAULT_TEST_PING_MEDIAN);
when(test.getDownloadSpeed()).thenReturn(TestConstants.DEFAULT_RESULT_DOWNLOAD_SPEED);
when(test.getUploadSpeed()).thenReturn(TestConstants.DEFAULT_RESULT_UPLOAD_SPEED);
when(qoeClassificationService.getQoeClassificationThreshold()).thenReturn(List.of(qoeClassificationThresholds));
when(qoeClassificationThresholds.getQoeCategory()).thenReturn(TestConstants.DEFAULT_QOE_CATEGORY);
when(test.getStatus()).thenReturn(TestConstants.DEFAULT_STATUS_FINISHED);

var result = testService.getTestResult(testResultRequest);

Expand All @@ -416,8 +421,9 @@ public void getTestResult_whenDEFAULT_expectTestResultContainerResponse() {
when(testResultRequest.getCapabilitiesRequest()).thenReturn(capabilitiesRequest);
when(capabilitiesRequest.getClassification()).thenReturn(classificationRequest);
when(classificationRequest.getCount()).thenReturn(TestConstants.DEFAULT_CLASSIFICATION_COUNT);
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES)).thenReturn(Optional.of(test));
when(testRepository.findByUuidAndStatusesIn(TestConstants.DEFAULT_TEST_UUID, Config.TEST_RESULT_STATUSES_INCLUDE_ERROR)).thenReturn(Optional.of(test));
when(test.getTime()).thenReturn(TestConstants.DEFAULT_ZONED_DATE_TIME);
when(test.getStatus()).thenReturn(TestConstants.DEFAULT_STATUS_FINISHED);
when(test.getTimezone()).thenReturn(TestConstants.DEFAULT_TIMEZONE);

var result = testService.getTestResult(testResultRequest);
Expand Down

0 comments on commit c5d6c4f

Please sign in to comment.