|
47 | 47 | import org.elasticsearch.index.alias.RandomAliasActionsGenerator;
|
48 | 48 | import org.elasticsearch.index.mapper.MapperService;
|
49 | 49 | import org.elasticsearch.indices.IndicesModule;
|
| 50 | +import org.elasticsearch.ingest.IngestMetadata; |
50 | 51 | import org.elasticsearch.plugins.FieldPredicate;
|
51 | 52 | import org.elasticsearch.plugins.MapperPlugin;
|
52 | 53 | import org.elasticsearch.test.AbstractChunkedSerializingTestCase;
|
@@ -2870,6 +2871,46 @@ public void testRetrieveIndexModeFromTemplateEmpty() throws IOException {
|
2870 | 2871 | }
|
2871 | 2872 | }
|
2872 | 2873 |
|
| 2874 | + public void testGetSingleProjectWithCustom() { |
| 2875 | + var type = IngestMetadata.TYPE; |
| 2876 | + { |
| 2877 | + Metadata metadata = Metadata.builder().build(); |
| 2878 | + assertNull(metadata.getSingleProjectCustom(type)); |
| 2879 | + assertNull(metadata.getSingleProjectWithCustom(type)); |
| 2880 | + } |
| 2881 | + { |
| 2882 | + Metadata metadata = Metadata.builder().put(ProjectMetadata.builder(new ProjectId(randomUUID())).build()).build(); |
| 2883 | + assertNull(metadata.getSingleProjectCustom(type)); |
| 2884 | + assertNull(metadata.getSingleProjectWithCustom(type)); |
| 2885 | + } |
| 2886 | + { |
| 2887 | + var ingestMetadata = new IngestMetadata(Map.of()); |
| 2888 | + Metadata metadata = Metadata.builder() |
| 2889 | + .put(ProjectMetadata.builder(new ProjectId(randomUUID())).putCustom(type, ingestMetadata)) |
| 2890 | + .build(); |
| 2891 | + assertEquals(ingestMetadata, metadata.getSingleProjectCustom(type)); |
| 2892 | + assertEquals(ingestMetadata, metadata.getSingleProjectWithCustom(type).custom(type)); |
| 2893 | + } |
| 2894 | + { |
| 2895 | + var ingestMetadata = new IngestMetadata(Map.of()); |
| 2896 | + Metadata metadata = Metadata.builder() |
| 2897 | + .put(ProjectMetadata.builder(new ProjectId(randomUUID()))) |
| 2898 | + .put(ProjectMetadata.builder(new ProjectId(randomUUID())).putCustom(type, ingestMetadata)) |
| 2899 | + .build(); |
| 2900 | + assertEquals(ingestMetadata, metadata.getSingleProjectCustom(type)); |
| 2901 | + assertEquals(ingestMetadata, metadata.getSingleProjectWithCustom(type).custom(type)); |
| 2902 | + } |
| 2903 | + { |
| 2904 | + var ingestMetadata = new IngestMetadata(Map.of()); |
| 2905 | + Metadata metadata = Metadata.builder() |
| 2906 | + .put(ProjectMetadata.builder(new ProjectId(randomUUID())).putCustom(type, new IngestMetadata(Map.of()))) |
| 2907 | + .put(ProjectMetadata.builder(new ProjectId(randomUUID())).putCustom(type, ingestMetadata)) |
| 2908 | + .build(); |
| 2909 | + assertThrows(UnsupportedOperationException.class, () -> metadata.getSingleProjectCustom(type)); |
| 2910 | + assertThrows(UnsupportedOperationException.class, () -> metadata.getSingleProjectWithCustom(type)); |
| 2911 | + } |
| 2912 | + } |
| 2913 | + |
2873 | 2914 | public void testProjectLookupWithSingleProject() {
|
2874 | 2915 | final ProjectId projectId = Metadata.DEFAULT_PROJECT_ID;
|
2875 | 2916 | final ProjectMetadata.Builder projectBuilder = ProjectMetadata.builder(projectId);
|
|
0 commit comments