Example usage for org.springframework.data.gemfire IndexFactoryBean getObjectType

List of usage examples for org.springframework.data.gemfire IndexFactoryBean getObjectType

Introduction

In this page you can find the example usage for org.springframework.data.gemfire IndexFactoryBean getObjectType.

Prototype

@Override
@SuppressWarnings("unchecked")
public Class<?> getObjectType() 

Source Link

Usage

From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java

@Test
@SuppressWarnings("all")
public void afterPropertiesSetIsSuccessful() throws Exception {

    ConfigurableBeanFactory mockConfigurableBeanFactory = mock(ConfigurableBeanFactory.class);

    Index mockIndex = mock(Index.class, "testAfterPropertiesSetIsSuccessful.MockIndex");

    when(mockQueryService.createKeyIndex(eq("TestKeyIndex"), eq("id"), eq("/Example"))).thenReturn(mockIndex);

    IndexFactoryBean indexFactoryBean = newIndexFactoryBean();

    indexFactoryBean.setBeanFactory(mockConfigurableBeanFactory);
    indexFactoryBean.setBeanName("KeyIndexBean");
    indexFactoryBean.setDefine(false);/*from ww  w  . j  a va 2  s .com*/
    indexFactoryBean.setExpression("id");
    indexFactoryBean.setFrom("/Example");
    indexFactoryBean.setName("TestKeyIndex");
    indexFactoryBean.setType("key");
    indexFactoryBean.afterPropertiesSet();

    assertThat(indexFactoryBean.getIndex()).isEqualTo(mockIndex);

    Index actualIndex = indexFactoryBean.getObject();

    assertThat(actualIndex).isEqualTo(mockIndex);
    assertThat(indexFactoryBean.getObject()).isSameAs(actualIndex);
    assertThat(Index.class).isAssignableFrom(indexFactoryBean.getObjectType());
    assertThat(indexFactoryBean.isSingleton()).isTrue();

    verify(indexFactoryBean, times(1)).getBeanName();
    verify(indexFactoryBean, never()).lookupQueryService();
    verify(mockConfigurableBeanFactory, times(1)).registerAlias(eq("KeyIndexBean"), eq("TestKeyIndex"));
    verify(mockQueryService, times(1)).createKeyIndex(eq("TestKeyIndex"), eq("id"), eq("/Example"));
    verifyZeroInteractions(mockCache);
}

From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java

@Test
@SuppressWarnings("all")
public void getObjectTypeReturnsMockIndexClassType() throws Exception {

    Index mockIndex = mockIndex("MockIndex");

    IndexFactoryBean indexFactoryBean = newIndexFactoryBean();

    doReturn(mockIndex).when(indexFactoryBean).getIndex();

    assertThat(indexFactoryBean.getObjectType()).isEqualTo(mockIndex.getClass());
}