|
77 | 77 | import org.springframework.util.StreamUtils; |
78 | 78 | import org.springframework.web.client.RestTemplate; |
79 | 79 |
|
80 | | - |
81 | 80 | import static org.assertj.core.api.Assertions.assertThat; |
82 | 81 | import static org.junit.jupiter.api.Assertions.assertThrows; |
83 | 82 | import static org.junit.jupiter.api.Assertions.assertTrue; |
@@ -644,9 +643,9 @@ public void analyticsCounter() { |
644 | 643 |
|
645 | 644 | Awaitility.await().until(() -> stream.getStatus().equals(DEPLOYED)); |
646 | 645 |
|
647 | | - String message1 = "Test message 1"; |
648 | | - String message2 = "Test message 2 with extension"; |
649 | | - String message3 = "Test message 2 with double extension"; |
| 646 | + String message1 = "Test message 1"; // length 14 |
| 647 | + String message2 = "Test message 2 with extension"; // length 29 |
| 648 | + String message3 = "Test message 2 with double extension"; // length 36 |
650 | 649 |
|
651 | 650 | String httpAppUrl = runtimeApps.getApplicationInstanceUrl(stream.getName(), "http"); |
652 | 651 | httpPost(httpAppUrl, message1); |
@@ -684,14 +683,14 @@ public void analyticsCounter() { |
684 | 683 | .inPath("$.results[0].series[0].values[1][0]") |
685 | 684 | .isEqualTo("myinfluxdb"); |
686 | 685 |
|
| 686 | + List<String> messageLengths = java.util.stream.Stream.of(message1, message2, message3) |
| 687 | + .map(s -> String.format("\"%s\"", s.length())).collect(Collectors.toList()); |
| 688 | + |
687 | 689 | // http://localhost:8086/query?db=myinfluxdb&q=SELECT%20%2A%20FROM%20%22my_http_counter%22 |
688 | 690 | String myHttpCounter = httpGet(testProperties.getInfluxUrl() + "/query?db=myinfluxdb&q=SELECT * FROM \"my_http_analytics\""); |
689 | | - JsonAssertions.assertThatJson(myHttpCounter).inPath("$.results[0].series[0].values[0][7]") |
690 | | - .isEqualTo(String.format("\"%s\"", message1.length())); |
691 | | - JsonAssertions.assertThatJson(myHttpCounter).inPath("$.results[0].series[0].values[1][7]") |
692 | | - .isEqualTo(String.format("\"%s\"", message2.length())); |
693 | | - JsonAssertions.assertThatJson(myHttpCounter).inPath("$.results[0].series[0].values[2][7]") |
694 | | - .isEqualTo(String.format("\"%s\"", message3.length())); |
| 691 | + JsonAssertions.assertThatJson(myHttpCounter).inPath("$.results[0].series[0].values[0][7]").isIn(messageLengths); |
| 692 | + JsonAssertions.assertThatJson(myHttpCounter).inPath("$.results[0].series[0].values[1][7]").isIn(messageLengths); |
| 693 | + JsonAssertions.assertThatJson(myHttpCounter).inPath("$.results[0].series[0].values[2][7]").isIn(messageLengths); |
695 | 694 | }); |
696 | 695 | } |
697 | 696 | } |
|
0 commit comments