@@ -436,9 +436,10 @@ public void testPutDatafeed() throws Exception {
436
436
}
437
437
438
438
public void testUpdateDatafeed () throws Exception {
439
+ MachineLearningClient machineLearningClient = highLevelClient ().machineLearning ();
440
+
439
441
String jobId = randomValidJobId ();
440
442
Job job = buildJob (jobId );
441
- MachineLearningClient machineLearningClient = highLevelClient ().machineLearning ();
442
443
execute (new PutJobRequest (job ), machineLearningClient ::putJob , machineLearningClient ::putJobAsync );
443
444
444
445
String datafeedId = "datafeed-" + jobId ;
@@ -462,6 +463,31 @@ public void testUpdateDatafeed() throws Exception {
462
463
assertThat (datafeedUpdate .getScrollSize (), equalTo (updatedDatafeed .getScrollSize ()));
463
464
}
464
465
466
+ public void testUpdateDatafeed_UpdatingJobIdIsDeprecated () throws Exception {
467
+ MachineLearningClient machineLearningClient = highLevelClient ().machineLearning ();
468
+
469
+ String jobId = randomValidJobId ();
470
+ Job job = buildJob (jobId );
471
+ execute (new PutJobRequest (job ), machineLearningClient ::putJob , machineLearningClient ::putJobAsync );
472
+
473
+ String anotherJobId = randomValidJobId ();
474
+ Job anotherJob = buildJob (anotherJobId );
475
+ execute (new PutJobRequest (anotherJob ), machineLearningClient ::putJob , machineLearningClient ::putJobAsync );
476
+
477
+ String datafeedId = "datafeed-" + jobId ;
478
+ DatafeedConfig datafeedConfig = DatafeedConfig .builder (datafeedId , jobId ).setIndices ("some_data_index" ).build ();
479
+ execute (new PutDatafeedRequest (datafeedConfig ), machineLearningClient ::putDatafeed , machineLearningClient ::putDatafeedAsync );
480
+
481
+ DatafeedUpdate datafeedUpdateWithChangedJobId = DatafeedUpdate .builder (datafeedId ).setJobId (anotherJobId ).build ();
482
+ WarningFailureException exception = expectThrows (
483
+ WarningFailureException .class ,
484
+ () -> execute (
485
+ new UpdateDatafeedRequest (datafeedUpdateWithChangedJobId ),
486
+ machineLearningClient ::updateDatafeed ,
487
+ machineLearningClient ::updateDatafeedAsync ));
488
+ assertThat (exception .getResponse ().getWarnings (), contains ("The ability to update a datafeed's job_id is deprecated." ));
489
+ }
490
+
465
491
public void testGetDatafeed () throws Exception {
466
492
String jobId1 = "test-get-datafeed-job-1" ;
467
493
String jobId2 = "test-get-datafeed-job-2" ;
0 commit comments