Skip to content

Instantly share code, notes, and snippets.

@sue445
Created November 25, 2012 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sue445/4143198 to your computer and use it in GitHub Desktop.
Save sue445/4143198 to your computer and use it in GitHub Desktop.
Doorkeeper API sample for Java
public class DoorkeeperDto{
public DoorkeeperEventDto event = new DoorkeeperEventDto();
}
import net.arnx.jsonic.JSONHint;
public class DoorkeeperEventDto{
public String title;
public int id;
@JSONHint(name = "starts_at")
public String startsAt;
@JSONHint(name = "ends_at")
public String endsAt;
public String venue;
public String address;
@JSONHint(name = "ticket_limit")
public int ticketLimit;
public String description;
public int participants;
public int waitlisted;
@JSONHint(name = "public_url")
public String publicUrl;
}
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.net.URL;
import net.arnx.jsonic.JSON;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
public class DoorkeeperTest {
private String json;
@Before
public void setUp() throws Exception {
json = IOUtils.toString(new URL("http://api.doorkeeper.jp/events?locale=ja"));
}
@Test
public void test() throws Exception {
DoorkeeperDto[] actual = JSON.decode(json, DoorkeeperDto[].class);
assertThat(actual.length, is(greaterThan(0)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment