/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
- /*
- * Copyright (c) 2010 Tonic Solutions LLC.
- *
- * http://www.nimbits.com
- *
- *
- * 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
- *
- * http://www.gnu.org/licenses/gpl.html
- *
- * 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.
- */
- import com.google.gson.Gson;
- import com.nimbits.client.model.common.CommonFactoryLocator;
- import com.nimbits.client.model.user.User;
- import com.nimbits.client.model.user.UserModel;
- import com.nimbits.server.gson.GsonFactory;
- import com.nimbits.server.user.UserModelFactory;
- import org.junit.Test;
- import static org.junit.Assert.assertNotNull;
- /**
- * Created by bsautner
- * User: benjamin
- * Date: 8/6/11
- * Time: 10:11 AM
- */
- public class TestGson {
- Gson gson = GsonFactory.getInstance();
- @Test
- public void testConvertUser() {
- User u = UserModelFactory.createUserModel(0);
- u.setEmail(CommonFactoryLocator.getInstance().createEmailAddress("bsautner@gmail.com"));
- String json = gson.toJson(u);
- User u2 = gson.fromJson(json, UserModel.class);
- assertNotNull(u2);
- }
- @Test
- public void testGetType() {
- User u = UserModelFactory.createUserModel(0);
- String json = gson.toJson(u);
- }
- }