|
14 | 14 | package com.google.firebase.appdistribution.impl;
|
15 | 15 |
|
16 | 16 | import static com.google.common.truth.Truth.assertThat;
|
17 |
| -import static com.google.firebase.appdistribution.impl.TestUtils.assertTaskFailure; |
18 | 17 | import static com.google.firebase.appdistribution.impl.TestUtils.awaitAsyncOperations;
|
19 | 18 | import static com.google.firebase.appdistribution.impl.TestUtils.awaitCondition;
|
| 19 | +import static com.google.firebase.appdistribution.impl.TestUtils.awaitTaskFailure; |
20 | 20 | import static org.junit.Assert.assertEquals;
|
21 | 21 | import static org.mockito.ArgumentMatchers.anyString;
|
22 | 22 | import static org.mockito.Mockito.times;
|
@@ -111,52 +111,41 @@ public void setup() throws IOException, FirebaseAppDistributionException {
|
111 | 111 | }
|
112 | 112 |
|
113 | 113 | @Test
|
114 |
| - public void updateAppTask_whenOpenConnectionFails_setsNetworkFailure() |
115 |
| - throws IOException, InterruptedException { |
| 114 | + public void updateAppTask_whenOpenConnectionFails_setsNetworkFailure() throws IOException { |
116 | 115 | IOException caughtException = new IOException("error");
|
117 | 116 | when(mockHttpsUrlConnectionFactory.openConnection(TEST_URL)).thenThrow(caughtException);
|
118 | 117 |
|
119 | 118 | UpdateTask updateTask = aabUpdater.updateAab(TEST_RELEASE_NEWER_AAB_INTERNAL);
|
120 |
| - awaitAsyncOperations(blockingExecutor); |
121 |
| - awaitAsyncOperations(lightweightExecutor); |
122 | 119 |
|
123 |
| - assertTaskFailure( |
| 120 | + awaitTaskFailure( |
124 | 121 | updateTask, Status.NETWORK_FAILURE, "Failed to open connection", caughtException);
|
125 | 122 | }
|
126 | 123 |
|
127 | 124 | @Test
|
128 |
| - public void updateAppTask_isNotRedirectResponse_setsDownloadFailure() |
129 |
| - throws IOException, InterruptedException { |
| 125 | + public void updateAppTask_isNotRedirectResponse_setsDownloadFailure() throws IOException { |
130 | 126 | when(mockHttpsUrlConnection.getResponseCode()).thenReturn(200);
|
131 | 127 |
|
132 | 128 | UpdateTask updateTask = aabUpdater.updateAab(TEST_RELEASE_NEWER_AAB_INTERNAL);
|
133 |
| - awaitAsyncOperations(blockingExecutor); |
134 |
| - awaitAsyncOperations(lightweightExecutor); |
135 | 129 |
|
136 |
| - assertTaskFailure(updateTask, Status.DOWNLOAD_FAILURE, "Expected redirect"); |
| 130 | + awaitTaskFailure(updateTask, Status.DOWNLOAD_FAILURE, "Expected redirect"); |
137 | 131 | }
|
138 | 132 |
|
139 | 133 | @Test
|
140 |
| - public void updateAppTask_missingLocationHeader_setsDownloadFailure() |
141 |
| - throws InterruptedException { |
| 134 | + public void updateAppTask_missingLocationHeader_setsDownloadFailure() { |
142 | 135 | when(mockHttpsUrlConnection.getHeaderField("Location")).thenReturn(null);
|
143 | 136 |
|
144 | 137 | UpdateTask updateTask = aabUpdater.updateAab(TEST_RELEASE_NEWER_AAB_INTERNAL);
|
145 |
| - awaitAsyncOperations(blockingExecutor); |
146 |
| - awaitAsyncOperations(lightweightExecutor); |
147 | 138 |
|
148 |
| - assertTaskFailure(updateTask, Status.DOWNLOAD_FAILURE, "No Location header"); |
| 139 | + awaitTaskFailure(updateTask, Status.DOWNLOAD_FAILURE, "No Location header"); |
149 | 140 | }
|
150 | 141 |
|
151 | 142 | @Test
|
152 |
| - public void updateAppTask_emptyLocationHeader_setsDownloadFailure() throws InterruptedException { |
| 143 | + public void updateAppTask_emptyLocationHeader_setsDownloadFailure() { |
153 | 144 | when(mockHttpsUrlConnection.getHeaderField("Location")).thenReturn("");
|
154 | 145 |
|
155 | 146 | UpdateTask updateTask = aabUpdater.updateAab(TEST_RELEASE_NEWER_AAB_INTERNAL);
|
156 |
| - awaitAsyncOperations(blockingExecutor); |
157 |
| - awaitAsyncOperations(lightweightExecutor); |
158 | 147 |
|
159 |
| - assertTaskFailure(updateTask, Status.DOWNLOAD_FAILURE, "Empty Location header"); |
| 148 | + awaitTaskFailure(updateTask, Status.DOWNLOAD_FAILURE, "Empty Location header"); |
160 | 149 | }
|
161 | 150 |
|
162 | 151 | @Test
|
@@ -195,7 +184,7 @@ public void updateAppTask_onAppResume_setsUpdateCancelled() throws InterruptedEx
|
195 | 184 | aabUpdater.onActivityStarted(activity);
|
196 | 185 |
|
197 | 186 | FirebaseAppDistributionException exception =
|
198 |
| - assertTaskFailure(updateTask, Status.INSTALLATION_CANCELED, ErrorMessages.UPDATE_CANCELED); |
| 187 | + awaitTaskFailure(updateTask, Status.INSTALLATION_CANCELED, ErrorMessages.UPDATE_CANCELED); |
199 | 188 | assertEquals(
|
200 | 189 | ReleaseUtils.convertToAppDistributionRelease(TEST_RELEASE_NEWER_AAB_INTERNAL),
|
201 | 190 | exception.getRelease());
|
|
0 commit comments