@Test
public void shouldGetQueryParam() {
QueryParams queryParams = new QueryParamsImpl();
//get QueryParamOption Null
{
QueryParamOption option = queryParams.get(QueryParams.NUMBER_OF_COMMENTS_PARAM);
//
assertThat(option, nullValue());
}
//get QueryParamOption Not Null
{
queryParams.clear();
queryParams.append(QueryParams.IDENTITY_ID_PARAM.setValue("1234"));
QueryParamOption option = queryParams.get(QueryParams.IDENTITY_ID_PARAM);
assertThat(option, notNullValue());
assertThat((String)option.getValue(), equalTo("1234"));
}
//get QueryParamOption Not Null with more existing
{
queryParams.clear();
queryParams.append(QueryParams.IDENTITY_ID_PARAM.setValue("1234"))
.append(QueryParams.POSTER_IDENTITY_PARAM.setValue("1"))
.append(QueryParams.NUMBER_OF_COMMENTS_PARAM.setValue(10))
.append(QueryParams.NUMBER_OF_LIKES_PARAM.setValue(5))
.append(QueryParams.ACTIVITY_STREAM_PARAM)
.append(QueryParams.LIMIT_PARAM.setValue(20))
.append(QueryParams.SINCE_ID_PARAM.setValue("234567"))
.append(QueryParams.MAX_ID_PARAM.setValue("345678"));
QueryParamOption option = queryParams.get(QueryParams.IDENTITY_ID_PARAM);
assertThat(option, notNullValue());
assertThat((String)option.getValue(), equalTo("1234"));
}
}