@@ -53,7 +53,7 @@ public void setup() {
5353 }
5454
5555 public void testGetAdditionalIndexSettings () throws Exception {
56- ProjectMetadata projectMetadata = Metadata . EMPTY_METADATA . getProject ();
56+ ProjectMetadata projectMetadata = emptyProject ();
5757 String dataStreamName = "logs-app1" ;
5858
5959 Instant now = Instant .now ().truncatedTo (ChronoUnit .SECONDS );
@@ -96,7 +96,7 @@ public void testGetAdditionalIndexSettings() throws Exception {
9696 }
9797
9898 public void testGetAdditionalIndexSettingsIndexRoutingPathAlreadyDefined () throws Exception {
99- ProjectMetadata projectMetadata = Metadata . EMPTY_METADATA . getProject ();
99+ ProjectMetadata projectMetadata = emptyProject ();
100100 String dataStreamName = "logs-app1" ;
101101
102102 Instant now = Instant .now ().truncatedTo (ChronoUnit .SECONDS );
@@ -140,7 +140,7 @@ public void testGetAdditionalIndexSettingsIndexRoutingPathAlreadyDefined() throw
140140 }
141141
142142 public void testGetAdditionalIndexSettingsMappingsMerging () throws Exception {
143- ProjectMetadata projectMetadata = Metadata . EMPTY_METADATA . getProject ();
143+ ProjectMetadata projectMetadata = emptyProject ();
144144 String dataStreamName = "logs-app1" ;
145145
146146 Instant now = Instant .now ().truncatedTo (ChronoUnit .SECONDS );
@@ -211,7 +211,7 @@ public void testGetAdditionalIndexSettingsMappingsMerging() throws Exception {
211211 }
212212
213213 public void testGetAdditionalIndexSettingsNoMappings () {
214- ProjectMetadata projectMetadata = Metadata . EMPTY_METADATA . getProject ();
214+ ProjectMetadata projectMetadata = emptyProject ();
215215 String dataStreamName = "logs-app1" ;
216216
217217 Instant now = Instant .now ().truncatedTo (ChronoUnit .SECONDS );
@@ -235,7 +235,7 @@ public void testGetAdditionalIndexSettingsNoMappings() {
235235 }
236236
237237 public void testGetAdditionalIndexSettingsLookAheadTime () throws Exception {
238- ProjectMetadata projectMetadata = Metadata . EMPTY_METADATA . getProject ();
238+ ProjectMetadata projectMetadata = emptyProject ();
239239 String dataStreamName = "logs-app1" ;
240240
241241 Instant now = Instant .now ().truncatedTo (ChronoUnit .SECONDS );
@@ -260,7 +260,7 @@ public void testGetAdditionalIndexSettingsLookAheadTime() throws Exception {
260260 }
261261
262262 public void testGetAdditionalIndexSettingsLookBackTime () throws Exception {
263- ProjectMetadata projectMetadata = Metadata . EMPTY_METADATA . getProject ();
263+ ProjectMetadata projectMetadata = emptyProject ();
264264 String dataStreamName = "logs-app1" ;
265265
266266 Instant now = Instant .now ().truncatedTo (ChronoUnit .SECONDS );
@@ -290,10 +290,11 @@ public void testGetAdditionalIndexSettingsDataStreamAlreadyCreated() throws Exce
290290
291291 Instant sixHoursAgo = Instant .now ().minus (6 , ChronoUnit .HOURS ).truncatedTo (ChronoUnit .SECONDS );
292292 Instant currentEnd = sixHoursAgo .plusMillis (lookAheadTime .getMillis ());
293- ProjectMetadata projectMetadata = DataStreamTestHelper .getClusterStateWithDataStream (
293+ ProjectMetadata projectMetadata = DataStreamTestHelper .getProjectWithDataStream (
294+ randomProjectIdOrDefault (),
294295 dataStreamName ,
295296 List .of (new Tuple <>(sixHoursAgo , currentEnd ))
296- ). getMetadata (). getProject () ;
297+ );
297298
298299 Instant now = sixHoursAgo .plus (6 , ChronoUnit .HOURS );
299300 Settings settings = Settings .EMPTY ;
@@ -317,18 +318,20 @@ public void testGetAdditionalIndexSettingsDataStreamAlreadyCreated() throws Exce
317318 public void testGetAdditionalIndexSettingsDataStreamAlreadyCreatedTimeSettingsMissing () {
318319 String dataStreamName = "logs-app1" ;
319320 Instant twoHoursAgo = Instant .now ().minus (4 , ChronoUnit .HOURS ).truncatedTo (ChronoUnit .MILLIS );
320- Metadata .Builder mb = Metadata .builder (
321+ final var projectId = randomProjectIdOrDefault ();
322+ ProjectMetadata .Builder projectBuilder = ProjectMetadata .builder (
321323 DataStreamTestHelper .getClusterStateWithDataStreams (
324+ projectId ,
322325 List .of (Tuple .tuple (dataStreamName , 1 )),
323326 List .of (),
324327 twoHoursAgo .toEpochMilli (),
325328 builder ().build (),
326329 1
327- ).getMetadata ( )
330+ ).metadata (). getProject ( projectId )
328331 );
329- DataStream ds = mb .dataStream (dataStreamName );
330- mb .put (ds .copy ().setIndexMode (IndexMode .TIME_SERIES ).build ());
331- ProjectMetadata projectMetadata = mb .build (). getProject ();
332+ DataStream ds = projectBuilder .dataStream (dataStreamName );
333+ projectBuilder .put (ds .copy ().setIndexMode (IndexMode .TIME_SERIES ).build ());
334+ ProjectMetadata projectMetadata = projectBuilder .build ();
332335
333336 Instant now = twoHoursAgo .plus (2 , ChronoUnit .HOURS );
334337 Settings settings = Settings .EMPTY ;
@@ -356,7 +359,7 @@ public void testGetAdditionalIndexSettingsDataStreamAlreadyCreatedTimeSettingsMi
356359 }
357360
358361 public void testGetAdditionalIndexSettingsNonTsdbTemplate () {
359- ProjectMetadata projectMetadata = Metadata . EMPTY_METADATA . getProject ();
362+ ProjectMetadata projectMetadata = emptyProject ();
360363 String dataStreamName = "logs-app1" ;
361364
362365 Settings settings = Settings .EMPTY ;
@@ -377,10 +380,9 @@ public void testGetAdditionalIndexSettingsMigrateToTsdb() {
377380 String dataStreamName = "logs-app1" ;
378381 IndexMetadata idx = createFirstBackingIndex (dataStreamName ).build ();
379382 DataStream existingDataStream = newInstance (dataStreamName , List .of (idx .getIndex ()));
380- ProjectMetadata projectMetadata = Metadata .builder ()
383+ ProjectMetadata projectMetadata = ProjectMetadata .builder (randomProjectIdOrDefault () )
381384 .dataStreams (Map .of (dataStreamName , existingDataStream ), Map .of ())
382- .build ()
383- .getProject ();
385+ .build ();
384386
385387 Settings settings = Settings .EMPTY ;
386388 Settings result = provider .getAdditionalIndexSettings (
@@ -404,16 +406,18 @@ public void testGetAdditionalIndexSettingsMigrateToTsdb() {
404406 public void testGetAdditionalIndexSettingsDowngradeFromTsdb () {
405407 String dataStreamName = "logs-app1" ;
406408 Instant twoHoursAgo = Instant .now ().minus (4 , ChronoUnit .HOURS ).truncatedTo (ChronoUnit .MILLIS );
409+ final var projectId = randomProjectIdOrDefault ();
407410 Metadata .Builder mb = Metadata .builder (
408411 DataStreamTestHelper .getClusterStateWithDataStreams (
412+ projectId ,
409413 List .of (Tuple .tuple (dataStreamName , 1 )),
410414 List .of (),
411415 twoHoursAgo .toEpochMilli (),
412416 builder ().build (),
413417 1
414418 ).getMetadata ()
415419 );
416- ProjectMetadata projectMetadata = mb .build ().getProject ();
420+ ProjectMetadata projectMetadata = mb .build ().getProject (projectId );
417421
418422 Settings settings = Settings .EMPTY ;
419423 Settings result = provider .getAdditionalIndexSettings (
@@ -691,7 +695,7 @@ public void testGenerateRoutingPathFromPassThroughObject() throws Exception {
691695 }
692696
693697 private Settings generateTsdbSettings (String mapping , Instant now ) throws IOException {
694- ProjectMetadata projectMetadata = Metadata . EMPTY_METADATA . getProject ();
698+ ProjectMetadata projectMetadata = emptyProject ();
695699 String dataStreamName = "logs-app1" ;
696700 Settings settings = Settings .EMPTY ;
697701
0 commit comments