Skip to content

Commit

Permalink
Merge pull request #167 from mobidata-bw/issues/430_missing_gbfs_feed
Browse files Browse the repository at this point in the history
Fix: return discovery feed
  • Loading branch information
testower authored Apr 20, 2024
2 parents 1321e9e + 505104a commit 0eb855e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/entur/gbfs/loader/BaseGbfsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,16 @@ public <R> R getFeed(Class<R> feed) {
}

public Optional<byte[]> getRawFeed(S feedName) {
if (feedName == getDiscoveryFeedName()) {
return discoveryFileUpdater.getRawData();
}

GBFSFeedUpdater<?> updater = feedUpdaters.get(feedName);
if (updater == null) {
return Optional.empty();
}
return updater.getRawData();
}

protected abstract S getDiscoveryFeedName();
}
5 changes: 5 additions & 0 deletions src/main/java/org/entur/gbfs/loader/v2/GbfsV2Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,9 @@ public GbfsV2Loader(
)
.collect(Collectors.toList());
}

@Override
protected GBFSFeedName getDiscoveryFeedName() {
return GBFSFeedName.GBFS;
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/entur/gbfs/loader/v3/GbfsV3Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ public GbfsV3Loader(
)
.collect(Collectors.toList());
}

@Override
protected GBFSFeed.Name getDiscoveryFeedName() {
return GBFSFeed.Name.GBFS;
}
}
2 changes: 2 additions & 0 deletions src/test/java/org/entur/gbfs/loader/v2/GbfsV2LoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ private void validateV22Feed(GbfsV2Loader loader) {
);
assertEquals(0, validationResult.getErrorsCount());

assertFalse(loader.getRawFeed(GBFSFeedName.GBFS).isEmpty());

GBFSSystemInformation systemInformation = loader.getFeed(GBFSSystemInformation.class);
assertNotNull(systemInformation);
assertEquals("lillestrombysykkel", systemInformation.getData().getSystemId());
Expand Down
8 changes: 3 additions & 5 deletions src/test/java/org/entur/gbfs/loader/v3/GbfsV3LoaderTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package org.entur.gbfs.loader.v3;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

import java.io.ByteArrayInputStream;
import java.util.List;
Expand Down Expand Up @@ -52,6 +48,8 @@ private void validateV3Feed(GbfsV3Loader loader) {
);
assertEquals(0, validationResult.getErrorsCount());

assertFalse(loader.getRawFeed(GBFSFeed.Name.GBFS).isEmpty());

GBFSSystemInformation systemInformation = loader.getFeed(GBFSSystemInformation.class);
assertNotNull(systemInformation);
assertEquals("getaround_stavanger", systemInformation.getData().getSystemId());
Expand Down

0 comments on commit 0eb855e

Please sign in to comment.