Skip to content

Commit

Permalink
spotlessApply
Browse files Browse the repository at this point in the history
Signed-off-by: Atanas Atanasov <[email protected]>
  • Loading branch information
ata-nas committed Dec 9, 2024
1 parent 5f08f5c commit 641957e
Showing 1 changed file with 67 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ class BlockAsLocalFileReaderTest {
@BeforeEach
void setUp() throws IOException {
blockNodeContext = TestConfigUtil.getTestBlockNodeContext(
Map.of(PERSISTENCE_STORAGE_LIVE_ROOT_PATH_KEY, testLiveRootPath.toString()));
Map.of(PERSISTENCE_STORAGE_LIVE_ROOT_PATH_KEY, testLiveRootPath.toString()));
testConfig = blockNodeContext.configuration().getConfigData(PersistenceStorageConfig.class);

final String testConfigLiveRootPath = testConfig.liveRootPath();
assertThat(testConfigLiveRootPath).isEqualTo(testLiveRootPath.toString());

blockAsLocalFileResolverMock = spy(BlockAsLocalFilePathResolver.of(testLiveRootPath));
blockAsLocalFileWriterMock = spy(
BlockAsLocalFileWriter.of(blockNodeContext, blockAsLocalFileResolverMock));
blockAsLocalFileWriterMock = spy(BlockAsLocalFileWriter.of(blockNodeContext, blockAsLocalFileResolverMock));
toTest = BlockAsLocalFileReader.of(blockAsLocalFileResolverMock);
}

Expand All @@ -82,34 +81,34 @@ void setUp() throws IOException {
@MethodSource("validBlockNumbers")
void testSuccessfulBlockRead(final long blockNumber) throws IOException, ParseException {
final List<BlockItemUnparsed> blockItemUnparsed =
PersistTestUtils.generateBlockItemsUnparsedForWithBlockNumber(blockNumber);
PersistTestUtils.generateBlockItemsUnparsedForWithBlockNumber(blockNumber);
final Optional<List<BlockItemUnparsed>> written = blockAsLocalFileWriterMock.write(blockItemUnparsed);

assertThat(written).isNotNull().isPresent();

final Optional<BlockUnparsed> actual = toTest.read(blockNumber);
assertThat(actual)
.isNotNull()
.isPresent()
.get(InstanceOfAssertFactories.type(BlockUnparsed.class))
.isNotNull()
.isExactlyInstanceOf(BlockUnparsed.class)
.returns(blockNumber, from(blockUnparsed -> {
try {
return BlockHeader.PROTOBUF
.parse(Objects.requireNonNull(
blockUnparsed.blockItems().getFirst().blockHeader()))
.number();
} catch (final ParseException e) {
throw new RuntimeException(e);
}
}))
.extracting(BlockUnparsed::blockItems)
.asList()
.isNotNull()
.isNotEmpty()
.hasSize(blockItemUnparsed.size())
.containsExactlyElementsOf(blockItemUnparsed);
.isNotNull()
.isPresent()
.get(InstanceOfAssertFactories.type(BlockUnparsed.class))
.isNotNull()
.isExactlyInstanceOf(BlockUnparsed.class)
.returns(blockNumber, from(blockUnparsed -> {
try {
return BlockHeader.PROTOBUF
.parse(Objects.requireNonNull(
blockUnparsed.blockItems().getFirst().blockHeader()))
.number();
} catch (final ParseException e) {
throw new RuntimeException(e);
}
}))
.extracting(BlockUnparsed::blockItems)
.asList()
.isNotNull()
.isNotEmpty()
.hasSize(blockItemUnparsed.size())
.containsExactlyElementsOf(blockItemUnparsed);
}

/**
Expand All @@ -132,28 +131,28 @@ void testInvalidBlockNumber(final long toRead) {
*/
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));
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));
}

/**
Expand All @@ -163,26 +162,26 @@ public static Stream<Arguments> validBlockNumbers() {
*/
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));
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));
}
}

0 comments on commit 641957e

Please sign in to comment.