Package com.streamreduce.core.service

Examples of com.streamreduce.core.service.SearchServiceImpl


    public void testSearchMessages() throws Exception {
        String json = JSONUtils.readJSONFromClasspath("/com/streamreduce/search/elastic_search_raw_payload.json");
        JSONObject elasticSearchPayload = JSONObject.fromObject(json);

        //Set these fields through reflection (mock prevents setters from working) to dummy values.
        SearchServiceImpl searchService = mock(SearchServiceImpl.class);
        ReflectionTestUtils.setField(searchService,"elasticSearchHost","doesNotMatter");
        ReflectionTestUtils.setField(searchService,"elasticSearchPort",666);
        ReflectionTestUtils.setField(searchService,"messageDatabaseName","nodeablemsgdb");
        ReflectionTestUtils.setField(searchService,"enabled",true);


        //Make sure calls to searchMessages uses the real implementation
        when(searchService.searchMessages(any(Account.class), anyString(), anyMap(), any(JSONObject.class))).thenCallRealMethod();
        //Make call to makeRequest so that it returns the elasticSearchPayload
        when(searchService.makeRequest(anyString(),any(JSONObject.class),anyMap(),anyString())).thenReturn(elasticSearchPayload);


        Account a = new Account.Builder().name("testAccount").build();
        a.setId(new ObjectId());

        List<SobaMessage> sobaMessages = searchService.searchMessages(a,"resource", null,null);

        //Expected number of hits in json:
        int expectedSize = elasticSearchPayload.getJSONObject("hits").getJSONArray("hits").size();
        Assert.assertEquals(expectedSize,sobaMessages.size());
    }
View Full Code Here


        Assert.assertEquals(expectedSize,sobaMessages.size());
    }

    @Test(expected = IllegalArgumentException.class)
    public void testCreateRiverForNullAccount() {
        SearchService searchService = new SearchServiceImpl();
        ReflectionTestUtils.setField(searchService,"enabled",true);
        searchService.createRiverForAccount(null);
    }
View Full Code Here

        Account acctWithoutId = new Account.Builder()
                .name("foo")
                .build();
        acctWithoutId.setId(null);

        SearchService searchService = new SearchServiceImpl();
        ReflectionTestUtils.setField(searchService,"enabled",true);
        searchService.createRiverForAccount(acctWithoutId);
    }
View Full Code Here

TOP

Related Classes of com.streamreduce.core.service.SearchServiceImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.