Package mungbean

Examples of mungbean.ObjectId


@RunWith(JDaveRunner.class)
public class GridFsStorageIntegrationTest extends Specification<GridFsStorage> {
    public class WithStorage {

        public GridFsStorage create() {
            return new Mungbean(new Settings(), new Server("localhost", 27017)).openDatabase(new ObjectId().toHex()).openStorage("foobar");
        }
View Full Code Here


    protected T injectId(T doc) {
        try {
            Field field = doc.getClass().getField("_id");
            field.setAccessible(true);
            if (field.get(doc) == null) {
                field.set(doc, new ObjectId());
            }
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
        } catch (SecurityException e) {
            throw new RuntimeException(e);
View Full Code Here

@RunWith(JDaveRunner.class)
public class PojoWithIdIntegrationTest extends Specification<Database> {
    public class WithDatabase {
        public Database create() {
            return new Mungbean(new Settings(), "localhost", 27017).openDatabase(new ObjectId().toHex());
        }
View Full Code Here

@RunWith(JDaveRunner.class)
public class PojoIntegrationTest extends Specification<Database> {
    public class WithDatabase {
        public Database create() {
            return new Mungbean(new Settings(), "localhost", 27017).openDatabase(new ObjectId().toHex());
        }
View Full Code Here

@RunWith(JDaveRunner.class)
public class DeleteRequestSpec extends Specification<DBTransaction<NoResponseExpected>> {
    public class WithAny {
        public DBTransaction<NoResponseExpected> create() {
            return new DBTransaction<NoResponseExpected>(new DeleteRequest("foozbar.foo", new MapBSONCoders(), new Query().field("_id").is(new ObjectId(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }))), 123);
        }
View Full Code Here

    @Override
    protected ObjectId decode(AbstractBSONCoders bson, LittleEndianDataReader reader) {
        byte[] bytes = new byte[12];
        reader.read(bytes);
        return new ObjectId(bytes);
    }
View Full Code Here

    @Override
    protected IPersistentMap injectId(IPersistentMap doc) {
        Keyword keyword = Keyword.intern(Symbol.intern("_id"));
        if (!doc.containsKey(keyword)) {
            return doc.assoc(keyword, new ObjectId());
        }
        return doc;
    }
View Full Code Here

    @Override
    public Object get(Object key) {
        String keyString = String.valueOf(key);
        Object o = NativeObject.getProperty(n, keyString);
        if (keyString.equals("_id") && o instanceof String) {
            return new ObjectId((String) o);
        }
        return wrapRhinoToJava(o);
    }
View Full Code Here

    }

    @Override
    protected ScriptableObject injectId(ScriptableObject doc) {
        if (!NativeObject.hasProperty(doc, "_id")) {
            NativeObject.putProperty(doc, "_id", new ObjectId());
        }
        return doc;
    }
View Full Code Here

TOP

Related Classes of mungbean.ObjectId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.