use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.
the class ConfigurationFileFactoryTest method testCreateConfigurationFileNullInput.
@Test(expected = IllegalArgumentException.class)
public void testCreateConfigurationFileNullInput() throws Exception {
// Setup
PersistenceStrategy mockPersistenceStrategy = mock(PersistenceStrategy.class);
ConfigurationFileFactory factory = new ConfigurationFileFactory(mockPersistenceStrategy, configAdmin);
// Perform Test
factory.createConfigurationFile((Path) null);
}
use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.
the class ConfigurationFileFactoryTest method testCreateConfigurationFileForManagedServiceFactory.
@Test
public void testCreateConfigurationFileForManagedServiceFactory() throws Exception {
// Setup
Dictionary<String, Object> properties = new Hashtable<>(1);
properties.put(ConfigurationAdmin.SERVICE_FACTORYPID, FACTORY_PID);
PersistenceStrategy mockPersistenceStrategy = getMockPersistenceStrategy(mockInputStream, properties);
ConfigurationFileFactory factory = new ConfigurationFileFactoryUnderTest(mockPersistenceStrategy, configAdmin);
// Perform Test
ConfigurationFile configFile = factory.createConfigurationFile(mockPath);
// Verify
assertThat(configFile, instanceOf(ManagedServiceFactoryConfigurationFile.class));
verify(mockPersistenceStrategy).read(mockInputStream);
}
use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.
the class ConfigurationFileFactoryTest method testCreateConfigurationFileForManagedService.
@Test
public void testCreateConfigurationFileForManagedService() throws Exception {
// Setup
Dictionary<String, Object> properties = new Hashtable<>(1);
properties.put(Constants.SERVICE_PID, PID);
PersistenceStrategy mockPersistenceStrategy = getMockPersistenceStrategy(mockInputStream, properties);
ConfigurationFileFactory factory = new ConfigurationFileFactoryUnderTest(mockPersistenceStrategy, configAdmin);
// Perform Test
ConfigurationFile configFile = factory.createConfigurationFile(mockPath);
// Verify
assertThat(configFile, instanceOf(ManagedServiceConfigurationFile.class));
verify(mockPersistenceStrategy).read(mockInputStream);
}
use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.
the class ConfigurationFileFactoryTest method getMockPersistenceStrategy.
private PersistenceStrategy getMockPersistenceStrategy(InputStream mockInputStream, Dictionary<String, Object> properties) throws Exception {
PersistenceStrategy mockPersistenceStrategy = mock(PersistenceStrategy.class);
when(mockPersistenceStrategy.read(mockInputStream)).thenReturn(properties);
return mockPersistenceStrategy;
}
Aggregations