-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests for no-op path resolver
Signed-off-by: Atanas Atanasov <[email protected]>
- Loading branch information
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...test/java/com/hedera/block/server/persistence/storage/path/NoOpBlockPathResolverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed 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 com.hedera.block.server.persistence.storage.path; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.nio.file.Path; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
/** | ||
* Tests for the {@link NoOpBlockPathResolver} class. | ||
*/ | ||
class NoOpBlockPathResolverTest { | ||
private NoOpBlockPathResolver toTest; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
toTest = NoOpBlockPathResolver.newInstance(); | ||
} | ||
|
||
/** | ||
* This test aims to verify that the | ||
* {@link NoOpBlockPathResolver#resolvePathToBlock(long)} correctly resolves | ||
* the path to a block by a given number. The no-op resolver does nothing, | ||
* always returns null and has no preconditions check. | ||
* | ||
* @param toResolve parameterized, block number | ||
*/ | ||
@ParameterizedTest | ||
@MethodSource({"validBlockNumbers", "invalidBlockNumbers"}) | ||
void testSuccessfulPathResolution(final long toResolve) { | ||
final Path actual = toTest.resolvePathToBlock(toResolve); | ||
// we always expect null, no preconditions as well | ||
assertThat(actual).isNull(); | ||
} | ||
|
||
/** | ||
* Some valid block numbers. | ||
* | ||
* @return a stream of valid block numbers | ||
*/ | ||
public static Stream<Arguments> validBlockNumbers() { | ||
return Stream.of( | ||
Arguments.of(0L), | ||
Arguments.of(1L), | ||
Arguments.of(2L), | ||
Arguments.of(10L), | ||
Arguments.of(100L), | ||
Arguments.of(1_000L), | ||
Arguments.of(10_000L), | ||
Arguments.of(100_000L), | ||
Arguments.of(1_000_000L), | ||
Arguments.of(10_000_000L), | ||
Arguments.of(100_000_000L), | ||
Arguments.of(1_000_000_000L), | ||
Arguments.of(10_000_000_000L), | ||
Arguments.of(100_000_000_000L), | ||
Arguments.of(1_000_000_000_000L), | ||
Arguments.of(10_000_000_000_000L), | ||
Arguments.of(100_000_000_000_000L), | ||
Arguments.of(1_000_000_000_000_000L), | ||
Arguments.of(10_000_000_000_000_000L), | ||
Arguments.of(100_000_000_000_000_000L), | ||
Arguments.of(1_000_000_000_000_000_000L), | ||
Arguments.of(Long.MAX_VALUE)); | ||
} | ||
|
||
/** | ||
* Some invalid block numbers. | ||
* | ||
* @return a stream of invalid block numbers | ||
*/ | ||
public static Stream<Arguments> invalidBlockNumbers() { | ||
return Stream.of( | ||
Arguments.of(-1L), | ||
Arguments.of(-2L), | ||
Arguments.of(-10L), | ||
Arguments.of(-100L), | ||
Arguments.of(-1_000L), | ||
Arguments.of(-10_000L), | ||
Arguments.of(-100_000L), | ||
Arguments.of(-1_000_000L), | ||
Arguments.of(-10_000_000L), | ||
Arguments.of(-100_000_000L), | ||
Arguments.of(-1_000_000_000L), | ||
Arguments.of(-10_000_000_000L), | ||
Arguments.of(-100_000_000_000L), | ||
Arguments.of(-1_000_000_000_000L), | ||
Arguments.of(-10_000_000_000_000L), | ||
Arguments.of(-100_000_000_000_000L), | ||
Arguments.of(-1_000_000_000_000_000L), | ||
Arguments.of(-10_000_000_000_000_000L), | ||
Arguments.of(-100_000_000_000_000_000L), | ||
Arguments.of(-1_000_000_000_000_000_000L), | ||
Arguments.of(Long.MIN_VALUE)); | ||
} | ||
} |