[ 
https://issues.apache.org/jira/browse/CONNECTORS-1162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14633431#comment-14633431
 ] 

Karl Wright commented on CONNECTORS-1162:
-----------------------------------------

Hi Tugba,

Mockito uses the following pattern: "when().thenReturn()", followed by the 
method you are trying to test, then followed by "verify()".  The verify() will 
only mean anything if (a) you have installed an intercept, using a when() 
clause above, and (b) you subsequently have invoked the method being tested.  
Here's a sample from AlfrescoConnectorTest that demonstrates this sequence:

{code}
    when(client.fetchNodes(anyInt(), anyInt(), 
Mockito.any(AlfrescoFilters.class)))
            .thenReturn(new AlfrescoResponse(
                    lastTransactionId, lastAclChangesetId));

    connector.addSeedDocuments(mock(SeedingActivity.class),
            new Specification(), "", 0, 
BaseRepositoryConnector.JOBMODE_ONCEONLY);
    verify(client, times(1)).fetchNodes(eq(firstTransactionId), 
eq(firstAclChangesetId), Mockito.any(AlfrescoFilters.class));

    verify(client, times(1)).fetchNodes(eq(lastTransactionId), 
eq(lastAclChangesetId), Mockito.any(AlfrescoFilters.class));
{code}

In the code you pointed me at, there's a lot of commented out stuff, and also 
there's a "setProducer()" method in the connector itself.  It looks like you 
tried lots of things but basically did not get the intercept to work?  The code 
in place is wrong on two levels: (1) It has no intercept, and (2) the verify is 
BEFORE the method invocation, not afterwards.

Could you try to code up something that adheres to the above guidelines, and 
then we can systematically debug it?

Thanks!

> Apache Kafka Output Connector
> -----------------------------
>
>                 Key: CONNECTORS-1162
>                 URL: https://issues.apache.org/jira/browse/CONNECTORS-1162
>             Project: ManifoldCF
>          Issue Type: Wish
>    Affects Versions: ManifoldCF 1.8.1, ManifoldCF 2.0.1
>            Reporter: Rafa Haro
>            Assignee: Karl Wright
>              Labels: gsoc, gsoc2015
>             Fix For: ManifoldCF 1.10, ManifoldCF 2.2
>
>         Attachments: 1.JPG, 2.JPG
>
>
> Kafka is a distributed, partitioned, replicated commit log service. It 
> provides the functionality of a messaging system, but with a unique design. A 
> single Kafka broker can handle hundreds of megabytes of reads and writes per 
> second from thousands of clients.
> Apache Kafka is being used for a number of uses cases. One of them is to use 
> Kafka as a feeding system for streaming BigData processes, both in Apache 
> Spark or Hadoop environment. A Kafka output connector could be used for 
> streaming or dispatching crawled documents or metadata and put them in a 
> BigData processing pipeline



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to