PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-tds/test/TestGson.java

http://nimbits-server.googlecode.com/
Java | 53 lines | 24 code | 11 blank | 18 comment | 0 complexity | c5482cecfc5ea19df113d1d49249eb32 MD5 | raw file
 1/*
 2 * Copyright (c) 2010 Tonic Solutions LLC.
 3 *
 4 * http://www.nimbits.com
 5 *
 6 *
 7 * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
 8 *
 9 * http://www.gnu.org/licenses/gpl.html
10 *
11 * 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.
12 */
13
14import com.google.gson.Gson;
15import com.nimbits.client.model.common.CommonFactoryLocator;
16import com.nimbits.client.model.user.User;
17import com.nimbits.client.model.user.UserModel;
18import com.nimbits.server.gson.GsonFactory;
19import com.nimbits.server.user.UserModelFactory;
20import org.junit.Test;
21
22import static org.junit.Assert.assertNotNull;
23
24/**
25 * Created by bsautner
26 * User: benjamin
27 * Date: 8/6/11
28 * Time: 10:11 AM
29 */
30public class TestGson {
31    Gson gson = GsonFactory.getInstance();
32
33    @Test
34    public void testConvertUser() {
35
36        User u = UserModelFactory.createUserModel(0);
37        u.setEmail(CommonFactoryLocator.getInstance().createEmailAddress("bsautner@gmail.com"));
38        String json = gson.toJson(u);
39        User u2 = gson.fromJson(json, UserModel.class);
40        assertNotNull(u2);
41
42
43    }
44
45    @Test
46    public void testGetType() {
47        User u = UserModelFactory.createUserModel(0);
48        String json = gson.toJson(u);
49
50
51    }
52
53}