Github user hmcl commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2465#discussion_r157930210
  
    --- Diff: 
external/storm-kafka-client/src/test/java/org/apache/storm/kafka/OffsetAndMetadataMocks.java
 ---
    @@ -0,0 +1,54 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + *   or more contributor license agreements.  See the NOTICE file
    + *   distributed with this work for additional information
    + *   regarding copyright ownership.  The ASF licenses this file
    + *   to you under the Apache License, Version 2.0 (the
    + *   "License"); you may not use this file except in compliance
    + *   with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *   Unless required by applicable law or agreed to in writing, software
    + *   distributed under the License is distributed on an "AS IS" BASIS,
    + *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
    + *   See the License for the specific language governing permissions and
    + *   limitations under the License.
    + */
    +
    +package org.apache.storm.kafka;
    +
    +import com.fasterxml.jackson.databind.ObjectMapper;
    +import org.apache.kafka.clients.consumer.KafkaConsumer;
    +import org.apache.kafka.clients.consumer.OffsetAndMetadata;
    +import org.apache.kafka.common.TopicPartition;
    +import org.apache.storm.kafka.spout.internal.CommitMetadata;
    +import org.apache.storm.task.TopologyContext;
    +
    +import static org.mockito.Mockito.mock;
    +import static org.mockito.Mockito.when;
    +
    +public class OffsetAndMetadataMocks {
    +    public static final String COMMIT_METADATA = 
"{\"topologyId\":\"tp1\",\"taskId\":3,\"thread\":\"Thread-20\"}";
    +
    +    public static OffsetAndMetadata createMocksTree(KafkaConsumer<String, 
String> consumerMock,
    +                                                    TopologyContext 
topologyContext,
    +                                                    TopicPartition 
topicPartition) throws java.io.IOException {
    +
    +        OffsetAndMetadata oam = mock(OffsetAndMetadata.class);
    +        when(consumerMock.committed(topicPartition))
    +            .thenReturn(oam);
    +
    +        when(oam.metadata())
    +            .thenReturn(COMMIT_METADATA);
    +
    +        when(topologyContext.getStormId()).thenReturn("tp1");
    +
    +        ObjectMapper om = mock(ObjectMapper.class);
    --- End diff --
    
    Done


---

Reply via email to