/*
 * Copyright (c) www.bugull.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.bugull.mongo.crud;

import com.bugull.mongo.BuguMapper;
import com.bugull.mongo.base.BaseTest;
import com.bugull.mongo.dao.ProductDao;
import com.bugull.mongo.entity.Product;
import java.util.List;
import org.junit.Test;

/**
 *
 * @author Frank Wen(xbwen@hotmail.com)
 */
public class LazyTest extends BaseTest {
    
    @Test
    public void test(){
        connectDB();
        
        ProductDao pDao = new ProductDao();
        List<Product> list = pDao.findAll();
        //the description property is lazy, it will not contained in the result list.
        for(Product p : list){
            System.out.println("description: " + p.getDescription());
        }
        
        //you can fetch out lazy property.
        BuguMapper.fetchLazy(list);
        for(Product p : list){
            System.out.println("description: " + p.getDescription());
        }
        
        //lazy property will not play a part if only one record is return.
        Product p = pDao.findOne();
        System.out.println("description: " + p.getDescription());
        
        disconnectDB();
    }

}

@@ -1103,24 +1103,21 @@
 ription 
-property
+field
  is lazy
@@ -1571,16 +1571,17 @@
 roduct p
+1
  = pDao.
@@ -1629,32 +1629,339 @@
 scription: %22 + p
+1.getDescription());%0A        %0A        //if you query with method notReturnFields(), the field will not contained even if only one record is return.%0A        Product p2 = pDao.query().is(%22id%22, %2255f3bae5a00803537bd092c6%22).notReturnFields(%22description%22).result();%0A        System.out.println(%22description: %22 + p2
 .getDescription(

add junit test code