Search in sources :

Example 1 with LuceneDestroyIndexInfo

use of org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo in project geode by apache.

the class LuceneDestroyIndexFunctionJUnitTest method testDestroyIndexFailure.

@Test
@SuppressWarnings("unchecked")
public void testDestroyIndexFailure() throws Throwable {
    String indexName = "index1";
    String regionPath = "/region1";
    LuceneDestroyIndexInfo indexInfo = new LuceneDestroyIndexInfo(indexName, regionPath, false);
    when(this.context.getArguments()).thenReturn(indexInfo);
    LuceneDestroyIndexFunction function = new LuceneDestroyIndexFunction();
    function = spy(function);
    doReturn(this.cache).when(function).getCache();
    doThrow(new IllegalStateException()).when(this.service).destroyIndex(eq(indexName), eq(regionPath));
    function.execute(this.context);
    verifyFunctionResult(false);
}
Also used : LuceneDestroyIndexInfo(org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 2 with LuceneDestroyIndexInfo

use of org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo in project geode by apache.

the class LuceneDestroyIndexFunctionJUnitTest method testDestroyDefinedIndexFailure.

@Test
@SuppressWarnings("unchecked")
public void testDestroyDefinedIndexFailure() throws Throwable {
    String indexName = "index1";
    String regionPath = "/region1";
    LuceneDestroyIndexInfo indexInfo = new LuceneDestroyIndexInfo(indexName, regionPath, true);
    when(this.context.getArguments()).thenReturn(indexInfo);
    LuceneDestroyIndexFunction function = new LuceneDestroyIndexFunction();
    function = spy(function);
    doReturn(this.cache).when(function).getCache();
    doThrow(new IllegalStateException()).when(this.service).destroyDefinedIndex(eq(indexName), eq(regionPath));
    function.execute(this.context);
    verifyFunctionResult(false);
}
Also used : LuceneDestroyIndexInfo(org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 3 with LuceneDestroyIndexInfo

use of org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo in project geode by apache.

the class LuceneDestroyIndexFunctionJUnitTest method testDestroyDefinedIndexes.

@Test
@SuppressWarnings("unchecked")
public void testDestroyDefinedIndexes() throws Throwable {
    String regionPath = "/region1";
    LuceneDestroyIndexInfo indexInfo = new LuceneDestroyIndexInfo(null, regionPath, true);
    when(this.context.getArguments()).thenReturn(indexInfo);
    LuceneDestroyIndexFunction function = new LuceneDestroyIndexFunction();
    function = spy(function);
    doReturn(this.cache).when(function).getCache();
    function.execute(this.context);
    verify(this.service).destroyDefinedIndexes(eq(regionPath));
    verify(this.service, never()).destroyIndexes(eq(regionPath));
    verify(this.service, never()).destroyIndex(any(), eq(regionPath));
    verify(function, never()).getXmlEntity(eq("index1"), eq(regionPath));
    verifyFunctionResult(true);
}
Also used : LuceneDestroyIndexInfo(org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 4 with LuceneDestroyIndexInfo

use of org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo in project geode by apache.

the class LuceneDestroyIndexFunctionJUnitTest method testDestroyDefinedIndexesFailure.

@Test
@SuppressWarnings("unchecked")
public void testDestroyDefinedIndexesFailure() throws Throwable {
    String regionPath = "/region1";
    LuceneDestroyIndexInfo indexInfo = new LuceneDestroyIndexInfo(null, regionPath, true);
    when(this.context.getArguments()).thenReturn(indexInfo);
    LuceneDestroyIndexFunction function = new LuceneDestroyIndexFunction();
    function = spy(function);
    doReturn(this.cache).when(function).getCache();
    doThrow(new IllegalStateException()).when(this.service).destroyDefinedIndexes(eq(regionPath));
    function.execute(this.context);
    verifyFunctionResult(false);
}
Also used : LuceneDestroyIndexInfo(org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 5 with LuceneDestroyIndexInfo

use of org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo in project geode by apache.

the class LuceneDestroyIndexFunctionJUnitTest method testDestroyIndexes.

@Test
@SuppressWarnings("unchecked")
public void testDestroyIndexes() throws Throwable {
    String regionPath = "/region1";
    LuceneDestroyIndexInfo indexInfo = new LuceneDestroyIndexInfo(null, regionPath, false);
    when(this.context.getArguments()).thenReturn(indexInfo);
    LuceneDestroyIndexFunction function = new LuceneDestroyIndexFunction();
    function = spy(function);
    doReturn(this.cache).when(function).getCache();
    function.execute(this.context);
    verify(this.service).destroyIndexes(eq(regionPath));
    verify(function).getXmlEntity(eq(null), eq(regionPath));
    verify(this.service, never()).destroyDefinedIndexes(eq(regionPath));
    verify(this.service, never()).destroyIndex(any(), eq(regionPath));
    verifyFunctionResult(true);
}
Also used : LuceneDestroyIndexInfo(org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Aggregations

LuceneDestroyIndexInfo (org.apache.geode.cache.lucene.internal.cli.LuceneDestroyIndexInfo)9 UnitTest (org.apache.geode.test.junit.categories.UnitTest)8 Test (org.junit.Test)8 LuceneService (org.apache.geode.cache.lucene.LuceneService)1 LuceneServiceImpl (org.apache.geode.cache.lucene.internal.LuceneServiceImpl)1 CliFunctionResult (org.apache.geode.management.internal.cli.functions.CliFunctionResult)1