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

Added changes which shows previous day events #221

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ public Event joinEventRazorPayment(final RazorPaymentRequest paymentRequest) {
public List<com.flickmatch.platform.graphql.type.Event> getEvents(String cityId, String localTimeZone) {
Date currentTime = new Date(System.currentTimeMillis());
List<com.flickmatch.platform.graphql.type.Event> eventList = new ArrayList<>();
List<com.flickmatch.platform.graphql.type.Event> prevDayList= getPastEvents(cityId,1,localTimeZone);

final int GET_EVENT_DAYS = 7;
eventList.addAll(prevDayList);
for (int i = 0; i < GET_EVENT_DAYS; i++) {
Date currentDate = Date.from(currentTime.toInstant().plus(i, ChronoUnit.DAYS));
String formattedDate = DateUtil.extractDateFromISOFormatDate(currentDate, localTimeZone);
Expand All @@ -102,6 +105,7 @@ public List<com.flickmatch.platform.graphql.type.Event> getEvents(String cityId,
.toList();
eventList.addAll(dailyEventList);
}

}
return eventList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class EventBuilderTest {
private EventRepository eventRepository;

private EventBuilder eventBuilder;

@BeforeEach
public void setup() {
eventRepository = mock(EventRepository.class);
Expand Down Expand Up @@ -158,4 +157,44 @@ public void testGetCurrencyForCity() {
assertEquals("USD", currencyForSanFrancisco);

}

@Test
public void testGetEvents() {
// Mock input data
String cityId = "2";
String localTimeZone = "GMT+5:030";
List<Event> events = createMockEvents(cityId);

// Mock the event repository to return the list of events
when(eventRepository.findAll()).thenReturn(events);

// Call the method under test
List<com.flickmatch.platform.graphql.type.Event> result = eventBuilder.getEvents(cityId, localTimeZone);

// Verify the result
assertEquals(2, result.size());
}

private List<Event> createMockEvents(String cityId) {
List<Event> events = new ArrayList<>();

// Create mock events
Event event1 = new Event();
Event event2 = new Event();

// Set up event details
event1.setCityId(cityId);
event1.setDate("2024-05-06");
event1.setEventDetailsList(new ArrayList<>());

event2.setCityId(cityId); // Make sure to set the cityId property
event2.setDate("2024-05-07");
abhimanyu-fm marked this conversation as resolved.
Show resolved Hide resolved
event2.setEventDetailsList(new ArrayList<>());

// Add events to the list
events.add(event1);
events.add(event2);

return events;
}
}
Loading