Commit 348c7508 authored by Jujube Orange's avatar Jujube Orange
Browse files

refactor(clea-ws): explicit test method names

parent 2d39e1dc
......@@ -61,7 +61,7 @@ class CleaControllerTest {
}
@Test
void testInfectedUserCanReportHimselfAsInfected() {
void infected_user_can_report_himself_as_infected() {
List<Visit> visits = List.of(new Visit("qrCode", 0L));
HttpEntity<ReportRequest> request = new HttpEntity<>(new ReportRequest(visits, 0L), newJsonHeader());
ResponseEntity<String> response = restTemplate
......@@ -71,7 +71,7 @@ class CleaControllerTest {
}
@Test
void testWhenReportRequestWithInvalidMediaTypeThenGetUnsupportedMediaType() {
void invalid_content_type_body_causes_415_unsupported_media_type() {
ResponseEntity<String> response = restTemplate
.postForEntity("/api/clea/v1/wreport", "foo", String.class);
......@@ -80,7 +80,7 @@ class CleaControllerTest {
}
@Test
void testWhenReportRequestWithNullVisitListThenGetBadRequest() {
void a_report_with_a_null_visits_list_causes_400_bad_request() {
HttpEntity<ReportRequest> request = new HttpEntity<>(new ReportRequest(null, 0L), newJsonHeader());
ResponseEntity<String> response = restTemplate
.postForEntity("/api/clea/v1/wreport", request, String.class);
......@@ -90,7 +90,7 @@ class CleaControllerTest {
}
@Test
void testWhenReportRequestWithInvalidJsonDataThenGetBadRequest() throws JSONException {
void a_report_with_malformed_body_causes_400_bad_request() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", 1);
ResponseEntity<String> response = restTemplate.postForEntity(
......@@ -105,7 +105,7 @@ class CleaControllerTest {
@Test
@DisplayName("when pivotDate is null, reject everything")
void nullPivotDate() throws JsonProcessingException {
void a_null_pivot_date_causes_400_bad_request() throws JsonProcessingException {
List<Visit> visits = List.of(new Visit(RandomStringUtils.randomAlphanumeric(20), RandomUtils.nextLong()));
HttpEntity<ReportRequest> request = new HttpEntity<>(new ReportRequest(visits, null), newJsonHeader());
ResponseEntity<String> response = restTemplate
......@@ -127,7 +127,7 @@ class CleaControllerTest {
@Test
@DisplayName("when pivotDate is not numeric, reject everything")
void notNumericPivotDate() throws JsonProcessingException {
void invalid_pivot_date_format_causes_400_bad_request() throws JsonProcessingException {
ReportRequest reportRequest = new ReportRequest(
List.of(new Visit(RandomStringUtils.randomAlphanumeric(20), 1L)), 0L
);
......@@ -147,7 +147,7 @@ class CleaControllerTest {
@Test
@DisplayName("when visit list is null, reject everything")
void nullVisitList() throws JsonProcessingException {
void a_report_with_a_null_visits_list_causes_400_bad_request_2() throws JsonProcessingException {
HttpEntity<ReportRequest> request = new HttpEntity<>(new ReportRequest(null, 0L), newJsonHeader());
ResponseEntity<String> response = restTemplate
.postForEntity("/api/clea/v1/wreport", request, String.class);
......@@ -162,7 +162,7 @@ class CleaControllerTest {
@Test
@DisplayName("when visit list is empty, reject everything")
void emptyVisitList() throws JsonProcessingException {
void a_report_with_an_empty_visits_list_causes_400_bad_request() throws JsonProcessingException {
HttpEntity<ReportRequest> request = new HttpEntity<>(new ReportRequest(List.of(), 0L), newJsonHeader());
ResponseEntity<String> response = restTemplate
.postForEntity("/api/clea/v1/wreport", request, String.class);
......@@ -177,7 +177,7 @@ class CleaControllerTest {
@Test
@DisplayName("when a qrCode is null reject just the visit")
void nullQrCode() {
void a_visit_with_a_null_qrcode_is_ignored() {
HttpEntity<ReportRequest> request = new HttpEntity<>(
new ReportRequest(List.of(new Visit("qr1", 1L), new Visit(null, 2L)), 3L),
newJsonHeader()
......@@ -199,7 +199,7 @@ class CleaControllerTest {
@Test
@DisplayName("when a qrCode is empty reject just the visit")
void emptyQrCode() {
void a_visit_with_an_empty_qrcode_is_ignored() {
HttpEntity<ReportRequest> request = new HttpEntity<>(
new ReportRequest(List.of(new Visit("qr1", 1L), new Visit("", 2L)), 3L),
newJsonHeader()
......@@ -221,7 +221,7 @@ class CleaControllerTest {
@Test
@DisplayName("when a qrCode is blank reject just the visit")
void blankQrCode() {
void a_visit_with_a_blank_qrcode_is_ignored() {
HttpEntity<ReportRequest> request = new HttpEntity<>(
new ReportRequest(List.of(new Visit("qr1", 1L), new Visit(" ", 2L)), 3L),
newJsonHeader()
......@@ -243,7 +243,7 @@ class CleaControllerTest {
@Test
@DisplayName("when a qrScan is null reject just the visit")
void nullQrScan() {
void a_visit_with_a_null_qrcode_scantime_is_ignored() {
HttpEntity<ReportRequest> request = new HttpEntity<>(
new ReportRequest(List.of(new Visit("qr1", 1L), new Visit("qr2", null)), 3L),
newJsonHeader()
......@@ -265,7 +265,7 @@ class CleaControllerTest {
@Test
@DisplayName("when a qrScan is not numeric reject everything")
void notNumericQrScan() throws JsonProcessingException {
void a_visit_with_a_malformed_qrcode_scantime_is_ignored() throws JsonProcessingException {
ReportRequest reportRequest = new ReportRequest(List.of(new Visit("qr1", 1L), new Visit("qr2", 2L)), 3L);
String json = objectMapper.writeValueAsString(reportRequest);
String badJson = json.replace("2", "a");
......@@ -283,7 +283,7 @@ class CleaControllerTest {
@Test
@DisplayName("when no valid visit then reject everything")
void noValidVisits() throws JsonProcessingException {
void a_report_with_no_valid_visit_causes_400_bad_request() throws JsonProcessingException {
ReportRequest reportRequest = new ReportRequest(List.of(new Visit(" ", 1L)), 2L);
String json = objectMapper.writeValueAsString(reportRequest);
HttpEntity<String> request = new HttpEntity<>(json, newJsonHeader());
......
......@@ -63,7 +63,7 @@ class ProducerServiceTest {
@Test
@DisplayName("test that produceVisits can send decoded lsps to kafka and that we can read them back")
void testProduceVisits() {
void can_send_decrypted_lsps_to_kafka() {
final Map<String, Object> configs = KafkaTestUtils.consumerProps("visitConsumer", "false", embeddedKafkaBroker);
final Consumer<String, DecodedVisit> visitConsumer = new DefaultKafkaConsumerFactory<>(
configs,
......@@ -115,7 +115,7 @@ class ProducerServiceTest {
@Test
@DisplayName("test that produceStat can send a stat to kafka and that we can read it back")
void testProduceStat() {
void can_send_report_stat_to_kafka() {
final Map<String, Object> configs = KafkaTestUtils.consumerProps("statConsumer", "false", embeddedKafkaBroker);
final Consumer<String, ReportStat> statConsumer = new DefaultKafkaConsumerFactory<>(
configs,
......
......@@ -49,7 +49,7 @@ class ReportServiceTest {
@Test
@DisplayName("test successful report with no rejection")
void report() {
void can_process_a_valid_report() {
UUID uuid1 = UUID.randomUUID();
UUID uuid2 = UUID.randomUUID();
UUID uuid3 = UUID.randomUUID();
......@@ -68,7 +68,7 @@ class ReportServiceTest {
@Test
@DisplayName("test report with non valid qr codes")
void testWithNonValidReports() {
void a_visit_in_the_future_is_not_processed() {
UUID uuid1 = UUID.randomUUID();
UUID uuid2 = UUID.randomUUID();
UUID uuid3 = UUID.randomUUID();
......@@ -88,7 +88,7 @@ class ReportServiceTest {
@Test
@DisplayName("test report with outdated scans")
void testWithOutdatedReports() {
void an_outdated_visit_is_not_processed() {
UUID uuid1 = UUID.randomUUID();
UUID uuid2 = UUID.randomUUID();
UUID uuid3 = UUID.randomUUID();
......@@ -110,7 +110,7 @@ class ReportServiceTest {
@Test
@DisplayName("test report with future scans")
void testWithFutureReports() {
void a_visit_in_the_future_is_not_processed_2() {
UUID uuid1 = UUID.randomUUID();
UUID uuid2 = UUID.randomUUID();
List<Visit> visits = List.of(
......@@ -128,7 +128,7 @@ class ReportServiceTest {
@Test
@DisplayName("test report with duplicated qr codes")
void testWithDuplicates() {
void successive_visits_in_less_than_duplicateThresholdConfig__3h__are_deduplicated() {
UUID uuidA = UUID.fromString("60f5ebf7-d2af-4451-a575-7d1a2de7a9fd");
UUID uuidA2 = UUID.fromString("60f5ebf7-d2af-4451-a575-7d1a2de7a9fd");
UUID uuidB = UUID.fromString("de4c7b16-d5a2-45fa-a4f4-50fbf1e3880b");
......@@ -157,7 +157,7 @@ class ReportServiceTest {
@Test
@DisplayName("if pivot date is in future, set it to retentionDate and check that all visits are forward")
void testWithPivotDateInFuture() {
void a_report_with_a_future_pivotDate_is_processed_like_a_report_with_a_pivotDate_set_to_retentionDate_and_all_visits_should_be_forwards() {
long pivotDateInFutureAsNtp = TimeUtils.ntpTimestampFromInstant(now.plus(1, ChronoUnit.MINUTES));
UUID uuid1 = UUID.randomUUID();
......@@ -178,7 +178,7 @@ class ReportServiceTest {
@Test
@DisplayName("if pivot date is before retentionDate, set it to retentionDate and check that all visits are forward")
void testWithPivotDateTooOld() {
void a_report_with_an_outdated_pivotDate_is_processed_like_a_report_with_a_pivotDate_set_to_retentionDate_and_all_visits_should_be_forwards() {
long pivotDateTooOldAsNtp = TimeUtils.ntpTimestampFromInstant(now.minus(15, ChronoUnit.DAYS));
UUID uuid1 = UUID.randomUUID();
......@@ -199,7 +199,7 @@ class ReportServiceTest {
@Test
@DisplayName("if pivot date is before or equal qrScanTime, visits should be marked as forward")
void testForward() {
void visits_with_qrScanTime_after_or_equal_to_pivotDate_should_be_forwards() {
long pivotDate = TimeUtils.ntpTimestampFromInstant(now.minus(1, ChronoUnit.DAYS));
long qrScan = TimeUtils.ntpTimestampFromInstant(now);
UUID uuid1 = UUID.randomUUID();
......@@ -218,7 +218,7 @@ class ReportServiceTest {
@Test
@DisplayName("if pivot date is strictly after qrScanTime, visits should be marked as backward")
void testBackward() {
void visits_with_qrScanTime_strictly_before_pivotDate_should_be_backwards() {
long pivotDate = TimeUtils.ntpTimestampFromInstant(now);
long qrScan = TimeUtils.ntpTimestampFromInstant(now.minus(1, ChronoUnit.DAYS));
UUID uuid = UUID.randomUUID();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment