Skip to content

Commit

Permalink
HDDS-11963. Address review comments
Browse files Browse the repository at this point in the history
Change-Id: I9ebc447eb9b60caa69e140b06fe899c58dd712a3
  • Loading branch information
swamirishi committed Dec 19, 2024
1 parent bfa7618 commit ded3450
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,15 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.ozone.upgrade.LayoutVersionManager;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

class TestVersionExtractor {

private static Stream<Arguments> futureClientVersionValues() {
return IntStream.range(1, 10).mapToObj(delta -> Arguments.of(ClientVersion.CURRENT_VERSION + delta));
}

@ParameterizedTest
@EnumSource(OMLayoutFeature.class)
void testLayoutVersionExtractor(OMLayoutFeature layoutVersionValue) throws OMException {
Expand All @@ -63,10 +55,10 @@ void testClientVersionExtractor(ClientVersion expectedClientVersion) {
}

@ParameterizedTest
@MethodSource("futureClientVersionValues")
void testClientVersionExtractorForFutureValues(int clientVersion) {
@ValueSource(ints = {1, 2, 5, 10, 1000, 10000})
void testClientVersionExtractorForFutureValues(int futureVersion) {
OMRequest request = mock(OMRequest.class);
when(request.getVersion()).thenReturn(clientVersion);
when(request.getVersion()).thenReturn(ClientVersion.CURRENT_VERSION + futureVersion);
Versioned version = VersionExtractor.CLIENT_VERSION_EXTRACTOR.extractVersion(request, null);
assertEquals(ClientVersion.FUTURE_VERSION, version);
assertEquals(ClientVersion.class, VersionExtractor.CLIENT_VERSION_EXTRACTOR.getVersionClass());
Expand Down

0 comments on commit ded3450

Please sign in to comment.