belugabehr commented on a change in pull request #1169: URL: https://github.com/apache/hive/pull/1169#discussion_r455834912
########## File path: beeline/src/test/org/apache/hive/beeline/TestJSONFileOutputFormat.java ########## @@ -0,0 +1,121 @@ +/* + * 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.hive.beeline; + +import static org.mockito.ArgumentMatchers.anyInt; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Types; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import static org.mockito.Mockito.when; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import static org.mockito.Mockito.mock; + +public class TestJSONFileOutputFormat { + + public class BeelineMock extends BeeLine { Review comment: Please just use Mockito to capture the argument instead of making a mock manually like this. https://www.baeldung.com/mockito-void-methods ########## File path: beeline/src/test/org/apache/hive/beeline/TestJSONFileOutputFormat.java ########## @@ -0,0 +1,121 @@ +/* + * 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.hive.beeline; + +import static org.mockito.ArgumentMatchers.anyInt; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Types; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import static org.mockito.Mockito.when; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import static org.mockito.Mockito.mock; + +public class TestJSONFileOutputFormat { + + public class BeelineMock extends BeeLine { + + private String output; + + @Override + final void output(String out) { + output = out; + super.output(out); + } + + private String getOutput() { + return output; + } + } + + private final String[][] mockRowData = { + {"aaa","1","3.14","true","","SGVsbG8sIFdvcmxkIQ"}, + {"bbb","2","2.718","false","Null","RWFzdGVyCgllZ2cu"} + }; + private BeelineMock mockBeeline; + private ResultSet mockResultSet; + private TestBufferedRows.MockRow mockRow; + + /** + * Test of print method, of class TableOutputFormat. There was an empty extra column after the + * last one. + */ + @Test + public final void testPrint() throws SQLException { + setupMockData(); Review comment: Let's make this a bit more JUNIT-ish. Please use the `@BeforeClass` annotation on the `setupMockData()` instead of calling like this manually ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
