|
| 1 | +package com.dnsimple.endpoints; |
| 2 | + |
| 3 | +import com.dnsimple.data.DomainResearchStatus; |
| 4 | +import com.dnsimple.response.SimpleResponse; |
| 5 | +import com.dnsimple.tools.DnsimpleTestBase; |
| 6 | +import org.junit.Test; |
| 7 | + |
| 8 | +import java.util.List; |
| 9 | + |
| 10 | +import static com.dnsimple.http.HttpMethod.GET; |
| 11 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 12 | +import static org.hamcrest.Matchers.*; |
| 13 | + |
| 14 | +/** |
| 15 | + * Tests for the domain research status endpoint. |
| 16 | + */ |
| 17 | +public class DomainsResearchTest extends DnsimpleTestBase { |
| 18 | + |
| 19 | + @Test |
| 20 | + public void testGetDomainResearchStatusBuildsCorrectRequest() { |
| 21 | + server.stubFixtureAt("getDomainsResearchStatus/success-unavailable.http"); |
| 22 | + client.domains.getDomainResearchStatus(1010, "taken.com"); |
| 23 | + |
| 24 | + assertThat(server.getRecordedRequest().getMethod(), is(GET)); |
| 25 | + assertThat(server.getRecordedRequest().getPath(), is("/v2/1010/domains/research/status?domain=taken.com")); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void testGetDomainResearchStatusReturnsDomainResearchStatus() { |
| 30 | + server.stubFixtureAt("getDomainsResearchStatus/success-unavailable.http"); |
| 31 | + |
| 32 | + SimpleResponse<DomainResearchStatus> response = client.domains.getDomainResearchStatus(1010, "taken.com"); |
| 33 | + |
| 34 | + assertThat(response, is(notNullValue())); |
| 35 | + DomainResearchStatus data = response.getData(); |
| 36 | + assertThat(data, is(notNullValue())); |
| 37 | + assertThat(data.getRequestId(), is("25dd77cb-2f71-48b9-b6be-1dacd2881418")); |
| 38 | + assertThat(data.getDomain(), is("taken.com")); |
| 39 | + assertThat(data.getAvailability(), is("unavailable")); |
| 40 | + assertThat(data.getErrors(), is(empty())); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void testGetDomainResearchStatusWithAvailableDomain() { |
| 45 | + server.stubFixtureAt("getDomainsResearchStatus/success-available.http"); |
| 46 | + |
| 47 | + SimpleResponse<DomainResearchStatus> response = client.domains.getDomainResearchStatus(1010, "available.com"); |
| 48 | + |
| 49 | + assertThat(response.getData(), is(notNullValue())); |
| 50 | + assertThat(response.getData().getAvailability(), is("available")); |
| 51 | + assertThat(response.getData().getDomain(), is("available.com")); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void testGetDomainResearchStatusWithUnsupportedTld() { |
| 56 | + server.stubFixtureAt("getDomainsResearchStatus/success-unsupported-tld.http"); |
| 57 | + |
| 58 | + SimpleResponse<DomainResearchStatus> response = client.domains.getDomainResearchStatus(1010, "example.unsupported"); |
| 59 | + |
| 60 | + assertThat(response.getData(), is(notNullValue())); |
| 61 | + assertThat(response.getData().getErrors(), is(not(empty()))); |
| 62 | + } |
| 63 | +} |
0 commit comments