diff --git a/src/main/java/at/rtr/rmbt/constant/Config.java b/src/main/java/at/rtr/rmbt/constant/Config.java index 5b767e5..ebc37c1 100644 --- a/src/main/java/at/rtr/rmbt/constant/Config.java +++ b/src/main/java/at/rtr/rmbt/constant/Config.java @@ -94,5 +94,6 @@ public interface Config { List SIGNAL_RESULT_STATUSES = List.of(TestStatus.SIGNAL_STARTED.toString(), TestStatus.SIGNAL.toString()); List TEST_RESULT_DETAIL_STATUSES = List.of(TestStatus.FINISHED.toString()); List TEST_RESULT_STATUSES = List.of(TestStatus.FINISHED.toString()); + List TEST_RESULT_STATUSES_INCLUDE_ERROR = List.of(TestStatus.FINISHED.toString(), TestStatus.ERROR.toString()); Integer SIGNIFICANT_PLACES = 2; } diff --git a/src/main/java/at/rtr/rmbt/response/TestResultResponse.java b/src/main/java/at/rtr/rmbt/response/TestResultResponse.java index 9efc10c..7bb15a0 100644 --- a/src/main/java/at/rtr/rmbt/response/TestResultResponse.java +++ b/src/main/java/at/rtr/rmbt/response/TestResultResponse.java @@ -61,4 +61,7 @@ public class TestResultResponse { @JsonProperty(value = "qoe_classification") private final List qoeClassificationResponses; + + @JsonProperty(value = "status") + private final String status; } diff --git a/src/main/java/at/rtr/rmbt/service/impl/TestServiceImpl.java b/src/main/java/at/rtr/rmbt/service/impl/TestServiceImpl.java index 87988ef..7f891ee 100644 --- a/src/main/java/at/rtr/rmbt/service/impl/TestServiceImpl.java +++ b/src/main/java/at/rtr/rmbt/service/impl/TestServiceImpl.java @@ -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); @@ -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); diff --git a/src/test/java/at/rtr/rmbt/TestConstants.java b/src/test/java/at/rtr/rmbt/TestConstants.java index 44de494..ab1676e 100644 --- a/src/test/java/at/rtr/rmbt/TestConstants.java +++ b/src/test/java/at/rtr/rmbt/TestConstants.java @@ -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"; @@ -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"; diff --git a/src/test/java/at/rtr/rmbt/service/impl/TestServiceImplTest.java b/src/test/java/at/rtr/rmbt/service/impl/TestServiceImplTest.java index 00115c7..f90edcd 100644 --- a/src/test/java/at/rtr/rmbt/service/impl/TestServiceImplTest.java +++ b/src/test/java/at/rtr/rmbt/service/impl/TestServiceImplTest.java @@ -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); @@ -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()); @@ -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); @@ -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()); @@ -332,7 +334,7 @@ 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); @@ -340,6 +342,7 @@ public void getTestResult_whenDualSimFalseAndBrowser_expectTestResultContainerRe 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); @@ -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); @@ -389,7 +393,7 @@ 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); @@ -397,6 +401,7 @@ public void getTestResult_whenQoeClassificaitonNotNull_expectTestResultContainer 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); @@ -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);