Skip to content

Commit 28bbce1

Browse files
author
Ryan
committed
added tests for new getType with default methods.
1 parent bae4822 commit 28bbce1

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

src/test/com/mongodb/BasicDBObjectTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,30 @@ public class BasicDBObjectTest extends TestCase {
2828
@Test(groups = {"basic"})
2929
public void testGetObjectId() {
3030
final ObjectId objId = ObjectId.get();
31-
3231
BasicDBObject doc = new BasicDBObject( "foo" , objId);
3332
assert( doc.getObjectId( "foo" ).equals( objId ) );
33+
}
34+
35+
@Test(groups = {"basic"})
36+
public void testGetLongWithDefault() {
37+
final long test = 100;
38+
BasicDBObject doc = new BasicDBObject( "foo" , test);
39+
assert( doc.getLong( "foo", 0l ) == test );
40+
assert( doc.getLong( "bar", 0l ) == 0l );
41+
}
3442

43+
@Test(groups = {"basic"})
44+
public void testGetDoubleWithDefault() {
45+
BasicDBObject doc = new BasicDBObject( "foo" , Double.MAX_VALUE);
46+
assert( doc.getDouble( "foo", (double)0 ) == Double.MAX_VALUE);
47+
assert( doc.getDouble( "bar", Double.MIN_VALUE ) == Double.MIN_VALUE);
48+
}
49+
50+
@Test(groups = {"basic"})
51+
public void testGetStringWithDefault() {
52+
BasicDBObject doc = new BasicDBObject( "foo" , "badmf");
53+
assert( doc.getString( "foo", "ID" ).equals("badmf"));
54+
assert( doc.getString( "bar", "DEFAULT" ).equals("DEFAULT") );
3555
}
3656

3757
@Test(groups = {"basic"})

0 commit comments

Comments
 (0)