Skip to content

Commit

Permalink
Expose floor info (#200)
Browse files Browse the repository at this point in the history
* Expose floor info

For multi-floor charts, floor information is included in chart reports.

* Replcaed `FloorInfo` with existing `Floor` class

---------

Co-authored-by: Steve Chaloner <[email protected]>
  • Loading branch information
schaloner and Steve Chaloner authored Oct 1, 2024
1 parent 4fad2b6 commit bb45f5e
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 370 deletions.
3 changes: 2 additions & 1 deletion src/main/java/seatsio/charts/ChartObjectInfo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seatsio.charts;

import seatsio.events.Floor;
import seatsio.events.IDs;
import seatsio.events.Labels;

Expand All @@ -23,5 +24,5 @@ public class ChartObjectInfo {
public Boolean isCompanionSeat;
public Boolean hasRestrictedView;
public String zone;

public Floor floor;
}
104 changes: 96 additions & 8 deletions src/test/java/seatsio/reports/charts/AbstractChartReportsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.junit.jupiter.api.Test;
import seatsio.SeatsioClientTest;
import seatsio.charts.ChartObjectInfo;
import seatsio.events.Floor;
import seatsio.events.IDs;
import seatsio.events.Labels;

Expand Down Expand Up @@ -37,6 +38,7 @@ public void reportItemProperties() {
assertThat(reportItem.isAccessible).isNotNull();
assertThat(reportItem.isCompanionSeat).isNotNull();
assertThat(reportItem.hasRestrictedView).isNotNull();
assertThat(reportItem.floor).isNull();
}

@Test
Expand All @@ -63,23 +65,37 @@ public void reportItemPropertiesForTable() {
}

@Test
public void byLabel() {
public void byObjectType() {
String chartKey = createTestChartForReport();

Map<String, List<ChartObjectInfo>> report = client.chartReports.byLabel(chartKey, updateOptions());
Map<String, List<ChartObjectInfo>> report = client.chartReports.byObjectType(chartKey, updateOptions());

assertThat(report.get("A-1")).hasSize(1);
assertThat(report.get("A-2")).hasSize(1);
assertThat(report.get("seat")).hasSize(32);
assertThat(report.get("generalAdmission")).hasSize(2);
}

@Test
public void byObjectType() {
String chartKey = createTestChartForReport();
public void byObjectType_withFloors() {
String chartKey = createTestChartWithFloorsForReport();

Map<String, List<ChartObjectInfo>> report = client.chartReports.byObjectType(chartKey, updateOptions());

assertThat(report.get("seat")).hasSize(32);
assertThat(report.get("generalAdmission")).hasSize(2);
List<ChartObjectInfo> seats = report.get("seat");
assertThat(seats).hasSize(4);
assertThat(seats.get(0).floor).isEqualTo(floor("1", "Floor 1"));
assertThat(seats.get(1).floor).isEqualTo(floor("1", "Floor 1"));
assertThat(seats.get(2).floor).isEqualTo(floor("2", "Floor 2"));
assertThat(seats.get(3).floor).isEqualTo(floor("2", "Floor 2"));
}

@Test
public void byLabel() {
String chartKey = createTestChartForReport();

Map<String, List<ChartObjectInfo>> report = client.chartReports.byLabel(chartKey, updateOptions());

assertThat(report.get("A-1")).hasSize(1);
assertThat(report.get("A-2")).hasSize(1);
}

@Test
Expand Down Expand Up @@ -118,6 +134,18 @@ public void byLabel_bookWholeTablesFalse() {
assertThat(report.keySet()).containsExactlyInAnyOrder("T1-1", "T1-2", "T1-3", "T1-4", "T1-5", "T1-6", "T2-1", "T2-2", "T2-3", "T2-4", "T2-5", "T2-6");
}

@Test
public void byLabel_withFloors() {
String chartKey = createTestChartWithFloorsForReport();

Map<String, List<ChartObjectInfo>> report = client.chartReports.byLabel(chartKey, updateOptions());

assertThat(report.get("S1-A-1").get(0).floor).isEqualTo(floor("1", "Floor 1"));
assertThat(report.get("S1-A-2").get(0).floor).isEqualTo(floor("1", "Floor 1"));
assertThat(report.get("S2-B-1").get(0).floor).isEqualTo(floor("2", "Floor 2"));
assertThat(report.get("S2-B-2").get(0).floor).isEqualTo(floor("2", "Floor 2"));
}

@Test
public void byCategoryKey() {
String chartKey = createTestChartForReport();
Expand All @@ -128,6 +156,23 @@ public void byCategoryKey() {
assertThat(report.get("10")).hasSize(17);
}

@Test
public void byCategoryKey_withFloors() {
String chartKey = createTestChartWithFloorsForReport();

Map<String, List<ChartObjectInfo>> report = client.chartReports.byCategoryKey(chartKey, updateOptions());

List<ChartObjectInfo> fooCategory = report.get("1");
assertThat(fooCategory).hasSize(2);
assertThat(fooCategory.get(0).floor).isEqualTo(floor("1", "Floor 1"));
assertThat(fooCategory.get(1).floor).isEqualTo(floor("1", "Floor 1"));

List<ChartObjectInfo> barCategory = report.get("2");
assertThat(barCategory).hasSize(2);
assertThat(barCategory.get(0).floor).isEqualTo(floor("2", "Floor 2"));
assertThat(barCategory.get(1).floor).isEqualTo(floor("2", "Floor 2"));
}

@Test
public void byCategoryLabel() {
String chartKey = createTestChartForReport();
Expand All @@ -138,6 +183,23 @@ public void byCategoryLabel() {
assertThat(report.get("Cat2")).hasSize(17);
}

@Test
public void byCategoryLabel_withFloors() {
String chartKey = createTestChartWithFloorsForReport();

Map<String, List<ChartObjectInfo>> report = client.chartReports.byCategoryLabel(chartKey, updateOptions());

List<ChartObjectInfo> fooCategory = report.get("Foo");
assertThat(fooCategory).hasSize(2);
assertThat(fooCategory.get(0).floor).isEqualTo(floor("1", "Floor 1"));
assertThat(fooCategory.get(1).floor).isEqualTo(floor("1", "Floor 1"));

List<ChartObjectInfo> barCategory = report.get("Bar");
assertThat(barCategory).hasSize(2);
assertThat(barCategory.get(0).floor).isEqualTo(floor("2", "Floor 2"));
assertThat(barCategory.get(1).floor).isEqualTo(floor("2", "Floor 2"));
}

@Test
public void bySection() {
String chartKey = createTestChartWithSectionsForReport();
Expand All @@ -148,6 +210,23 @@ public void bySection() {
assertThat(report.get("Section B")).hasSize(35);
}

@Test
public void bySection_withFloors() {
String chartKey = createTestChartWithFloorsForReport();

Map<String, List<ChartObjectInfo>> report = client.chartReports.bySection(chartKey, updateOptions());

List<ChartObjectInfo> section1 = report.get("S1");
assertThat(section1).hasSize(2);
assertThat(section1.get(0).floor).isEqualTo(floor("1", "Floor 1"));
assertThat(section1.get(0).floor).isEqualTo(floor("1", "Floor 1"));

List<ChartObjectInfo> section2 = report.get("S2");
assertThat(section2).hasSize(2);
assertThat(section2.get(1).floor).isEqualTo(floor("2", "Floor 2"));
assertThat(section2.get(1).floor).isEqualTo(floor("2", "Floor 2"));
}

@Test
public void byZone() {
String chartKey = createTestChartWithZonesForReport();
Expand All @@ -167,7 +246,16 @@ public void byZone() {

public abstract String createTestChartWithTablesForReport();

public abstract String createTestChartWithFloorsForReport();

public abstract ChartReportOptions updateOptions();

public abstract ChartReportOptions updateOptions(ChartReportOptions options);

private static Floor floor(String name, String displayName){
Floor floor = new Floor();
floor.name = name;
floor.displayName = displayName;
return floor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public String createTestChartWithTablesForReport() {
return chartKey;
}

@Override
public String createTestChartWithFloorsForReport() {
String chartKey = createTestChartWithFloors();
createDraft(chartKey);
return chartKey;
}

private void createDraft(String chartKey) {
client.events.create(chartKey);
client.charts.update(chartKey, "foo");
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/seatsio/reports/charts/ChartReportsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public String createTestChartWithTablesForReport() {
return createTestChartWithTables();
}

@Override
public String createTestChartWithFloorsForReport() {
return createTestChartWithFloors();
}

@Override
public ChartReportOptions updateOptions() {
return ChartReportOptions.NONE;
Expand Down
Loading

0 comments on commit bb45f5e

Please sign in to comment.