Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions parquet-avro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@
import org.apache.avro.Schema;
import org.apache.avro.SchemaBuilder;
import org.apache.avro.specific.SpecificData;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareForTest(AvroRecordConverter.class)
public class TestAvroRecordConverter {

private MockedStatic<AvroRecordConverter> avroRecordConverterMock;

@Before
public void setup() {
// Default to calling real methods unless overridden in specific test
PowerMockito.mockStatic(AvroRecordConverter.class, CALLS_REAL_METHODS);
avroRecordConverterMock = Mockito.mockStatic(AvroRecordConverter.class, CALLS_REAL_METHODS);
}

@After
public void tearDown() {
avroRecordConverterMock.close();
}

@Test
Expand Down Expand Up @@ -86,7 +89,7 @@ public void testModelForGenericRecord() {
// Test logical type support for older Avro versions
@Test
public void testModelForSpecificRecordWithLogicalTypesWithDeprecatedAvro1_8() {
Mockito.when(AvroRecordConverter.getRuntimeAvroVersion()).thenReturn("1.8.2");
avroRecordConverterMock.when(AvroRecordConverter::getRuntimeAvroVersion).thenReturn("1.8.2");

// Test that model is generated correctly when record contains both top-level and nested logical types
SpecificData model = AvroRecordConverter.getModelForSchema(LogicalTypesTestDeprecated.SCHEMA$);
Expand All @@ -108,7 +111,7 @@ public void testModelForSpecificRecordWithLogicalTypesWithDeprecatedAvro1_8() {

@Test
public void testModelForSpecificRecordWithLogicalTypesWithDeprecatedAvro1_7() {
Mockito.when(AvroRecordConverter.getRuntimeAvroVersion()).thenReturn("1.7.7");
avroRecordConverterMock.when(AvroRecordConverter::getRuntimeAvroVersion).thenReturn("1.7.7");

// Test that model is generated correctly
final SpecificData model = AvroRecordConverter.getModelForSchema(LogicalTypesTestDeprecated.SCHEMA$);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,27 @@
import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName;
import org.apache.parquet.schema.Type;
import org.apache.parquet.schema.Types;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareForTest(AvroRecordConverter.class)
public class TestAvroSchemaConverter {

private static final Configuration NEW_BEHAVIOR = new Configuration(false);
private MockedStatic<AvroRecordConverter> avroRecordConverterMock;

@Before
public void setupMockito() {
PowerMockito.mockStatic(AvroRecordConverter.class, CALLS_REAL_METHODS);
avroRecordConverterMock = Mockito.mockStatic(AvroRecordConverter.class, CALLS_REAL_METHODS);
}

@After
public void tearDown() {
avroRecordConverterMock.close();
}

@BeforeClass
Expand Down Expand Up @@ -706,7 +708,9 @@ public void testTimestampMillisType() throws Exception {

// Test that conversions for timestamp types only use APIs that are available in the user's Avro version
for (String avroVersion : ImmutableSet.of("1.7.0", "1.8.0", "1.9.0", "1.10.0", "1.11.0")) {
Mockito.when(AvroRecordConverter.getRuntimeAvroVersion()).thenReturn(avroVersion);
avroRecordConverterMock
.when(AvroRecordConverter::getRuntimeAvroVersion)
.thenReturn(avroVersion);
final Schema converted = new AvroSchemaConverter()
.convert(Types.buildMessage()
.addField(Types.primitive(INT64, Type.Repetition.REQUIRED)
Expand Down Expand Up @@ -792,7 +796,9 @@ public void testTimestampMicrosType() throws Exception {

// Test that conversions for timestamp types only use APIs that are available in the user's Avro version
for (String avroVersion : ImmutableSet.of("1.7.0", "1.8.0", "1.9.0", "1.10.0", "1.11.0")) {
Mockito.when(AvroRecordConverter.getRuntimeAvroVersion()).thenReturn(avroVersion);
avroRecordConverterMock
.when(AvroRecordConverter::getRuntimeAvroVersion)
.thenReturn(avroVersion);
final Schema converted = new AvroSchemaConverter()
.convert(Types.buildMessage()
.addField(Types.primitive(INT64, Type.Repetition.REQUIRED)
Expand Down
8 changes: 7 additions & 1 deletion parquet-column/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -100,6 +100,12 @@
<version>${commons-lang3.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reasons I don't understand this started getting flagged as an undeclared dependency. This seems correct, but I don't know why it wasn't getting flagged before.

<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
2 changes: 1 addition & 1 deletion parquet-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyObject;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -401,6 +401,6 @@ private void validateToByteBufferIsInternal(Supplier<BytesInput> factory) {
Consumer<ByteBuffer> callbackMock = Mockito.mock(Consumer.class);
factory.get().toByteBuffer(allocatorMock, callbackMock);
verify(allocatorMock, never()).allocate(anyInt());
verify(callbackMock, never()).accept(anyObject());
verify(callbackMock, never()).accept(any());
}
}
8 changes: 7 additions & 1 deletion parquet-hadoop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -191,6 +191,12 @@
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -732,7 +732,7 @@ public void testColumnWithoutDictionary() throws Exception {
"Should never drop block using plain encoding",
canDrop(notEq(plain, nElements + 10), ccmd, dictionaryStore));

verifyZeroInteractions(dictionaryStore);
verifyNoInteractions(dictionaryStore);
}

@Test
Expand All @@ -758,7 +758,7 @@ public void testColumnWithDictionaryAndPlainEncodings() throws Exception {
"Should never drop block using plain encoding",
canDrop(notEq(plain, nElements + 10), ccmd, dictionaryStore));

verifyZeroInteractions(dictionaryStore);
verifyNoInteractions(dictionaryStore);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Matchers.same;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.inOrder;

import java.io.ByteArrayInputStream;
Expand Down
6 changes: 6 additions & 0 deletions parquet-thrift/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
<version>${guava.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.twitter.elephantbird</groupId>
<artifactId>elephant-bird-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
*/
package org.apache.parquet.thrift.projection;

import static org.easymock.EasyMock.createMockBuilder;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -112,23 +113,18 @@ public void testIsStrict() {

@Test
public void testWarnWhenMultiplePatternsMatch() {
StrictFieldProjectionFilter filter = createMockBuilder(StrictFieldProjectionFilter.class)
.withConstructor(Arrays.asList("a.b.c.{x_average,z_average}", "a.*_average"))
.addMockedMethod("warn")
.createMock();
StrictFieldProjectionFilter filter = spy(new StrictFieldProjectionFilter(
Arrays.asList("a.b.c.{x_average,z_average}", "a.*_average")));
doNothing().when(filter).warn(anyString());

// set expectations
filter.warn("Field path: 'a.b.c.x_average' matched more than one glob path pattern. "
assertMatches(filter, "a.b.c.x_average", "a.b.c.z_average", "a.other.w_average");
assertDoesNotMatch(filter, "hello");

verify(filter).warn("Field path: 'a.b.c.x_average' matched more than one glob path pattern. "
+ "First match: 'a.b.c.{x_average,z_average}' (when expanded to 'a.b.c.x_average') "
+ "second match:'a.*_average' (when expanded to 'a.*_average')");
filter.warn("Field path: 'a.b.c.z_average' matched more than one glob path pattern. "
verify(filter).warn("Field path: 'a.b.c.z_average' matched more than one glob path pattern. "
+ "First match: 'a.b.c.{x_average,z_average}' (when expanded to 'a.b.c.z_average') "
+ "second match:'a.*_average' (when expanded to 'a.*_average')");

replay(filter);

assertMatches(filter, "a.b.c.x_average", "a.b.c.z_average", "a.other.w_average");
assertDoesNotMatch(filter, "hello");
verify(filter);
}
}
9 changes: 1 addition & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@
<avro.version>1.11.5</avro.version>
<guava.version>33.5.0-jre</guava.version>
<brotli-codec.version>0.1.1</brotli-codec.version>
<mockito.version>1.10.19</mockito.version>
<powermock.version>2.0.9</powermock.version>
<mockito.version>5.21.0</mockito.version>
<net.openhft.version>0.27ea0</net.openhft.version>
<exec-maven-plugin.version>3.5.0</exec-maven-plugin.version>
<jts.version>1.20.0</jts.version>
Expand Down Expand Up @@ -163,12 +162,6 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down