|
4 | 4 | import com.conveyal.datatools.UnitTest;
|
5 | 5 | import com.conveyal.datatools.manager.models.ExternalFeedSourceProperty;
|
6 | 6 | import com.conveyal.datatools.manager.models.FeedSource;
|
| 7 | +import com.conveyal.datatools.manager.models.FeedVersion; |
7 | 8 | import com.conveyal.datatools.manager.models.Project;
|
8 | 9 | import com.conveyal.datatools.manager.persistence.Persistence;
|
9 | 10 | import com.fasterxml.jackson.databind.JsonNode;
|
|
15 | 16 | import java.io.IOException;
|
16 | 17 | import java.util.Date;
|
17 | 18 |
|
| 19 | +import static com.conveyal.datatools.TestUtils.createFeedVersion; |
18 | 20 | import static com.conveyal.datatools.TestUtils.parseJson;
|
| 21 | +import static com.conveyal.datatools.TestUtils.zipFolderFiles; |
19 | 22 | import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
20 | 23 | import static com.github.tomakehurst.wiremock.client.WireMock.get;
|
21 | 24 | import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
|
|
27 | 30 | import static org.hamcrest.Matchers.equalTo;
|
28 | 31 | import static org.hamcrest.Matchers.notNullValue;
|
29 | 32 | import static org.hamcrest.Matchers.nullValue;
|
| 33 | +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
30 | 34 |
|
31 | 35 | class MtcFeedResourceTest extends UnitTest {
|
32 | 36 | private static Project project;
|
@@ -152,4 +156,23 @@ void canUpdateFeedExternalPropertiesToMongo() throws IOException {
|
152 | 156 | ExternalFeedSourceProperty removedPublicIdProp = Persistence.externalFeedSourceProperties.getById(agencyPublicIdProp.id);
|
153 | 157 | assertThat(removedPublicIdProp, nullValue());
|
154 | 158 | }
|
| 159 | + |
| 160 | + @Test |
| 161 | + void shouldTolerateNullObjectInExternalPropertyAgencyId() throws IOException { |
| 162 | + // Add an entry in the ExternalFeedSourceProperties collection |
| 163 | + // with AgencyId value set to null. |
| 164 | + ExternalFeedSourceProperty agencyIdProp = new ExternalFeedSourceProperty( |
| 165 | + feedSource, |
| 166 | + "MTC", |
| 167 | + "AgencyId", |
| 168 | + null |
| 169 | + ); |
| 170 | + agencyIdProp.feedSourceId = feedSource.id; |
| 171 | + Persistence.externalFeedSourceProperties.create(agencyIdProp); |
| 172 | + |
| 173 | + // Trigger the feed update process (it should not upload anything to S3). |
| 174 | + FeedVersion feedVersion = createFeedVersion(feedSource, zipFolderFiles("mini-bart-new")); |
| 175 | + MtcFeedResource mtcFeedResource = new MtcFeedResource(); |
| 176 | + assertDoesNotThrow(() -> mtcFeedResource.feedVersionCreated(feedVersion, null)); |
| 177 | + } |
155 | 178 | }
|
0 commit comments