Skip to content

Commit

Permalink
#35 - fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed Jul 28, 2015
1 parent 0c3ab46 commit 150628d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/test/java/alfio/manager/ConfigurationManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void prepareEnv() {
new DateTimeModification(LocalDate.now(), LocalTime.now()),
"desc", BigDecimal.TEN, false, "", false));
EventModification em = new EventModification(null, "url", "url", "url", null,
"eventShortName", organization.getId(),
"eventShortName", "displayName", organization.getId(),
"muh location", "muh description",
new DateTimeModification(LocalDate.now(), LocalTime.now()),
new DateTimeModification(LocalDate.now(), LocalTime.now()),
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/alfio/manager/EventManagerIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void testIncreaseEventSeatsWithAnUnboundedCategory() {
"desc", BigDecimal.TEN, false, "", false));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager);
Event event = pair.getKey();
EventModification update = new EventModification(event.getId(), null, null, null, null, null, event.getOrganizationId(), null, null,
EventModification update = new EventModification(event.getId(), null, null, null, null, null, null, event.getOrganizationId(), null, null,
DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd()),
event.getRegularPrice(), event.getCurrency(), 40, event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), null, event.isFreeOfCharge(), null);
eventManager.updateEventPrices(event.getId(), update, pair.getValue());
Expand All @@ -210,7 +210,7 @@ public void testIncreaseEventSeatsWithABoundedCategory() {
"desc", BigDecimal.TEN, false, "", true));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager);
Event event = pair.getKey();
EventModification update = new EventModification(event.getId(), null, null, null, null, null, event.getOrganizationId(), null, null,
EventModification update = new EventModification(event.getId(), null, null, null, null, null, null, event.getOrganizationId(), null, null,
DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd()),
event.getRegularPrice(), event.getCurrency(), 40, event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), null, event.isFreeOfCharge(), null);
eventManager.updateEventPrices(event.getId(), update, pair.getValue());
Expand All @@ -230,7 +230,7 @@ public void testDecreaseEventSeatsWithAnUnboundedCategory() {
"desc", BigDecimal.TEN, false, "", false));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager);
Event event = pair.getKey();
EventModification update = new EventModification(event.getId(), null, null, null, null, null, event.getOrganizationId(), null, null,
EventModification update = new EventModification(event.getId(), null, null, null, null, null, null, event.getOrganizationId(), null, null,
DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd()),
event.getRegularPrice(), event.getCurrency(), 10, event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), null, event.isFreeOfCharge(), null);
eventManager.updateEventPrices(event.getId(), update, pair.getValue());
Expand All @@ -250,7 +250,7 @@ public void testDecreaseEventSeatsWithABoundedCategory() {
"desc", BigDecimal.TEN, false, "", true));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager);
Event event = pair.getKey();
EventModification update = new EventModification(event.getId(), null, null, null, null, null, event.getOrganizationId(), null, null,
EventModification update = new EventModification(event.getId(), null, null, null, null, null, null, event.getOrganizationId(), null, null,
DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd()),
event.getRegularPrice(), event.getCurrency(), 10, event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), null, event.isFreeOfCharge(), null);
eventManager.updateEventPrices(event.getId(), update, pair.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public static void initEnv() {
}

private Pair<Event, String> initEvent(List<TicketCategoryModification> categories) {
return initEvent(categories, "display name");
}

private Pair<Event,String> initEvent(List<TicketCategoryModification> categories, String displayName) {
String organizationName = UUID.randomUUID().toString();
String username = UUID.randomUUID().toString();
String eventName = UUID.randomUUID().toString();
Expand All @@ -102,7 +106,7 @@ private Pair<Event, String> initEvent(List<TicketCategoryModification> categorie
userManager.insertUser(organization.getId(), username, "test", "test", "[email protected]");

EventModification em = new EventModification(null, "url", "url", "url", null,
eventName, organization.getId(),
eventName, displayName, organization.getId(),
"muh location", "muh description",
new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()),
new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now().plusHours(1)),
Expand Down Expand Up @@ -183,4 +187,25 @@ public void testAlreadyMigratedEvent() {
assertEquals(AVAILABLE_SEATS, tickets.size());//<-- the migration has not been done
assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null));
}

@Test
public void testUpdateDisplayName() {
List<TicketCategoryModification> categories = Collections.singletonList(
new TicketCategoryModification(null, "default", AVAILABLE_SEATS,
new DateTimeModification(LocalDate.now(), LocalTime.now()),
new DateTimeModification(LocalDate.now(), LocalTime.now()),
"desc", BigDecimal.TEN, false, "", false));
Event event = initEvent(categories, null).getKey();

dataMigrator.migrateEventsToCurrentVersion();
EventMigration eventMigration = eventMigrationRepository.loadEventMigration(event.getId());
assertNotNull(eventMigration);
assertEquals(buildTimestamp, eventMigration.getBuildTimestamp().toString());
assertEquals(currentVersion, eventMigration.getCurrentVersion());

Event withDescription = eventRepository.findById(event.getId());
assertNotNull(withDescription.getDisplayName());
assertEquals(event.getShortName(), withDescription.getShortName());
assertEquals(event.getShortName(), withDescription.getDisplayName());
}
}
2 changes: 1 addition & 1 deletion src/test/java/alfio/repository/EventRepositoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testJavaInsertedDatesRespectTheirTimeZone() throws Exception {

int orgId = organizationRepository.findByName(ORG_NAME).stream().findFirst().orElseThrow(IllegalStateException::new).getId();

AffectedRowCountAndKey<Integer> pair = eventRepository.insert("test from unit test", "unittest","http://localhost:8080/", "http://localhost:8080", "http://localhost:8080", null, "Lugano", "9", "8", beginEventDate, endEventDate, NEW_YORK_TZ, 0, "CHF", 4, true, new BigDecimal(1), "", "", orgId);
AffectedRowCountAndKey<Integer> pair = eventRepository.insert("test from unit test", "unittest", "display Name", "http://localhost:8080/", "http://localhost:8080", "http://localhost:8080", null, "Lugano", "9", "8", beginEventDate, endEventDate, NEW_YORK_TZ, 0, "CHF", 4, true, new BigDecimal(1), "", "", orgId);
Event e = eventRepository.findById(pair.getKey());
assertNotNull("Event not found in DB", e);

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/alfio/test/util/IntegrationTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static Pair<Event, String> initEvent(List<TicketCategoryModification> cat
userManager.insertUser(organization.getId(), username, "test", "test", "[email protected]");

EventModification em = new EventModification(null, "url", "url", "url", null,
eventName, organization.getId(),
eventName, "event display name", organization.getId(),
"muh location", "muh description",
new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()),
new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now().plusHours(1)),
Expand Down

0 comments on commit 150628d

Please sign in to comment.