package com.auth0.json.mgmt.tickets; import com.auth0.json.JsonMatcher; import com.auth0.json.JsonTest; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; public class EmailVerificationTicketTest extends JsonTest<EmailVerificationTicket> { private static final String readOnlyJson = "{\"ticket\":\"https://page.auth0.com/tickets/123\"}"; @Test public void shouldSerialize() throws Exception { EmailVerificationTicket ticket = new EmailVerificationTicket("usr123"); ticket.setResultUrl("https://page.auth0.com/result"); ticket.setTTLSeconds(36000); String serialized = toJSON(ticket); assertThat(serialized, is(notNullValue())); assertThat(serialized, JsonMatcher.hasEntry("user_id", "usr123")); assertThat(serialized, JsonMatcher.hasEntry("result_url", "https://page.auth0.com/result")); assertThat(serialized, JsonMatcher.hasEntry("ttl_sec", 36000)); } @Test public void shouldIncludeReadOnlyValuesOnDeserialize() throws Exception { EmailVerificationTicket ticket = fromJSON(readOnlyJson, EmailVerificationTicket.class); assertThat(ticket, is(notNullValue())); assertThat(ticket.getTicket(), is("https://page.auth0.com/tickets/123")); } }