Search in sources :

Example 6 with SearchRequest

use of org.codice.ddf.ui.searchui.query.model.SearchRequest in project ddf by codice.

the class SearchControllerTest method testExecuteQueryCacheDisabled.

/**
     * Verify that the CatalogFramework does not use the cache (i.e. the CatalogFramework
     * is called WITHOUT the query request property mode=cache).
     */
@Test
public void testExecuteQueryCacheDisabled() throws Exception {
    // Setup
    final String ID = "id";
    Set<String> srcIds = new HashSet<>(1);
    srcIds.add(ID);
    SearchRequest request = new SearchRequest(srcIds, getQueryRequest("title LIKE 'Meta*'"), ID);
    BayeuxServer bayeuxServer = mock(BayeuxServer.class);
    ServerChannel channel = mock(ServerChannel.class);
    when(bayeuxServer.getChannel(any(String.class))).thenReturn(channel);
    ArgumentCaptor<QueryRequest> queryRequestCaptor = ArgumentCaptor.forClass(QueryRequest.class);
    // Enable Cache
    searchController.setCacheDisabled(true);
    searchController.setBayeuxServer(bayeuxServer);
    // Perform Test
    searchController.executeQuery(request, mockServerSession, null);
    // Verify
    verify(framework).query(queryRequestCaptor.capture());
    assertThat(queryRequestCaptor.getValue().getProperties().size(), is(0));
}
Also used : SearchRequest(org.codice.ddf.ui.searchui.query.model.SearchRequest) QueryRequest(ddf.catalog.operation.QueryRequest) BayeuxServer(org.cometd.bayeux.server.BayeuxServer) Matchers.anyString(org.mockito.Matchers.anyString) ServerChannel(org.cometd.bayeux.server.ServerChannel) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

SearchRequest (org.codice.ddf.ui.searchui.query.model.SearchRequest)6 BayeuxServer (org.cometd.bayeux.server.BayeuxServer)5 ServerChannel (org.cometd.bayeux.server.ServerChannel)5 Matchers.anyString (org.mockito.Matchers.anyString)5 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 QueryRequest (ddf.catalog.operation.QueryRequest)3 ServerMessage (org.cometd.bayeux.server.ServerMessage)2 Mutable (org.cometd.bayeux.server.ServerMessage.Mutable)2 ServerSession (org.cometd.bayeux.server.ServerSession)2 CatalogFramework (ddf.catalog.CatalogFramework)1 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)1 Query (ddf.catalog.operation.Query)1 QueryResponse (ddf.catalog.operation.QueryResponse)1 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)1 ArrayList (java.util.ArrayList)1 ActionRegistryImpl (org.codice.ddf.ui.searchui.query.actions.ActionRegistryImpl)1 CQLException (org.geotools.filter.text.cql2.CQLException)1 Filter (org.opengis.filter.Filter)1