/*
 * Copyright 2012 Ryuji Yamashita
 *
 * 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 facebook4j.json;

public class DataObjectFactoryTest {
/*
    @Before
    public void setUp() throws Exception {
        Configuration conf = new ConfigurationBuilder().setOAuthAppId(appId).setOAuthAppSecret(appSecret)
                                                       .setJSONStoreEnabled(true)
                                                       .build();
        facebook1 = new FacebookFactory().getInstance(new OAuthAuthorization(conf));
        facebook1.setOAuthAccessToken(new AccessToken(id1.getAccessToken(), null));
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void getRawJSON() throws Exception {
        ResponseList<Post> posts = facebook1.getPosts();
        String rawJSON = DataObjectFactory.getRawJSON(posts);
        assertThat(rawJSON, is(notNullValue()));
        System.out.println(rawJSON);
    }
*/
}

@@ -624,346 +624,561 @@
 n;%0A%0A
-public class DataObjectFactoryTest %7B%0A/*%0A    @Before%0A    public void setUp() throws Exception %7B%0A        Configuration conf = new ConfigurationBuilder().setOAuthAppId(appId).setOAuthAppSecret(appSecret)%0A                                                       .setJSONStoreEnabled(true)%0A                                                       
+import facebook4j.MockFacebook;%0Aimport facebook4j.MockFacebookFactory;%0Aimport facebook4j.Page;%0Aimport facebook4j.auth.AccessToken;%0Aimport facebook4j.conf.Configuration;%0Aimport facebook4j.conf.ConfigurationBuilder;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport static org.hamcrest.CoreMatchers.*;%0Aimport static org.junit.Assert.*;%0A%0Apublic class DataObjectFactoryTest %7B%0A%0A    protected MockFacebook facebook;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        Configuration conf = new ConfigurationBuilder().setJSONStoreEnabled(true)
 .bui
@@ -1203,16 +1203,15 @@
 book
-1
  = 
-new 
+Mock
 Face
@@ -1225,51 +1225,68 @@
 tory
-().getInstance(new OAuthAuthorization(conf)
+.create(conf);%0A        facebook.setOAuthAppId(%22mock%22, %22json%22
 );%0A 
@@ -1300,17 +1300,16 @@
 facebook
-1
 .setOAut
@@ -1341,34 +1341,18 @@
 ken(
-id1.getAccessToken(), null
+%22required%22
 ));%0A
@@ -1367,13 +1367,12 @@
    @
-After
+Test
 %0A   
@@ -1388,16 +1388,18 @@
 oid 
-tearDown
+getRawJSON
 () t
@@ -1412,24 +1412,231 @@
 Exception %7B%0A
+        facebook.setMockJSON(%22mock_json/page/f4j.json%22);%0A        Page page = facebook.getPage();%0A        String rawJSON = DataObjectFactory.getRawJSON(page);%0A        assertThat(rawJSON, is(notNullValue()));%0A
     %7D%0A%0A    @
@@ -1652,34 +1652,34 @@
 public void 
-getRawJSON
+createPage
 () throws Ex
@@ -1700,32 +1700,74 @@
     
-ResponseList%3CPost%3E posts
+facebook.setMockJSON(%22mock_json/page/f4j.json%22);%0A        Page page
  = f
@@ -1777,18 +1777,16 @@
 book
-1
 .getP
-osts
+age
 ();%0A
@@ -1844,12 +1844,11 @@
 ON(p
-osts
+age
 );%0A 
@@ -1858,83 +1858,156 @@
     
-assertThat(rawJSON, is(notNullValue()));%0A        System.out.println(rawJSON
+Page actual = DataObjectFactory.createPage(rawJSON);%0A        assertThat(actual, is(page));%0A        assertThat(actual.toString(), is(page.toString())
 );%0A 
@@ -2011,13 +2011,11 @@
 ;%0A    %7D%0A
-*/
 %0A%7D%0A

test DataObjectFactory