List of usage examples for org.springframework.data.gemfire IndexFactoryBean.IndexWrapper IndexFactoryBean.IndexWrapper
protected IndexWrapper(QueryService queryService, String indexName)
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test @SuppressWarnings("deprecation") public void indexWrapperDelegation() { Index mockIndex = mockIndex("testIndexWrapperDelegation.MockIndex"); IndexStatistics mockIndexStats = mock(IndexStatistics.class, "testIndexWrapperDelegation.MockIndexStats"); QueryService mockQueryService = mock(QueryService.class, "testIndexWrapperDelegation.MockQueryService"); when(mockIndex.getCanonicalizedFromClause()).thenReturn("/Example"); when(mockIndex.getCanonicalizedIndexedExpression()).thenReturn("ID"); when(mockIndex.getCanonicalizedProjectionAttributes()).thenReturn("identifier"); when(mockIndex.getFromClause()).thenReturn("Example"); when(mockIndex.getIndexedExpression()).thenReturn("id"); when(mockIndex.getName()).thenReturn("MockIndex"); when(mockIndex.getProjectionAttributes()).thenReturn("id"); when(mockIndex.getStatistics()).thenReturn(mockIndexStats); when(mockIndex.getType()).thenReturn(org.apache.geode.cache.query.IndexType.HASH); when(mockQueryService.getIndexes()).thenReturn(Collections.singletonList(mockIndex)); IndexFactoryBean.IndexWrapper indexWrapper = new IndexFactoryBean.IndexWrapper(mockQueryService, "MockIndex"); assertThat(indexWrapper).isNotNull(); assertThat(indexWrapper.getIndexName()).isEqualTo("MockIndex"); assertThat(indexWrapper.getQueryService()).isEqualTo(mockQueryService); Index actualIndex = indexWrapper.resolveIndex(); assertThat(actualIndex).isSameAs(mockIndex); assertThat(indexWrapper.getCanonicalizedFromClause()).isEqualTo("/Example"); assertThat(indexWrapper.getCanonicalizedIndexedExpression()).isEqualTo("ID"); assertThat(indexWrapper.getCanonicalizedProjectionAttributes()).isEqualTo("identifier"); assertThat(indexWrapper.getFromClause()).isEqualTo("Example"); assertThat(indexWrapper.getIndexedExpression()).isEqualTo("id"); assertThat(indexWrapper.getName()).isEqualTo("MockIndex"); assertThat(indexWrapper.getProjectionAttributes()).isEqualTo("id"); assertThat(indexWrapper.getStatistics()).isSameAs(mockIndexStats); assertThat(indexWrapper.getType()).isEqualTo(org.apache.geode.cache.query.IndexType.HASH); Index sameIndex = indexWrapper.resolveIndex(); assertThat(sameIndex).isSameAs(actualIndex); }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test(expected = IllegalArgumentException.class) public void createIndexWrapperWithNullQueryService() { try {/*from ww w. j a v a 2 s . co m*/ new IndexFactoryBean.IndexWrapper(null, "TestIndex"); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage("QueryService is required"); assertThat(expected).hasNoCause(); throw expected; } }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test(expected = IllegalArgumentException.class) public void createIndexWrapperWithNoIndexName() { try {/*from w w w . ja v a2 s. com*/ new IndexFactoryBean.IndexWrapper(mockQueryService, " "); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage("Name of Index is required"); assertThat(expected).hasNoCause(); throw expected; } }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test(expected = GemfireIndexException.class) public void indexWrapperGetIndexThrowsExceptionWhenIndexNotFound() { when(mockQueryService.getIndexes()).thenReturn(Collections.emptyList()); IndexFactoryBean.IndexWrapper indexWrapper = new IndexFactoryBean.IndexWrapper(mockQueryService, "NonExistingIndex"); assertThat(indexWrapper).isNotNull(); assertThat(indexWrapper.getIndexName()).isEqualTo("NonExistingIndex"); assertThat(indexWrapper.getQueryService()).isSameAs(mockQueryService); try {/* w ww . j a va 2s. c o m*/ indexWrapper.resolveIndex(); } catch (GemfireIndexException expected) { assertThat(expected).hasMessage("Index with name [NonExistingIndex] was not found"); assertThat(expected).hasNoCause(); throw expected; } }