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

    https://github.com/apache/storm/pull/2465#discussion_r157737965
  
    --- 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,
    --- End diff --
    
    I think you should leave off the topicPartition. You can use the 
any(TopicPartition.class) matcher in L39 instead.
    
    It might also be good to rename to stubCommitted, and split it up a bit. 
The consumerMock/oam stub makes sense to have in a method together, but I think 
the topologyContext stubbing should be separated. Otherwise there's no way to 
test the case where you want to check what happens when the spout starts up 
with a commit metadata from an older topology (which I think we should add 
tests for to demonstrate that EARLIEST/LATEST work the way we say they do)


---

Reply via email to