1111import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .equalTo ;
1212import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .satisfies ;
1313import static java .nio .charset .StandardCharsets .UTF_8 ;
14+ import static java .util .Arrays .asList ;
1415
1516import com .sun .net .httpserver .HttpServer ;
1617import io .opentelemetry .api .trace .SpanKind ;
@@ -324,18 +325,14 @@ private static String buildScriptCommandLine() throws IOException {
324325
325326 private static List <AttributeAssertion > elasticJobBaseAttributes (
326327 String jobName , long item , long totalCount , String parameters ) {
327- List <AttributeAssertion > assertions = new ArrayList <>();
328- assertions .add (equalTo (stringKey ("job.system" ), "elasticjob" ));
329- assertions .add (equalTo (stringKey ("scheduling.apache-elasticjob.job.name" ), jobName ));
330- assertions .add (equalTo (longKey ("scheduling.apache-elasticjob.sharding.item.index" ), item ));
331- assertions .add (
332- equalTo (longKey ("scheduling.apache-elasticjob.sharding.total.count" ), totalCount ));
333- assertions .add (
334- equalTo (stringKey ("scheduling.apache-elasticjob.sharding.item.parameters" ), parameters ));
335- assertions .add (
328+ return asList (
329+ equalTo (stringKey ("job.system" ), "elasticjob" ),
330+ equalTo (stringKey ("scheduling.apache-elasticjob.job.name" ), jobName ),
331+ equalTo (longKey ("scheduling.apache-elasticjob.sharding.item.index" ), item ),
332+ equalTo (longKey ("scheduling.apache-elasticjob.sharding.total.count" ), totalCount ),
333+ equalTo (stringKey ("scheduling.apache-elasticjob.sharding.item.parameters" ), parameters ),
336334 satisfies (
337335 stringKey ("scheduling.apache-elasticjob.task.id" ), taskId -> taskId .contains (jobName )));
338- return assertions ;
339336 }
340337
341338 private static List <AttributeAssertion > elasticJobWithCodeAttributes (
@@ -345,9 +342,11 @@ private static List<AttributeAssertion> elasticJobWithCodeAttributes(
345342 String parameters ,
346343 String codeFunction ,
347344 String codeNamespace ) {
348- List <AttributeAssertion > assertions = new ArrayList <>();
349- assertions .add (equalTo (stringKey ("code.function" ), codeFunction ));
350- assertions .add (equalTo (stringKey ("code.namespace" ), codeNamespace ));
345+ List <AttributeAssertion > assertions =
346+ new ArrayList <>(
347+ asList (
348+ equalTo (stringKey ("code.function" ), codeFunction ),
349+ equalTo (stringKey ("code.namespace" ), codeNamespace )));
351350 assertions .addAll (elasticJobBaseAttributes (jobName , item , totalCount , parameters ));
352351 return assertions ;
353352 }
0 commit comments