Skip to content

Instantly share code, notes, and snippets.

@masayuki038
Created May 4, 2011 18:13
Show Gist options
  • Save masayuki038/955698 to your computer and use it in GitHub Desktop.
Save masayuki038/955698 to your computer and use it in GitHub Desktop.
mungbean test
package test;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.junit.Test;
import test.entity.Bar;
import test.entity.Foo;
import mungbean.DBCollection;
import mungbean.Database;
import mungbean.Mungbean;
import mungbean.ObjectId;
import mungbean.Settings;
public class MongoTest {
@Test
public void testSaveFoo(){
Database database = new Mungbean(new Settings(), "localhost", 27017).openDatabase("test");
DBCollection<Foo> collection = database.openCollection("foo", Foo.class);
collection.save(createFoo());
}
protected Foo createFoo() {
Foo foo = new Foo();
foo.setId(1);
foo.setName("hoge");
foo.setCreated(new Date());
//foo.setBars(createBarList());
return foo;
}
protected List<Bar> createBarList() {
Bar bar1 = new Bar();
bar1.setId(2);
bar1.setList(Arrays.asList("foo", "bar", "hoge"));
Bar bar2 = new Bar();
bar2.setId(3);
bar2.setList(Arrays.asList("mungbean", "test"));
return Arrays.asList(bar1, bar2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment