Search in sources :

Example 1 with SolrCacheMBean

use of ddf.catalog.cache.SolrCacheMBean in project ddf by codice.

the class RemoveAllCommandTest method testExecuteWithSubjectWithCache.

/**
     * Checks the forced (-f) generic case with (--cache) option
     *
     * @throws Exception
     */
@Test
public void testExecuteWithSubjectWithCache() throws Exception {
    // given
    final SolrCacheMBean mbean = mock(SolrCacheMBean.class);
    RemoveAllCommand removeAllCommand = new RemoveAllCommand() {

        @Override
        protected SolrCacheMBean getCacheProxy() {
            return mbean;
        }
    };
    removeAllCommand.force = true;
    removeAllCommand.cache = true;
    // when
    removeAllCommand.executeWithSubject();
    // then
    verify(mbean, times(1)).removeAll();
}
Also used : SolrCacheMBean(ddf.catalog.cache.SolrCacheMBean) Test(org.junit.Test)

Example 2 with SolrCacheMBean

use of ddf.catalog.cache.SolrCacheMBean in project ddf by codice.

the class RemoveCommandTest method testNullList.

/**
     * Tests the {@Link RemoveCommand} when passed
     * a null list of ids
     *
     * @throws Exception
     */
@Test
public void testNullList() throws Exception {
    final SolrCacheMBean mbean = mock(SolrCacheMBean.class);
    RemoveCommand removeCommand = new RemoveCommand() {

        @Override
        protected SolrCacheMBean getCacheProxy() {
            return mbean;
        }
    };
    removeCommand.ids = null;
    removeCommand.executeWithSubject();
    assertThat(consoleOutput.getOutput(), containsString("Nothing to remove."));
}
Also used : SolrCacheMBean(ddf.catalog.cache.SolrCacheMBean) Test(org.junit.Test)

Example 3 with SolrCacheMBean

use of ddf.catalog.cache.SolrCacheMBean in project ddf by codice.

the class RemoveCommandTest method testMultipleItemList.

@Test
public void testMultipleItemList() throws Exception {
    final SolrCacheMBean mbean = mock(SolrCacheMBean.class);
    RemoveCommand removeCommand = new RemoveCommand() {

        @Override
        protected SolrCacheMBean getCacheProxy() {
            return mbean;
        }
    };
    List<String> ids = new ArrayList<>();
    ids.add(metacardList.get(0).getId());
    ids.add(metacardList.get(1).getId());
    ids.add(metacardList.get(2).getId());
    removeCommand.ids = ids;
    removeCommand.cache = true;
    removeCommand.executeWithSubject();
    String[] idsArray = new String[ids.size()];
    idsArray = ids.toArray(idsArray);
    verify(mbean, times(1)).removeById(idsArray);
}
Also used : SolrCacheMBean(ddf.catalog.cache.SolrCacheMBean) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 4 with SolrCacheMBean

use of ddf.catalog.cache.SolrCacheMBean in project ddf by codice.

the class RemoveCommandTest method testSingleItemList.

@Test
public void testSingleItemList() throws Exception {
    final SolrCacheMBean mbean = mock(SolrCacheMBean.class);
    RemoveCommand removeCommand = new RemoveCommand() {

        @Override
        protected SolrCacheMBean getCacheProxy() {
            return mbean;
        }
    };
    List<String> ids = new ArrayList<>();
    ids.add(metacardList.get(0).getId());
    removeCommand.ids = ids;
    removeCommand.cache = true;
    removeCommand.executeWithSubject();
    String[] idsArray = new String[ids.size()];
    idsArray = ids.toArray(idsArray);
    verify(mbean, times(1)).removeById(idsArray);
}
Also used : SolrCacheMBean(ddf.catalog.cache.SolrCacheMBean) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

SolrCacheMBean (ddf.catalog.cache.SolrCacheMBean)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2