Home | History | Annotate | Download | only in mock
      1 /*
      2  * Copyright 2017 Google Inc.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of 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,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.example.android.wearable.wear.messaging.mock;
     17 
     18 import android.support.annotation.NonNull;
     19 import com.example.android.wearable.wear.messaging.R;
     20 import com.example.android.wearable.wear.messaging.model.Profile;
     21 import java.util.Arrays;
     22 import java.util.List;
     23 
     24 /** Helper methods to generate mock objects. */
     25 public class MockObjectGenerator {
     26 
     27     /**
     28      * Returns a list of mocked contacts.
     29      *
     30      * @return a {@link List<Profile>} that can be used to mock out a user's contact list.
     31      */
     32     public static List<Profile> generateDefaultContacts() {
     33 
     34         Profile paul = buildProfile("1234", "Paul Saxman", "PaulSaxman (at) email.com", R.drawable.paul);
     35 
     36         Profile ben =
     37                 buildProfile("2345", "Benjamin Baxter", "benjaminbaxter (at) email.com", R.drawable.ben);
     38 
     39         Profile jeremy =
     40                 buildProfile("3456", "Jeremy Walker", "jeremywalker (at) email.com", R.drawable.jeremy);
     41 
     42         Profile jennifer =
     43                 buildProfile(
     44                         "4567", "Jennifer Smith", "jennifersmith (at) email.com", R.drawable.jennifer);
     45 
     46         Profile android =
     47                 buildProfile("5678", "Android", "android (at) email.com", R.drawable.android_logo);
     48 
     49         Profile lisa =
     50                 buildProfile("6789", "Lisa Williams", "lisawilliams (at) email.com", R.drawable.lisa);
     51 
     52         Profile jane = buildProfile("7890", "Jane Doe", "janedoe (at) email.com", R.drawable.jane);
     53 
     54         return Arrays.asList(paul, jennifer, ben, lisa, jane, jeremy, android);
     55     }
     56 
     57     @NonNull
     58     private static Profile buildProfile(String id, String name, String email, int profileResource) {
     59         return new Profile.Builder()
     60                 .id(id)
     61                 .name(name)
     62                 .email(email)
     63                 .profileImageResource(profileResource)
     64                 .lastUpdatedTime(System.currentTimeMillis())
     65                 .build();
     66     }
     67 }
     68