14
14
15
15
package com .google .firebase .installations .local ;
16
16
17
- import static com .google .common .truth .Truth .assertWithMessage ;
18
17
import static com .google .firebase .installations .FisAndroidTestConstants .TEST_APP_ID_1 ;
19
18
import static com .google .firebase .installations .FisAndroidTestConstants .TEST_APP_ID_2 ;
20
19
import static com .google .firebase .installations .FisAndroidTestConstants .TEST_AUTH_TOKEN ;
23
22
import static com .google .firebase .installations .FisAndroidTestConstants .TEST_FID_1 ;
24
23
import static com .google .firebase .installations .FisAndroidTestConstants .TEST_REFRESH_TOKEN ;
25
24
import static com .google .firebase .installations .FisAndroidTestConstants .TEST_TOKEN_EXPIRATION_TIMESTAMP ;
25
+ import static com .google .firebase .installations .local .PersistedFidEntrySubject .assertThat ;
26
26
import static org .junit .Assert .assertNull ;
27
27
import static org .junit .Assert .assertTrue ;
28
28
29
29
import androidx .test .core .app .ApplicationProvider ;
30
30
import androidx .test .runner .AndroidJUnit4 ;
31
31
import com .google .firebase .FirebaseApp ;
32
32
import com .google .firebase .FirebaseOptions ;
33
+ import com .google .firebase .installations .local .PersistedFid .RegistrationStatus ;
33
34
import org .junit .After ;
34
35
import org .junit .Before ;
35
36
import org .junit .Test ;
@@ -88,25 +89,12 @@ public void testUpdateAndReadPersistedFidEntry_successful() throws Exception {
88
89
PersistedFidEntry entryValue = persistedFid0 .readPersistedFidEntryValue ();
89
90
90
91
// Validate insertion was successful
91
- assertWithMessage ("Persisted Fid doesn't match" )
92
- .that (entryValue .getFirebaseInstallationId ())
93
- .isEqualTo (TEST_FID_1 );
94
- assertWithMessage ("Persisted Auth Token doesn't match" )
95
- .that (entryValue .getAuthToken ())
96
- .isEqualTo (TEST_AUTH_TOKEN );
97
- assertWithMessage ("Persisted Refresh Token doesn't match" )
98
- .that (entryValue .getRefreshToken ())
99
- .isEqualTo (TEST_REFRESH_TOKEN );
100
- assertWithMessage ("Persisted Registration Status doesn't match" )
101
- .that (entryValue .getRegistrationStatus ())
102
- .isEqualTo (PersistedFid .RegistrationStatus .UNREGISTERED );
103
- assertWithMessage ("Persisted Token expiration timestamp doesn't match" )
104
- .that (entryValue .getExpiresInSecs ())
105
- .isEqualTo (TEST_TOKEN_EXPIRATION_TIMESTAMP );
106
- assertWithMessage ("Persisted Creation time doesn't match" )
107
- .that (entryValue .getTokenCreationEpochInSecs ())
108
- .isEqualTo (TEST_CREATION_TIMESTAMP_1 );
109
- assertNull (persistedFid1 .readPersistedFidEntryValue ());
92
+ assertThat (entryValue ).hasFid (TEST_FID_1 );
93
+ assertThat (entryValue ).hasAuthToken (TEST_AUTH_TOKEN );
94
+ assertThat (entryValue ).hasRefreshToken (TEST_REFRESH_TOKEN );
95
+ assertThat (entryValue ).hasRegistrationStatus (RegistrationStatus .UNREGISTERED );
96
+ assertThat (entryValue ).hasTokenExpirationTimestamp (TEST_TOKEN_EXPIRATION_TIMESTAMP );
97
+ assertThat (entryValue ).hasCreationTimestamp (TEST_CREATION_TIMESTAMP_1 );
110
98
111
99
// Update Persisted Fid Entry with Registered status in Shared Prefs
112
100
assertTrue (
@@ -122,23 +110,11 @@ public void testUpdateAndReadPersistedFidEntry_successful() throws Exception {
122
110
entryValue = persistedFid0 .readPersistedFidEntryValue ();
123
111
124
112
// Validate update was successful
125
- assertWithMessage ("Persisted Fid doesn't match" )
126
- .that (entryValue .getFirebaseInstallationId ())
127
- .isEqualTo (TEST_FID_1 );
128
- assertWithMessage ("Persisted Auth Token doesn't match" )
129
- .that (entryValue .getAuthToken ())
130
- .isEqualTo (TEST_AUTH_TOKEN );
131
- assertWithMessage ("Persisted Refresh Token doesn't match" )
132
- .that (entryValue .getRefreshToken ())
133
- .isEqualTo (TEST_REFRESH_TOKEN );
134
- assertWithMessage ("Persisted Registration Status doesn't match" )
135
- .that (entryValue .getRegistrationStatus ())
136
- .isEqualTo (PersistedFid .RegistrationStatus .REGISTERED );
137
- assertWithMessage ("Persisted Token expiration timestamp doesn't match" )
138
- .that (entryValue .getExpiresInSecs ())
139
- .isEqualTo (TEST_TOKEN_EXPIRATION_TIMESTAMP );
140
- assertWithMessage ("Persisted Creation time doesn't match" )
141
- .that (entryValue .getTokenCreationEpochInSecs ())
142
- .isEqualTo (TEST_CREATION_TIMESTAMP_2 );
113
+ assertThat (entryValue ).hasFid (TEST_FID_1 );
114
+ assertThat (entryValue ).hasAuthToken (TEST_AUTH_TOKEN );
115
+ assertThat (entryValue ).hasRefreshToken (TEST_REFRESH_TOKEN );
116
+ assertThat (entryValue ).hasRegistrationStatus (RegistrationStatus .REGISTERED );
117
+ assertThat (entryValue ).hasTokenExpirationTimestamp (TEST_TOKEN_EXPIRATION_TIMESTAMP );
118
+ assertThat (entryValue ).hasCreationTimestamp (TEST_CREATION_TIMESTAMP_2 );
143
119
}
144
120
}
0 commit comments