Home | History | Annotate | Download | only in client
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
      5  * use this file except in compliance with the License. You may obtain a copy of
      6  * the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     13  * License for the specific language governing permissions and limitations under
     14  * the License.
     15  */
     16 package com.example.android.samplesync.client;
     17 
     18 import com.example.android.samplesync.client.User;
     19 
     20 import junit.framework.TestCase;
     21 
     22 import org.json.JSONObject;
     23 
     24 public class UserTest extends TestCase {
     25 
     26     @SmallTest
     27     public void testConstructor() throws Exception {
     28         User user =
     29             new User("mjoshi", "Megha", "Joshi", "1-650-335-5681", "1-650-111-5681",
     30                 "1-650-222-5681", "test (at) google.com", false, 1);
     31         assertEquals("Megha", user.getFirstName());
     32         assertEquals("Joshi", user.getLastName());
     33         assertEquals("mjoshi", user.getUserName());
     34         assertEquals(1, user.getUserId());
     35         assertEquals("1-650-335-5681", user.getCellPhone());
     36         assertEquals(false, user.isDeleted());
     37     }
     38 
     39     @SmallTest
     40     public void testValueOf() throws Exception {
     41         JSONObject jsonObj = new JSONObject();
     42         jsonObj.put("u", "mjoshi");
     43         jsonObj.put("f", "Megha");
     44         jsonObj.put("l", "Joshi");
     45         jsonObj.put("i", 1);
     46         User user = User.valueOf(jsonObj);
     47         assertEquals("Megha", user.getFirstName());
     48         assertEquals("Joshi", user.getLastName());
     49         assertEquals("mjoshi", user.getUserName());
     50         assertEquals(1, user.getUserId());
     51     }
     52 }
     53