Search in sources :

Example 1 with JobCollection

use of com.splunk.JobCollection in project camel by apache.

the class ConsumerStreamingTest method testSearch.

@Test
public void testSearch() throws Exception {
    MockEndpoint searchMock = getMockEndpoint("mock:search-result");
    searchMock.expectedMessageCount(3);
    JobCollection jobCollection = mock(JobCollection.class);
    Job jobMock = mock(Job.class);
    when(service.getJobs()).thenReturn(jobCollection);
    when(jobCollection.create(anyString(), any(JobArgs.class))).thenReturn(jobMock);
    when(jobMock.isDone()).thenReturn(Boolean.TRUE);
    InputStream stream = ConsumerTest.class.getResourceAsStream("/resultsreader_test_data.json");
    when(jobMock.getResults(any(JobResultsArgs.class))).thenReturn(stream);
    assertMockEndpointsSatisfied();
    SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
    assertNotNull(recieved);
    Map<String, String> data = recieved.getEventData();
    assertEquals("indexertpool", data.get("name"));
    stream.close();
}
Also used : JobResultsArgs(com.splunk.JobResultsArgs) SplunkEvent(org.apache.camel.component.splunk.event.SplunkEvent) JobCollection(com.splunk.JobCollection) JobArgs(com.splunk.JobArgs) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) InputStream(java.io.InputStream) Matchers.anyString(org.mockito.Matchers.anyString) Job(com.splunk.Job) Test(org.junit.Test)

Example 2 with JobCollection

use of com.splunk.JobCollection in project camel by apache.

the class ConsumerTest method testSearch.

@Test
public void testSearch() throws Exception {
    MockEndpoint searchMock = getMockEndpoint("mock:search-result");
    searchMock.expectedMessageCount(3);
    searchMock.expectedPropertyReceived(Exchange.BATCH_SIZE, 3);
    JobCollection jobCollection = mock(JobCollection.class);
    Job jobMock = mock(Job.class);
    when(service.getJobs()).thenReturn(jobCollection);
    when(jobCollection.create(anyString(), any(JobArgs.class))).thenReturn(jobMock);
    when(jobMock.isDone()).thenReturn(Boolean.TRUE);
    InputStream stream = ConsumerTest.class.getResourceAsStream("/resultsreader_test_data.json");
    when(jobMock.getResults(any(JobResultsArgs.class))).thenReturn(stream);
    assertMockEndpointsSatisfied();
    SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
    assertNotNull(recieved);
    Map<String, String> data = recieved.getEventData();
    assertEquals("indexertpool", data.get("name"));
    assertEquals(true, searchMock.getReceivedExchanges().get(2).getProperty(Exchange.BATCH_COMPLETE, Boolean.class));
    stream.close();
}
Also used : JobResultsArgs(com.splunk.JobResultsArgs) SplunkEvent(org.apache.camel.component.splunk.event.SplunkEvent) JobCollection(com.splunk.JobCollection) JobArgs(com.splunk.JobArgs) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) InputStream(java.io.InputStream) Matchers.anyString(org.mockito.Matchers.anyString) Job(com.splunk.Job) Test(org.junit.Test)

Aggregations

Job (com.splunk.Job)2 JobArgs (com.splunk.JobArgs)2 JobCollection (com.splunk.JobCollection)2 JobResultsArgs (com.splunk.JobResultsArgs)2 InputStream (java.io.InputStream)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 SplunkEvent (org.apache.camel.component.splunk.event.SplunkEvent)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2