| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.activeinstalls.internal.client; |
| 21 |
|
|
| 22 |
|
import static org.mockito.ArgumentMatchers.any; |
| 23 |
|
import static org.mockito.Mockito.mock; |
| 24 |
|
import static org.mockito.Mockito.verify; |
| 25 |
|
import static org.mockito.Mockito.when; |
| 26 |
|
import io.searchbox.client.JestClient; |
| 27 |
|
import io.searchbox.core.DocumentResult; |
| 28 |
|
import io.searchbox.core.Index; |
| 29 |
|
|
| 30 |
|
import org.junit.Rule; |
| 31 |
|
import org.junit.Test; |
| 32 |
|
import org.xwiki.activeinstalls.internal.JestClientManager; |
| 33 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
| 34 |
|
|
| 35 |
|
import com.google.gson.Gson; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@link |
| 39 |
|
|
| 40 |
|
@version |
| 41 |
|
@since |
| 42 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.1 |
|
| 43 |
|
public class DefaultPingSenderTest |
| 44 |
|
{ |
| 45 |
|
@Rule |
| 46 |
|
public MockitoComponentMockingRule<DefaultPingSender> mocker = |
| 47 |
|
new MockitoComponentMockingRule<>(DefaultPingSender.class); |
| 48 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 49 |
1 |
@Test... |
| 50 |
|
public void sendPing() throws Exception |
| 51 |
|
{ |
| 52 |
1 |
JestClient client = mock(JestClient.class); |
| 53 |
1 |
DocumentResult indexResult = new DocumentResult(new Gson()); |
| 54 |
1 |
indexResult.setSucceeded(true); |
| 55 |
1 |
when(client.execute(any(Index.class))).thenReturn(indexResult); |
| 56 |
|
|
| 57 |
1 |
JestClientManager jestManager = this.mocker.getInstance(JestClientManager.class); |
| 58 |
1 |
when(jestManager.getClient()).thenReturn(client); |
| 59 |
|
|
| 60 |
1 |
PingDataProvider pingDataProvider = this.mocker.registerMockComponent(PingDataProvider.class, "test"); |
| 61 |
|
|
| 62 |
1 |
this.mocker.getComponentUnderTest().sendPing(); |
| 63 |
|
|
| 64 |
|
|
| 65 |
1 |
verify(pingDataProvider).provideMapping(); |
| 66 |
1 |
verify(pingDataProvider).provideData(); |
| 67 |
|
} |
| 68 |
|
} |