@Test public void testGetAll() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); List<Object> list = r.getAll(); Assert.assertEquals(INT_CONST, ((Integer) list.get(0)).intValue()); Assert.assertEquals(LONG_CONST, ((Long) list.get(1)).longValue()); Assert.assertEquals(DOUBLE_CONST, ((Double) list.get(2)).doubleValue(), 0); Assert.assertEquals(STRING_CONST, (String) list.get(3)); }
@Test public void testGetWritable() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()).getWritable(); Assert.assertEquals(INT_CONST, ((Integer) r.get(0)).intValue()); Assert.assertEquals(LONG_CONST, ((Long) r.get(1)).longValue()); Assert.assertEquals(DOUBLE_CONST, ((Double) r.get(2)).doubleValue(), 0); Assert.assertEquals(STRING_CONST, (String) r.get(3)); Assert.assertEquals("org.apache.hive.hcatalog.data.DefaultHCatRecord", r.getClass().getName()); }
@Test public void testGet() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); Assert.assertEquals(INT_CONST, ((Integer) r.get(0)).intValue()); Assert.assertEquals(LONG_CONST, ((Long) r.get(1)).longValue()); Assert.assertEquals(DOUBLE_CONST, ((Double) r.get(2)).doubleValue(), 0); Assert.assertEquals(STRING_CONST, (String) r.get(3)); }
@Test public void testCopy() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); boolean sawException = false; try { r.copy(null); } catch (UnsupportedOperationException uoe) { sawException = true; } Assert.assertTrue(sawException); }
@Test public void testSize() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); Assert.assertEquals(4, r.size()); }
@Test public void testReadFields() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); boolean sawException = false; try { r.readFields(null); } catch (UnsupportedOperationException uoe) { sawException = true; } Assert.assertTrue(sawException); }
@Test public void testWrite() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); boolean sawException = false; try { r.write(null); } catch (UnsupportedOperationException uoe) { sawException = true; } Assert.assertTrue(sawException); }
@Test public void testRemove() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); boolean sawException = false; try { r.remove(0); } catch (UnsupportedOperationException uoe) { sawException = true; } Assert.assertTrue(sawException); }
@Test public void testSet() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); boolean sawException = false; try { r.set(3, "Mary had a little lamb"); } catch (UnsupportedOperationException uoe) { sawException = true; } Assert.assertTrue(sawException); }
@Test public void testSetWithName() throws Exception { HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()); boolean sawException = false; try { r.set("fred", null, "bob"); } catch (UnsupportedOperationException uoe) { sawException = true; } Assert.assertTrue(sawException); }
@Test public void testGetWithName() throws Exception { TypeInfo ti = getTypeInfo(); HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector(ti)); HCatSchema schema = HCatSchemaUtils.getHCatSchema(ti) .get(0).getStructSubSchema(); Assert.assertEquals(INT_CONST, ((Integer) r.get("an_int", schema)).intValue()); Assert.assertEquals(LONG_CONST, ((Long) r.get("a_long", schema)).longValue()); Assert.assertEquals(DOUBLE_CONST, ((Double) r.get("a_double", schema)).doubleValue(), 0); Assert.assertEquals(STRING_CONST, (String) r.get("a_string", schema)); }