DDMRESTDataProvider implements DDMDataProvider { protected void setRequestParameters( DDMDataProviderRequest ddmDataProviderRequest, DDMRESTDataProviderSettings ddmRESTDataProviderSettings, HttpRequest httpRequest) { if (ddmRESTDataProviderSettings.filterable()) { Optional<String> filterParameterValue = ddmDataProviderRequest.getParameterOptional( "filterParameterValue", String.class); if (filterParameterValue.isPresent()) { httpRequest.query( ddmRESTDataProviderSettings.filterParameterName(), filterParameterValue.get()); } } if (ddmRESTDataProviderSettings.pagination()) { Optional<String> paginationStart = ddmDataProviderRequest.getParameterOptional( "paginationStart", String.class); if (paginationStart.isPresent()) { httpRequest.query( ddmRESTDataProviderSettings.paginationStartParameterName(), paginationStart.get()); } Optional<String> paginationEnd = ddmDataProviderRequest.getParameterOptional( "paginationEnd", String.class); if (paginationEnd.isPresent()) { httpRequest.query( ddmRESTDataProviderSettings.paginationEndParameterName(), paginationEnd.get()); } } httpRequest.query( getQueryParameters( ddmDataProviderRequest, ddmRESTDataProviderSettings)); }  @Override DDMDataProviderResponse getData(
			DDMDataProviderRequest ddmDataProviderRequest); @Override Class<?> getSettings();  }
@Test public void testSetRequestParameters() { DDMRESTDataProviderSettings ddmRESTDataProviderSettings = mock( DDMRESTDataProviderSettings.class); when( ddmRESTDataProviderSettings.url() ).thenReturn( "http: ); when( ddmRESTDataProviderSettings.filterable() ).thenReturn( true ); when( ddmRESTDataProviderSettings.inputParameters() ).thenReturn( new DDMDataProviderInputParametersSettings[0] ); when( ddmRESTDataProviderSettings.pagination() ).thenReturn( true ); when( ddmRESTDataProviderSettings.filterParameterName() ).thenReturn( "country" ); when( ddmRESTDataProviderSettings.paginationStartParameterName() ).thenReturn( "start" ); when( ddmRESTDataProviderSettings.paginationEndParameterName() ).thenReturn( "end" ); HttpRequest httpRequest = mock(HttpRequest.class); HttpRequest spy = spy(httpRequest); DDMDataProviderRequest.Builder builder = DDMDataProviderRequest.Builder.newBuilder(); DDMDataProviderRequest ddmDataProviderRequest = builder.withParameter( "filterParameterValue", "brazil" ).withParameter( "paginationStart", "1" ).withParameter( "paginationEnd", "10" ).build(); _ddmRESTDataProvider.setRequestParameters( ddmDataProviderRequest, ddmRESTDataProviderSettings, spy); ArgumentCaptor<String> name = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> value = ArgumentCaptor.forClass(String.class); Mockito.verify( spy, Mockito.times(3) ).query( name.capture(), value.capture() ); List<String> names = new ArrayList<String>() { { add("country"); add("start"); add("end"); } }; Assert.assertEquals(names, name.getAllValues()); List<String> values = new ArrayList<String>() { { add("brazil"); add("1"); add("10"); } }; Assert.assertEquals(values, value.getAllValues()); }