Search in sources :

Example 1 with FileSystemConfigurationCache

use of org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache in project nifi-minifi by apache.

the class FileSystemConfigurationCacheTest method getConfigurationTest.

@Test
public void getConfigurationTest() throws IOException, ConfigurationProviderException {
    final String pathRoot = "files";
    final String pathPattern = "config";
    FileSystemConfigurationCache cache = new FileSystemConfigurationCache(pathRoot, pathPattern);
    Map<String, List<String>> parameters = new HashMap<>();
    ConfigurationCacheFileInfo info = cache.getCacheFileInfo("text/yaml", parameters);
    WriteableConfiguration configuration = info.getConfiguration(1);
    assertEquals("config.text.yaml.v1", configuration.getName());
    assertEquals("1", configuration.getVersion());
    assertTrue(configuration.exists());
}
Also used : HashMap(java.util.HashMap) WriteableConfiguration(org.apache.nifi.minifi.c2.api.cache.WriteableConfiguration) FileSystemConfigurationCache(org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache) List(java.util.List) ConfigurationCacheFileInfo(org.apache.nifi.minifi.c2.api.cache.ConfigurationCacheFileInfo) Test(org.junit.Test)

Example 2 with FileSystemConfigurationCache

use of org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache in project nifi-minifi by apache.

the class FileSystemConfigurationCacheTest method getConfigurationInvalidParametersTest.

@Test(expected = InvalidParameterException.class)
public void getConfigurationInvalidParametersTest() throws IOException, InvalidParameterException {
    final String pathRoot = "files";
    final String pathPattern = "${test}/config";
    FileSystemConfigurationCache cache = new FileSystemConfigurationCache(pathRoot, pathPattern);
    Map<String, List<String>> parameters = new HashMap<>();
    cache.getCacheFileInfo("test/contenttype", parameters);
}
Also used : HashMap(java.util.HashMap) FileSystemConfigurationCache(org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache) List(java.util.List) Test(org.junit.Test)

Example 3 with FileSystemConfigurationCache

use of org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache in project nifi-minifi by apache.

the class FileSystemConfigurationCacheTest method getCachedConfigurationsTest.

@Test
public void getCachedConfigurationsTest() throws IOException, ConfigurationProviderException {
    final String pathRoot = "files";
    final String pathPattern = "config";
    FileSystemConfigurationCache cache = new FileSystemConfigurationCache(pathRoot, pathPattern);
    Map<String, List<String>> parameters = new HashMap<>();
    ConfigurationCacheFileInfo info = cache.getCacheFileInfo("text/yaml", parameters);
    Stream<WriteableConfiguration> configs = info.getCachedConfigurations();
    assertEquals(1, configs.count());
}
Also used : HashMap(java.util.HashMap) WriteableConfiguration(org.apache.nifi.minifi.c2.api.cache.WriteableConfiguration) FileSystemConfigurationCache(org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache) List(java.util.List) ConfigurationCacheFileInfo(org.apache.nifi.minifi.c2.api.cache.ConfigurationCacheFileInfo) Test(org.junit.Test)

Example 4 with FileSystemConfigurationCache

use of org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache in project nifi-minifi by apache.

the class FileSystemConfigurationCacheTest method getNonexistantConfigurationTest.

@Test
public void getNonexistantConfigurationTest() throws IOException, ConfigurationProviderException {
    final String pathRoot = "files";
    final String pathPattern = "config";
    FileSystemConfigurationCache cache = new FileSystemConfigurationCache(pathRoot, pathPattern);
    Map<String, List<String>> parameters = new HashMap<>();
    ConfigurationCacheFileInfo info = cache.getCacheFileInfo("test/contenttype", parameters);
    WriteableConfiguration configuration = info.getConfiguration(1);
    assertEquals("config.test.contenttype.v1", configuration.getName());
    assertEquals("1", configuration.getVersion());
    assertFalse(configuration.exists());
}
Also used : HashMap(java.util.HashMap) WriteableConfiguration(org.apache.nifi.minifi.c2.api.cache.WriteableConfiguration) FileSystemConfigurationCache(org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache) List(java.util.List) ConfigurationCacheFileInfo(org.apache.nifi.minifi.c2.api.cache.ConfigurationCacheFileInfo) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)4 List (java.util.List)4 FileSystemConfigurationCache (org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache)4 Test (org.junit.Test)4 ConfigurationCacheFileInfo (org.apache.nifi.minifi.c2.api.cache.ConfigurationCacheFileInfo)3 WriteableConfiguration (org.apache.nifi.minifi.c2.api.cache.WriteableConfiguration)3