harbor run -t openthoughts/tasktrove-exp-rpt-crosscodeeval-java-crosscodeeval-java-0403harbor download openthoughts/tasktrove-exp-rpt-crosscodeeval-java-crosscodeeval-java-0403solution file
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright Decodable, Inc.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package co.decodable.sdk.pipeline.testing;
import co.decodable.sdk.pipeline.EnvironmentAccess;
import co.decodable.sdk.pipeline.util.Incubating;
import java.lang.System.Logger.Level;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
/**
* Provides access to Decodable streams during testing as well as the ability to run custom Flink
* jobs.
*/
@Incubating
public class PipelineTestContext implements AutoCloseable {
private static final System.Logger LOGGER = System.getLogger(PipelineTestContext.class.getName());
private final TestEnvironment testEnvironment;
private final KafkaProducer<String, String> producer;
private final Map<String, DecodableStreamImpl> streams;
private final ExecutorService executorService;
/** Creates a new testing context, using the given {@link TestEnvironment}. */
public PipelineTestContext(TestEnvironment testEnvironment) {
EnvironmentAccess.setEnvironment(testEnvironment);
this.testEnvironment = testEnvironment;
this.producer =
new KafkaProducer<String, String>(
Complete the code above, taking into account the cross-file context provided. Your solution must work correctly with the related files in the project.
Place your complete solution in /app/solution.py