@@ -0,0 +1,2971 @@
+package uk.ac.ebi.quickgo.client.service.loader.presets;%0A%0Aimport uk.ac.ebi.quickgo.rest.search.RetrievalException;%0Aimport uk.ac.ebi.quickgo.rest.search.request.FilterRequest;%0Aimport uk.ac.ebi.quickgo.rest.search.request.converter.ConvertedFilter;%0Aimport uk.ac.ebi.quickgo.rest.search.request.converter.RESTFilterConverterFactory;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.Optional;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.collection.IsCollectionWithSize.hasSize;%0Aimport static org.hamcrest.core.Is.is;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.when;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class RestValuesRetrieverTest %7B%0A%0A    private static final String RETRIEVE_KEY = %22BogusKey%22;%0A    RestValuesRetriever retriever;%0A%0A    @Mock RESTFilterConverterFactory converterFactory;%0A%0A    ConvertedFilter%3CList%3CString%3E%3E convertedValuesFound;%0A    ConvertedFilter%3CList%3CString%3E%3E convertedValuesNotFound;%0A%0A    @Before%0A    public void setup() %7B%0A        List%3CString%3E returnValues = Arrays.asList(%22Brandish%22, %22Bungalow%22);%0A        convertedValuesFound = new ConvertedFilter%3C%3E(returnValues);%0A        convertedValuesNotFound = new ConvertedFilter%3C%3E(Collections.emptyList());%0A        retriever = new RestValuesRetriever(converterFactory);%0A    %7D%0A%0A    @Test%0A    public void valuesAreRetrieved() %7B%0A        when(converterFactory.%3CList%3CString%3E%3Econvert(any(FilterRequest.class))).thenReturn(convertedValuesFound);%0A%0A        Optional%3CList%3CString%3E%3E retrievedValues = retriever.retrieveValues(RETRIEVE_KEY);%0A%0A        assertThat(retrievedValues.isPresent(), is(true));%0A        assertThat(retrievedValues.get(), hasSize(2));%0A%0A    %7D%0A%0A    @Test%0A    public void noValueRetrievedButNoExceptionThrown() %7B%0A        when(converterFactory.%3CList%3CString%3E%3Econvert(any(FilterRequest.class))).thenReturn(convertedValuesNotFound);%0A%0A        Optional%3CList%3CString%3E%3E retrievedValues = retriever.retrieveValues(RETRIEVE_KEY);%0A%0A        assertThat(retrievedValues.isPresent(), is(true));%0A        assertThat(retrievedValues.get(), hasSize(0));%0A    %7D%0A%0A    @Test%0A    public void illegalStateExceptionThrownDuringRetrieval() %7B%0A        when(converterFactory.%3CList%3CString%3E%3Econvert(any(FilterRequest.class))).thenThrow(IllegalStateException.class);%0A%0A        Optional%3CList%3CString%3E%3E retrievedValues = retriever.retrieveValues(RETRIEVE_KEY);%0A%0A        assertThat(retrievedValues.isPresent(), is(false));%0A    %7D%0A%0A    @Test%0A    public void retrievalExceptionThrownDuringRetrieval() %7B%0A        when(converterFactory.%3CList%3CString%3E%3Econvert(any(FilterRequest.class))).thenThrow(RetrievalException.class);%0A%0A        Optional%3CList%3CString%3E%3E retrievedValues = retriever.retrieveValues(RETRIEVE_KEY);%0A%0A        assertThat(retrievedValues.isPresent(), is(false));%0A    %7D%0A%0A%7D

Test RestValuesRetriever