|
16 | 16 |
|
17 | 17 | package org.springframework.cloud.gcp.data.datastore.it;
|
18 | 18 |
|
19 |
| -import java.io.File; |
20 |
| -import java.io.IOException; |
21 |
| -import java.net.URISyntaxException; |
22 |
| -import java.net.URL; |
23 |
| -import java.nio.file.Paths; |
24 | 19 | import java.util.ArrayList;
|
25 | 20 | import java.util.Arrays;
|
26 | 21 | import java.util.Collection;
|
@@ -851,38 +846,20 @@ public void testPageableGqlEntityProjectionsSlice() {
|
851 | 846 | }
|
852 | 847 |
|
853 | 848 | @Test(timeout = 10000L)
|
854 |
| - public void testSliceString() throws IOException, URISyntaxException, InterruptedException { |
855 |
| - createIndexAndRun(() -> { |
| 849 | + public void testSliceString() { |
| 850 | + try { |
856 | 851 | Slice<String> slice = this.testEntityRepository.getSliceStringBySize(2L, PageRequest.of(0, 3));
|
857 | 852 |
|
858 | 853 | List<String> testEntityProjections = slice.get().collect(Collectors.toList());
|
859 | 854 |
|
860 | 855 | assertThat(testEntityProjections).hasSize(1);
|
861 | 856 | assertThat(testEntityProjections.get(0)).isEqualTo("blue");
|
862 |
| - }); |
863 |
| - } |
864 |
| - |
865 |
| - private void createIndexAndRun(Runnable runnable) throws URISyntaxException, IOException, InterruptedException { |
866 |
| - URL resource = this.getClass().getResource("/index.yaml"); |
867 |
| - File file = Paths.get(resource.toURI()).toFile(); |
868 |
| - |
869 |
| - Process process = new ProcessBuilder("gcloud", "datastore", "indexes", "create", file.getAbsolutePath(), "-q") |
870 |
| - .start(); |
871 |
| - |
872 |
| - if (process.waitFor() != 0) { |
873 |
| - throw new RuntimeException("Error while creating index."); |
874 |
| - } |
875 |
| - |
876 |
| - try { |
877 |
| - runnable.run(); |
878 | 857 | }
|
879 | 858 | catch (DatastoreException e) {
|
880 | 859 | if (e.getMessage().contains("no matching index found")) {
|
881 |
| - throw new RuntimeException( |
882 |
| - "The required index is not found. " |
883 |
| - + "This test attempts to create it, but it might take a few minutes. " |
884 |
| - + "Retry this test later.", |
885 |
| - e); |
| 860 | + throw new RuntimeException("The required index is not found. " + |
| 861 | + "The index could be created by running this command from 'resources' directory: " + |
| 862 | + "'gcloud datastore indexes create index.yaml'"); |
886 | 863 | }
|
887 | 864 | throw e;
|
888 | 865 | }
|
|
0 commit comments