This is an automated email from the ASF dual-hosted git repository. tkalkirill pushed a commit to branch ignite-27053 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 1ef577709fc1b8163af20252fb855ab2896670a0 Author: Kirill Tkalenko <[email protected]> AuthorDate: Mon Nov 17 08:57:46 2025 +0300 IGNITE-27053 wip --- .../ignite/internal/app/SameValueLongSupplier.java | 49 ------------------ .../internal/app/SameValueLongSupplierTest.java | 59 ---------------------- 2 files changed, 108 deletions(-) diff --git a/modules/runner/src/main/java/org/apache/ignite/internal/app/SameValueLongSupplier.java b/modules/runner/src/main/java/org/apache/ignite/internal/app/SameValueLongSupplier.java deleted file mode 100644 index ade1adaa4f6..00000000000 --- a/modules/runner/src/main/java/org/apache/ignite/internal/app/SameValueLongSupplier.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.ignite.internal.app; - -import java.util.concurrent.atomic.AtomicLong; -import java.util.function.LongSupplier; -import java.util.function.LongUnaryOperator; - -/** - * {@link LongSupplier} that fails an assertion if a wrapped supplier returns a value different - * from the one returned on the previous call. - */ -class SameValueLongSupplier implements LongSupplier { - private static final long NO_VALUE = Long.MIN_VALUE; - - private final AtomicLong previousValue = new AtomicLong(NO_VALUE); - - private final LongUnaryOperator assertingUpdate; - - SameValueLongSupplier(LongSupplier supplier) { - assertingUpdate = prev -> { - long current = supplier.getAsLong(); - - assert prev == NO_VALUE || current == prev : "Previous value was " + prev + ", but current value is " + current; - - return current; - }; - } - - @Override - public long getAsLong() { - return previousValue.updateAndGet(assertingUpdate); - } -} diff --git a/modules/runner/src/test/java/org/apache/ignite/internal/app/SameValueLongSupplierTest.java b/modules/runner/src/test/java/org/apache/ignite/internal/app/SameValueLongSupplierTest.java deleted file mode 100644 index ef3e44086f9..00000000000 --- a/modules/runner/src/test/java/org/apache/ignite/internal/app/SameValueLongSupplierTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.ignite.internal.app; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.when; - -import java.util.function.LongSupplier; -import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class SameValueLongSupplierTest extends BaseIgniteAbstractTest { - @Mock - private LongSupplier supplier; - - @InjectMocks - private SameValueLongSupplier sameValueSupplier; - - @Test - void suppliesSameValueSuccessfully() { - when(supplier.getAsLong()).thenReturn(1L, 1L, 1L); - - assertThat(sameValueSupplier.getAsLong(), is(1L)); - assertThat(sameValueSupplier.getAsLong(), is(1L)); - assertThat(sameValueSupplier.getAsLong(), is(1L)); - } - - @Test - void failsAssertionOnMismatchingValue() { - when(supplier.getAsLong()).thenReturn(2L, 3L); - - sameValueSupplier.getAsLong(); - - AssertionError error = assertThrows(AssertionError.class, () -> sameValueSupplier.getAsLong()); - assertThat(error.getMessage(), is("Previous value was 2, but current value is 3")); - } -}
