muralibasani commented on code in PR #22992: URL: https://github.com/apache/kafka/pull/22992#discussion_r4577669473
########## streams/src/test/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersWindowStoreAdapterCompletenessTest.java: ########## @@ -0,0 +1,141 @@ +/* + * 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.kafka.streams.state.internals; + +import org.apache.kafka.streams.state.WindowStore; + +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Requires every {@link WindowStore} method to be classified into a contract group, and every non-special + * method to be overridden by {@link TimestampedToHeadersWindowStoreAdapter}, so a header-aware override + * that is silently dropped (returning raw bytes) fails this test rather than escaping to manual testing + * (KAFKA-20328). Behavioral assertions live in {@link TimestampedToHeadersWindowStoreAdapterDelegationTest} + * and {@link TimestampedToHeadersWindowStoreAdapterTest}. + * <p> + * Signatures use erased parameter types, so a key ({@code K}) or value ({@code V}) appears as {@code Object}. + */ +public class TimestampedToHeadersWindowStoreAdapterCompletenessTest { + + private static final Set<String> VALUE_CONVERTING = Set.of( + "fetch(Object,long)" + ); + + private static final Set<String> ITERATOR_WRAPPING = Set.of( + "fetch(Object,long,long)", + "fetch(Object,Instant,Instant)", + "backwardFetch(Object,long,long)", + "backwardFetch(Object,Instant,Instant)", + "fetch(Object,Object,long,long)", + "fetch(Object,Object,Instant,Instant)", + "backwardFetch(Object,Object,long,long)", + "backwardFetch(Object,Object,Instant,Instant)", + "fetchAll(long,long)", + "fetchAll(Instant,Instant)", + "backwardFetchAll(long,long)", + "backwardFetchAll(Instant,Instant)", + "all()", + "backwardAll()" + ); + + private static final Set<String> HEADER_STRIPPING = Set.of( + "put(Object,Object,long)" + ); + + private static final Set<String> DELEGATING = Set.of( + "name()", + "init(StateStoreContext,StateStore)", + "commit(Map)", + "managesOffsets()", + "committedOffset(TopicPartition)", + "approximateNumUncommittedBytes()", + "close()", + "persistent()", + "isOpen()", + "getPosition()" + ); + + // query has bespoke iterator wrapping; flush is a deprecated no-op; readOnly returns `this`. + private static final Set<String> SPECIAL = Set.of( + "query(Query,PositionBound,QueryConfig)", + "flush()", + "readOnly(IsolationLevel)" Review Comment: Thank you. good one. I hv updated the SPECIAL comment in both tests and referenced the jira ticket. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
