Search in sources :

Example 16 with StateProvider

use of org.apache.nifi.components.state.StateProvider in project nifi by apache.

the class ITRedisStateProvider method testClear.

@Test
public void testClear() throws IOException {
    final StateProvider provider = getProvider();
    StateMap stateMap = provider.getState(componentId);
    assertNotNull(stateMap);
    assertEquals(-1L, stateMap.getVersion());
    assertTrue(stateMap.toMap().isEmpty());
    provider.setState(Collections.singletonMap("testClear", "value"), componentId);
    stateMap = provider.getState(componentId);
    assertNotNull(stateMap);
    assertEquals(0, stateMap.getVersion());
    assertEquals("value", stateMap.get("testClear"));
    provider.clear(componentId);
    stateMap = provider.getState(componentId);
    assertNotNull(stateMap);
    assertEquals(1L, stateMap.getVersion());
    assertTrue(stateMap.toMap().isEmpty());
}
Also used : StateProvider(org.apache.nifi.components.state.StateProvider) StateMap(org.apache.nifi.components.state.StateMap) Test(org.junit.Test)

Aggregations

StateProvider (org.apache.nifi.components.state.StateProvider)16 StateMap (org.apache.nifi.components.state.StateMap)15 Test (org.junit.Test)14 HashMap (java.util.HashMap)9 LinkedHashMap (java.util.LinkedHashMap)4 IOException (java.io.IOException)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 SSLContext (javax.net.ssl.SSLContext)1 StandardPropertyValue (org.apache.nifi.attribute.expression.language.StandardPropertyValue)1 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)1 PropertyValue (org.apache.nifi.components.PropertyValue)1 ValidationContext (org.apache.nifi.components.ValidationContext)1 ValidationResult (org.apache.nifi.components.ValidationResult)1 StateProviderInitializationContext (org.apache.nifi.components.state.StateProviderInitializationContext)1 ConfigParseException (org.apache.nifi.controller.state.ConfigParseException)1 StandardStateProviderInitializationContext (org.apache.nifi.controller.state.StandardStateProviderInitializationContext)1 StateManagerConfiguration (org.apache.nifi.controller.state.config.StateManagerConfiguration)1 StateProviderConfiguration (org.apache.nifi.controller.state.config.StateProviderConfiguration)1