Skip to content

Commit

Permalink
Adapted format of labels returned by change object status calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Jun 11, 2018
1 parent 0ae76c2 commit f5f3eed
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ Then you can refer to seatsio-java as a regular package:
```
// build.gradle
dependencies {
compile 'com.github.seatsio:seatsio-java:15'
compile 'com.github.seatsio:seatsio-java:16'
}
// pom.xml
<dependency>
<groupId>com.github.seatsio</groupId>
<artifactId>seatsio-java</artifactId>
<version>15</version>
<version>16</version>
</dependency>
```

Expand Down
28 changes: 28 additions & 0 deletions src/main/java/seatsio/events/LabelAndType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package seatsio.events;

import static org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals;
import static org.apache.commons.lang3.builder.HashCodeBuilder.reflectionHashCode;

public class LabelAndType {

private String label;
private String type;

protected LabelAndType() {
}

public LabelAndType(String label, String type) {
this.label = label;
this.type = type;
}

@Override
public boolean equals(Object obj) {
return reflectionEquals(this, obj);
}

@Override
public int hashCode() {
return reflectionHashCode(this);
}
}
19 changes: 12 additions & 7 deletions src/main/java/seatsio/events/Labels.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@

public class Labels {

public String own;
public String row;
public String table;
public LabelAndType own;
public LabelAndType parent;
public String section;

public Labels(String own, String row, String table, String section) {
this.own = own;
this.row = row;
this.table = table;
protected Labels() {
}

public Labels(String ownLabel, String ownType, String section) {
this.own = new LabelAndType(ownLabel, ownType);
this.section = section;
}

public Labels(String ownLabel, String ownType, String parentLabel, String parentType, String section) {
this(ownLabel, ownType, section);
this.parent = new LabelAndType(parentLabel, parentType);
}

@Override
public boolean equals(Object obj) {
return reflectionEquals(this, obj);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/BookObjectsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public void test() {
assertThat(client.events.retrieveObjectStatus(event.key, "A-2").status).isEqualTo(BOOKED);
assertThat(client.events.retrieveObjectStatus(event.key, "A-3").status).isEqualTo(FREE);
assertThat(result.labels).isEqualTo(ImmutableMap.of(
"A-1", new Labels("1", "A", null, null),
"A-2", new Labels("2", "A", null, null)
"A-1", new Labels("1", "seat", "A", "row", null),
"A-2", new Labels("2", "seat", "A", "row", null)
));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package seatsio.events;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import org.junit.Test;
import seatsio.SeatsioClientTest;

Expand Down Expand Up @@ -32,7 +31,10 @@ public void labels() {

BestAvailableResult bestAvailableResult = client.events.changeObjectStatus(event.key, new BestAvailable(2), "foo");

assertThat(bestAvailableResult.labels).isEqualTo(ImmutableMap.of("B-4", new Labels("4", "B", null, null), "B-5", new Labels("5", "B", null, null)));
assertThat(bestAvailableResult.labels).isEqualTo(ImmutableMap.of(
"B-4", new Labels("4", "seat", "B", "row", null),
"B-5", new Labels("5", "seat", "B", "row", null)
));
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seatsio/events/ChangeObjectStatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void labels() {

ChangeObjectStatusResult result = client.events.changeObjectStatus(event.key, newArrayList("A-1"), "foo");

assertThat(result.labels).isEqualTo(ImmutableMap.of("A-1", new Labels("1", "A", null, null)));
assertThat(result.labels).isEqualTo(ImmutableMap.of("A-1", new Labels("1", "seat", "A", "row", null)));
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/HoldObjectsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void labels() {
ChangeObjectStatusResult result = client.events.hold(event.key, newArrayList("A-1", "A-2"), holdToken.holdToken);

assertThat(result.labels).isEqualTo(ImmutableMap.of(
"A-1", new Labels("1", "A", null, null),
"A-2", new Labels("2", "A", null, null)
"A-1", new Labels("1", "seat", "A", "row", null),
"A-2", new Labels("2", "seat", "A", "row", null)
));
}
}
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/ReleaseObjectsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public void test() {
assertThat(client.events.retrieveObjectStatus(event.key, "A-1").status).isEqualTo(FREE);
assertThat(client.events.retrieveObjectStatus(event.key, "A-2").status).isEqualTo(FREE);
assertThat(result.labels).isEqualTo(ImmutableMap.of(
"A-1", new Labels("1", "A", null, null),
"A-2", new Labels("2", "A", null, null)
"A-1", new Labels("1", "seat", "A", "row", null),
"A-2", new Labels("2", "seat", "A", "row", null)
));
}

Expand Down

0 comments on commit f5f3eed

Please sign in to comment.