@@ -0,0 +1,2386 @@
+/*%0A * Yet Another UserAgent Analyzer%0A * Copyright (C) 2013-2018 Niels Basjes%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * https://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage nl.basjes.parse.useragent.hive;%0A%0Aimport org.apache.hadoop.hive.ql.exec.UDFArgumentException;%0Aimport org.apache.hadoop.hive.ql.metadata.HiveException;%0Aimport org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject;%0Aimport org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject;%0Aimport org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;%0Aimport org.apache.hadoop.hive.serde2.objectinspector.StandardStructObjectInspector;%0Aimport org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0A%0Aimport static org.junit.Assert.assertNull;%0A%0Apublic class TestParseUserAgentBadInput %7B%0A%0A    @Rule%0A    public final transient ExpectedException expectedEx = ExpectedException.none();%0A%0A    private ParseUserAgent parseUserAgent = new ParseUserAgent();%0A%0A    @Test%0A    public void testBadInputType() throws HiveException %7B%0A        expectedEx.expect(UDFArgumentException.class);%0A        expectedEx.expectMessage(%22The argument must be a string%22);%0A        StandardStructObjectInspector resultInspector = (StandardStructObjectInspector) parseUserAgent%0A            .initialize(new ObjectInspector%5B%5D%7B%0A                PrimitiveObjectInspectorFactory.javaBooleanObjectInspector%0A            %7D);%0A    %7D%0A%0A    @Test%0A    public void testBadInputNull() throws HiveException %7B%0A        StandardStructObjectInspector resultInspector = (StandardStructObjectInspector) parseUserAgent%0A            .initialize(new ObjectInspector%5B%5D%7B%0A                PrimitiveObjectInspectorFactory.javaStringObjectInspector%0A            %7D);%0A%0A        assertNull(parseUserAgent.evaluate(new DeferredObject%5B%5D%7Bnew DeferredJavaObject(null)%7D));%0A    %7D%0A%0A%0A%0A%7D%0A

Improve code coverage for Hive UDF