Search in sources :

Example 1 with SearchDescription

use of br.com.caelum.restfulie.opensearch.SearchDescription in project restfulie-java by caelum.

the class ClientTest method search.

private Response search(String term, int page) {
    Response response = restfulie.at("http://localhost:3000/products/opensearch.xml").accept("application/opensearchdescription+xml").get();
    SearchDescription desc = response.getResource();
    response = desc.use("application/xml").with(queryFor(term)).and(page(page)).get();
    return response;
}
Also used : Response(br.com.caelum.restfulie.Response) SearchDescription(br.com.caelum.restfulie.opensearch.SearchDescription)

Example 2 with SearchDescription

use of br.com.caelum.restfulie.opensearch.SearchDescription in project restfulie-java by caelum.

the class TagsConverterTest method shouldConvertAnElementWithTwoTagsSeparetedByOneSpace.

@Test
public void shouldConvertAnElementWithTwoTagsSeparetedByOneSpace() {
    // Given
    String xml = "<OpenSearchDescription>" + "<Tags>restfulie rest</Tags>" + "</OpenSearchDescription>";
    // When
    SearchDescription desc = (SearchDescription) stream.fromXML(new StringReader(xml));
    // Then
    assertThat(desc.getTags().size(), is(equalTo(2)));
    assertThat(desc.getTags().get(0), is(equalTo("restfulie")));
    assertThat(desc.getTags().get(1), is(equalTo("rest")));
}
Also used : SearchDescription(br.com.caelum.restfulie.opensearch.SearchDescription) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 3 with SearchDescription

use of br.com.caelum.restfulie.opensearch.SearchDescription in project restfulie-java by caelum.

the class TagsConverterTest method shouldConvertAnEmptyElement.

@Test
public void shouldConvertAnEmptyElement() {
    // Given
    String xml = "<OpenSearchDescription>" + "<Tags></Tags>" + "</OpenSearchDescription>";
    // When
    SearchDescription desc = (SearchDescription) stream.fromXML(new StringReader(xml));
    // Then
    assertThat(desc.getTags().size(), is(equalTo(0)));
}
Also used : SearchDescription(br.com.caelum.restfulie.opensearch.SearchDescription) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 4 with SearchDescription

use of br.com.caelum.restfulie.opensearch.SearchDescription in project restfulie-java by caelum.

the class TagsConverterTest method shouldConvertAnElementWithThreeTagsSeparetedByMoreThanOneSpace.

@Test
public void shouldConvertAnElementWithThreeTagsSeparetedByMoreThanOneSpace() {
    // Given
    String xml = "<OpenSearchDescription>" + "<Tags>restfulie      rest      http</Tags>" + "</OpenSearchDescription>";
    // When
    SearchDescription desc = (SearchDescription) stream.fromXML(new StringReader(xml));
    // Then
    assertThat(desc.getTags().size(), is(equalTo(3)));
    assertThat(desc.getTags().get(0), is(equalTo("restfulie")));
    assertThat(desc.getTags().get(1), is(equalTo("rest")));
    assertThat(desc.getTags().get(2), is(equalTo("http")));
}
Also used : SearchDescription(br.com.caelum.restfulie.opensearch.SearchDescription) StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

SearchDescription (br.com.caelum.restfulie.opensearch.SearchDescription)4 StringReader (java.io.StringReader)3 Test (org.junit.Test)3 Response (br.com.caelum.restfulie.Response)1