StoredOrDefaultConfigurationProvider implements ConfigurationProvider { @Override public InputStream getConfigurationStream() { final InputStream configuration = storage.load(); if (configuration != null) { return configuration; } return getClass().getResourceAsStream("cloud-jenkins-defaults-assembly.zip"); } StoredOrDefaultConfigurationProvider(final Storage storage); @Override InputStream getConfigurationStream(); @Override Storage getStorage();  }
@Test public void testEmptyRepositoryProvidesDefaultConfiguration() throws IOException { final Storage storage = setupMockStorage(null); final InputStream configuration = new StoredOrDefaultConfigurationProvider(storage).getConfigurationStream(); final InputStream expectedStream = getClass().getResourceAsStream("cloud-jenkins-defaults-assembly.zip"); assertArrayEquals(IOUtils.toByteArray(expectedStream), IOUtils.toByteArray(configuration)); }
@Test public void testGetConfigurationFromECM() throws IOException { final InputStream expectedInputStream = mock(InputStream.class); final Storage storage = setupMockStorage(expectedInputStream); final InputStream configuration = new StoredOrDefaultConfigurationProvider(storage).getConfigurationStream(); assertSame(expectedInputStream, configuration); }