Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add episode count to the Event #90

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/io/kontur/disasterninja/dto/EventDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ public class EventDto {
private OffsetDateTime updatedAt;
private List<Double> bbox;
private List<Double> centroid;
private int episodeCount;

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public class EventListDto {
private List<String> externalUrls;
private List<Double> bbox;
private List<Double> centroid;
private int episodeCount;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ public class EventApiEventDto {
private String location;
private List<Double> bbox = new ArrayList<>();
private List<Double> centroid = new ArrayList<>();
private int episodeCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static EventDto convert(EventApiEventDto event) {
dto.setEventName(eventName(event));
dto.setDescription(event.getDescription());
dto.setLocation(event.getLocation());
dto.setEpisodeCount(event.getEpisodeCount());
List<String> eventUrls = event.getUrls();
dto.setExternalUrls(eventUrls != null ? List.copyOf(eventUrls) : List.of());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static EventListDto convert(EventApiEventDto event) {
dto.setEventName(eventName(event));
dto.setDescription(event.getDescription());
dto.setLocation(event.getLocation());
dto.setEpisodeCount(event.getEpisodeCount());
List<String> eventUrls = event.getUrls();
dto.setExternalUrls(eventUrls != null ? List.copyOf(eventUrls) : List.of());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void noDefaultFeedReturnedByUps_twoFeedsReturnedByEventApiTest() {
}

@Test
public void fefaultFeedReturnedByUps_singleFeedReturnedByEventApiTest() {
public void defaultFeedReturnedByUps_singleFeedReturnedByEventApiTest() {
givenUpsReturnsPublicFeed2AsDefault();
givenEventApiReturnsOnlyFeed2();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private static EventApiEventDto testEvent() {
episodes.add(episode);

event.setEpisodes(episodes);
event.setEpisodeCount(1);
return event;
}

Expand Down Expand Up @@ -118,6 +119,23 @@ public void eventDtoTestNames() {
assertEquals(DROUGHT.getName(), dto.getEventName());
}

@Test
public void eventDtoTestEpisodeCount() {
EventApiEventDto event = testEvent();
EventDto dto = EventDtoConverter.convert(event);
assertEquals(dto.getEpisodeCount(), 1);

//1. with 0 episodes
event.setEpisodeCount(0);
dto = EventDtoConverter.convert(event);
assertEquals(dto.getEpisodeCount(), 0);

//2. with 2 episodes
event.setEpisodeCount(2);
dto = EventDtoConverter.convert(event);
assertEquals(dto.getEpisodeCount(), 2);
}

@Test
public void eventListDtoTestNulls() {
EventApiEventDto event = testEvent();
Expand Down Expand Up @@ -188,4 +206,21 @@ public void eventListDtoTestNames() {
dto = EventListEventDtoConverter.convert(event);
assertEquals(DROUGHT.getName(), dto.getEventName());
}

@Test
public void eventListDtoTestEpisodeCount() {
EventApiEventDto event = testEvent();
EventListDto dto = EventListEventDtoConverter.convert(event);
assertEquals(dto.getEpisodeCount(), 1);

//1. with 0 episodes
event.setEpisodeCount(0);
dto = EventListEventDtoConverter.convert(event);
assertEquals(dto.getEpisodeCount(), 0);

//2. with 2 episodes
event.setEpisodeCount(2);
dto = EventListEventDtoConverter.convert(event);
assertEquals(dto.getEpisodeCount(), 2);
}
}
Loading