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;
}
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")));
}
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)));
}
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")));
}
Aggregations