@@ -155,7 +155,8 @@ public void testUsage() throws Exception {
155155 Settings .Builder settings = Settings .builder ().put (commonSettings );
156156 settings .put ("xpack.ml.enabled" , true );
157157
158- Job opened1 = buildJob ("opened1" , Arrays .asList (buildMinDetector ("foo" )));
158+ Job opened1 = buildJob ("opened1" , Collections .singletonList (buildMinDetector ("foo" )),
159+ Collections .singletonMap ("created_by" , randomFrom ("a-cool-module" , "a_cool_module" , "a cool module" )));
159160 GetJobsStatsAction .Response .JobStats opened1JobStats = buildJobStats ("opened1" , JobState .OPENED , 100L , 3L );
160161 Job opened2 = buildJob ("opened2" , Arrays .asList (buildMinDetector ("foo" ), buildMinDetector ("bar" )));
161162 GetJobsStatsAction .Response .JobStats opened2JobStats = buildJobStats ("opened2" , JobState .OPENED , 200L , 8L );
@@ -200,6 +201,8 @@ public void testUsage() throws Exception {
200201 assertThat (source .getValue ("jobs._all.model_size.max" ), equalTo (300.0 ));
201202 assertThat (source .getValue ("jobs._all.model_size.total" ), equalTo (600.0 ));
202203 assertThat (source .getValue ("jobs._all.model_size.avg" ), equalTo (200.0 ));
204+ assertThat (source .getValue ("jobs._all.created_by.a_cool_module" ), equalTo (1 ));
205+ assertThat (source .getValue ("jobs._all.created_by.unknown" ), equalTo (2 ));
203206
204207 assertThat (source .getValue ("jobs.opened.count" ), equalTo (2 ));
205208 assertThat (source .getValue ("jobs.opened.detectors.min" ), equalTo (1.0 ));
@@ -210,6 +213,8 @@ public void testUsage() throws Exception {
210213 assertThat (source .getValue ("jobs.opened.model_size.max" ), equalTo (200.0 ));
211214 assertThat (source .getValue ("jobs.opened.model_size.total" ), equalTo (300.0 ));
212215 assertThat (source .getValue ("jobs.opened.model_size.avg" ), equalTo (150.0 ));
216+ assertThat (source .getValue ("jobs.opened.created_by.a_cool_module" ), equalTo (1 ));
217+ assertThat (source .getValue ("jobs.opened.created_by.unknown" ), equalTo (1 ));
213218
214219 assertThat (source .getValue ("jobs.closed.count" ), equalTo (1 ));
215220 assertThat (source .getValue ("jobs.closed.detectors.min" ), equalTo (3.0 ));
@@ -220,6 +225,8 @@ public void testUsage() throws Exception {
220225 assertThat (source .getValue ("jobs.closed.model_size.max" ), equalTo (300.0 ));
221226 assertThat (source .getValue ("jobs.closed.model_size.total" ), equalTo (300.0 ));
222227 assertThat (source .getValue ("jobs.closed.model_size.avg" ), equalTo (300.0 ));
228+ assertThat (source .getValue ("jobs.closed.created_by.a_cool_module" ), is (nullValue ()));
229+ assertThat (source .getValue ("jobs.closed.created_by.unknown" ), equalTo (1 ));
223230
224231 assertThat (source .getValue ("jobs.opening" ), is (nullValue ()));
225232 assertThat (source .getValue ("jobs.closing" ), is (nullValue ()));
@@ -359,6 +366,7 @@ private void givenJobs(List<Job> jobs, List<GetJobsStatsAction.Response.JobStats
359366 }).when (jobManager ).expandJobs (eq (MetaData .ALL ), eq (true ), any (ActionListener .class ));
360367
361368 doAnswer (invocationOnMock -> {
369+ @ SuppressWarnings ("unchecked" )
362370 ActionListener <GetJobsStatsAction .Response > listener =
363371 (ActionListener <GetJobsStatsAction .Response >) invocationOnMock .getArguments ()[2 ];
364372 listener .onResponse (new GetJobsStatsAction .Response (
@@ -400,6 +408,7 @@ private void givenNodeCount(int nodeCount) {
400408
401409 private void givenDatafeeds (List <GetDatafeedsStatsAction .Response .DatafeedStats > datafeedStats ) {
402410 doAnswer (invocationOnMock -> {
411+ @ SuppressWarnings ("unchecked" )
403412 ActionListener <GetDatafeedsStatsAction .Response > listener =
404413 (ActionListener <GetDatafeedsStatsAction .Response >) invocationOnMock .getArguments ()[2 ];
405414 listener .onResponse (new GetDatafeedsStatsAction .Response (
@@ -416,10 +425,15 @@ private static Detector buildMinDetector(String fieldName) {
416425 }
417426
418427 private static Job buildJob (String jobId , List <Detector > detectors ) {
428+ return buildJob (jobId , detectors , null );
429+ }
430+
431+ private static Job buildJob (String jobId , List <Detector > detectors , Map <String , Object > customSettings ) {
419432 AnalysisConfig .Builder analysisConfig = new AnalysisConfig .Builder (detectors );
420433 return new Job .Builder (jobId )
421434 .setAnalysisConfig (analysisConfig )
422435 .setDataDescription (new DataDescription .Builder ())
436+ .setCustomSettings (customSettings )
423437 .build (new Date (randomNonNegativeLong ()));
424438 }
425439
0 commit comments