/** Test method for {@link com.twitterapime.model.DefaultEntity#getInt(java.lang.String)}. */ public void testGetInt() { DefaultEntity d = new DefaultEntity(dataSample); assertEquals(7, d.getInt(KEY_INT)); assertEquals(Integer.MIN_VALUE, d.getInt("WHATEVER_INT")); // try { d.getInt(KEY_STRING); fail(); } catch (ClassCastException e) { } catch (Exception e) { fail(); } }
/** Test method for {@link com.twitterapime.model.DefaultEntity#getDate(java.lang.String)}. */ public void testGetDate() { DefaultEntity d = new DefaultEntity(dataSample); assertEquals(new Date(now), d.getDate(KEY_DATE)); assertNull(d.getDate("WHATEVER_DATE")); // try { d.getDate(KEY_INT); fail(); } catch (ClassCastException e) { } catch (Exception e) { fail(); } }
/** Test method for {@link com.twitterapime.model.DefaultEntity#getArray(java.lang.String)}. */ public void testGetArray() { DefaultEntity d = new DefaultEntity(dataSample); assertEquals(3, d.getArray(KEY_ARRAY).length); assertSame(dataSample.get(KEY_ARRAY), d.getArray(KEY_ARRAY)); assertNull(d.getArray("WHATEVER_ARRAY")); // try { d.getArray(KEY_INT); fail(); } catch (ClassCastException e) { } catch (Exception e) { fail(); } }
/** Test method for {@link com.twitterapime.model.DefaultEntity#getLong(java.lang.String)}. */ public void testGetLong() { DefaultEntity d = new DefaultEntity(dataSample); assertEquals(14, d.getLong(KEY_LONG)); assertEquals(Long.MIN_VALUE, d.getLong("WHATEVER_LONG")); assertEquals(now, d.getLong(KEY_DATE)); // try { d.getLong(KEY_STRING); fail(); } catch (ClassCastException e) { } catch (Exception e) { fail(); } }
/** Test method for {@link com.twitterapime.model.DefaultEntity#getObject(java.lang.String)}. */ public void testGetObject() { DefaultEntity d = new DefaultEntity(dataSample); assertEquals(this, d.getObject(KEY_OBJECT)); assertNull(d.getObject("WHATEVER_OBJECT")); assertTrue(d.getObject(KEY_ARRAY) instanceof String[]); assertTrue(d.getObject(KEY_DATE) instanceof Date); assertTrue(d.getObject(KEY_INT) instanceof Integer); assertTrue(d.getObject(KEY_LONG) instanceof Long); assertTrue(d.getObject(KEY_STRING) instanceof String); }
/** Test method for {@link com.twitterapime.model.DefaultEntity#equals(java.lang.Object)}. */ public void testEqualsObject() { DefaultEntity d = new DefaultEntity(dataSample); assertTrue(d.equals(d)); assertFalse(d.equals(null)); DefaultEntity dc = new DefaultEntity(dataSample); assertTrue(d.equals(dc)); dc.setData((Hashtable) null); assertFalse(d.equals(dc)); }
/** Test method for {@link com.twitterapime.model.DefaultEntity#getString(java.lang.String)}. */ public void testGetString() { DefaultEntity d = new DefaultEntity(dataSample); assertEquals("Twitter API ME", d.getString(KEY_STRING)); assertNull(d.getString("WHATEVER_STRING")); // assertEquals("7", d.getString(KEY_INT)); assertEquals("14", d.getString(KEY_LONG)); assertEquals(new Date(now).toString(), d.getString(KEY_DATE)); }
/** Test method for {@link com.twitterapime.model.DefaultEntity#setData(java.util.Hashtable)}. */ public void testSetData() { DefaultEntity d = new DefaultEntity(); d.setData(dataSample); assertTrue(dataSample.equals(d.data)); d.setData((Hashtable) null); assertNotNull(d.data); assertFalse(dataSample.equals(d.data)); // DefaultEntity d1 = new DefaultEntity(); d1.setData(d); assertTrue(d1.equals(d)); }
/** Test method for {@link com.twitterapime.model.DefaultEntity#hashCode()}. */ public void testHashCode() { DefaultEntity d = new DefaultEntity(dataSample); assertEquals(d.toString().hashCode(), d.hashCode()); DefaultEntity df = new DefaultEntity(); assertTrue(d.toString().hashCode() != df.hashCode()); }
/** Test method for {@link com.twitterapime.model.DefaultEntity#size()}. */ public void testSize() { DefaultEntity d = new DefaultEntity(dataSample); assertEquals(dataSample.size(), d.size()); d = new DefaultEntity(null); assertEquals(0, d.size()); }