Search in sources :

Example 1 with RedisScanResult

use of com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult in project azure-tools-for-java by microsoft.

the class RedisExplorerIntegrationTest method testScanMoreKey.

@Test
public void testScanMoreKey() throws Exception {
    final String testCursor = "3";
    List<String> expectedList = Arrays.asList(STRING_KEY, ZSET_KEY, HASHSET_KEY);
    Collections.sort(expectedList);
    redisExplorerPresenter.onKeyList(TEST_DB, testCursor, TEST_PATTERN);
    testSchedulerProvider.triggerActions();
    ArgumentCaptor<RedisScanResult> argument = ArgumentCaptor.forClass(RedisScanResult.class);
    verify(redisExplorerMvpViewMock).showScanResult(argument.capture());
    List<String> keys = argument.getValue().getKeys();
    Collections.sort(keys);
    assertEquals(keys, expectedList);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RedisScanResult(com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with RedisScanResult

use of com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult in project azure-tools-for-java by microsoft.

the class RedisExplorerPresenter method onKeyList.

/**
 * Called when Scan button is clicked.
 *
 * @param sid
 *            subscription id of Redis Cache
 * @param id
 *            resource id of Redis Cache
 * @param db
 *            index of Redis Cache database
 * @param cursor
 *            scan cursor for Redis Cache
 * @param pattern
 *            scan match pattern for Redis Cache
 */
public void onKeyList(int db, String cursor, String pattern) {
    Operation operation = TelemetryManager.createOperation(TelemetryConstants.REDIS, TelemetryConstants.REDIS_SCAN);
    operation.start();
    Observable.fromCallable(() -> {
        return RedisExplorerMvpModel.getInstance().scanKeys(sid, id, db, cursor, pattern);
    }).subscribeOn(getSchedulerProvider().io()).subscribe(result -> {
        DefaultLoader.getIdeHelper().invokeLater(() -> {
            if (isViewDetached()) {
                return;
            }
            getMvpView().showScanResult(new RedisScanResult(result));
            operation.complete();
        });
    }, e -> {
        EventUtil.logError(operation, ErrorType.userError, new Exception(e), null, null);
        operation.complete();
        errorHandler(CANNOT_GET_REDIS_INFO, (Exception) e);
    });
}
Also used : Operation(com.microsoft.azuretools.telemetrywrapper.Operation) RedisScanResult(com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult)

Example 3 with RedisScanResult

use of com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult in project azure-tools-for-java by microsoft.

the class RedisExplorerIntegrationTest method testScanPatternFilter.

@Test
public void testScanPatternFilter() throws Exception {
    String patternFilter = "testS*";
    List<String> expectedList = Arrays.asList(STRING_KEY, SET_KEY);
    Collections.sort(expectedList);
    redisExplorerPresenter.onKeyList(TEST_DB, TEST_CURSOR, patternFilter);
    testSchedulerProvider.triggerActions();
    ArgumentCaptor<RedisScanResult> argument = ArgumentCaptor.forClass(RedisScanResult.class);
    verify(redisExplorerMvpViewMock).showScanResult(argument.capture());
    List<String> keys = argument.getValue().getKeys();
    Collections.sort(keys);
    assertEquals(keys, expectedList);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RedisScanResult(com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with RedisScanResult

use of com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult in project azure-tools-for-java by Microsoft.

the class RedisExplorerIntegrationTest method testScanMoreKey.

@Test
public void testScanMoreKey() throws Exception {
    final String testCursor = "3";
    List<String> expectedList = Arrays.asList(STRING_KEY, ZSET_KEY, HASHSET_KEY);
    Collections.sort(expectedList);
    redisExplorerPresenter.onKeyList(TEST_DB, testCursor, TEST_PATTERN);
    testSchedulerProvider.triggerActions();
    ArgumentCaptor<RedisScanResult> argument = ArgumentCaptor.forClass(RedisScanResult.class);
    verify(redisExplorerMvpViewMock).showScanResult(argument.capture());
    List<String> keys = argument.getValue().getKeys();
    Collections.sort(keys);
    assertEquals(keys, expectedList);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RedisScanResult(com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with RedisScanResult

use of com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult in project azure-tools-for-java by Microsoft.

the class RedisExplorerIntegrationTest method testScanPatternFilter.

@Test
public void testScanPatternFilter() throws Exception {
    String patternFilter = "testS*";
    List<String> expectedList = Arrays.asList(STRING_KEY, SET_KEY);
    Collections.sort(expectedList);
    redisExplorerPresenter.onKeyList(TEST_DB, TEST_CURSOR, patternFilter);
    testSchedulerProvider.triggerActions();
    ArgumentCaptor<RedisScanResult> argument = ArgumentCaptor.forClass(RedisScanResult.class);
    verify(redisExplorerMvpViewMock).showScanResult(argument.capture());
    List<String> keys = argument.getValue().getKeys();
    Collections.sort(keys);
    assertEquals(keys, expectedList);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RedisScanResult(com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

RedisScanResult (com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult)6 Test (org.junit.Test)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Operation (com.microsoft.azuretools.telemetrywrapper.Operation)2