@Override public Stream<CoreExtension> loadedCoreExtensions() { checkInitialized(); return coreExtensions.stream(); }
@Test public void isInstalled_returns_true_for_loaded_and_installed_CoreExtension() { CoreExtension coreExtension = newCoreExtension(); underTest.setLoadedCoreExtensions(singleton(coreExtension)); underTest.installed(coreExtension); assertThat(underTest.isInstalled(coreExtension.getName())).isTrue(); }
@Test @UseDataProvider("coreExtensionsSets") public void isInstalled_returns_false_for_not_loaded_CoreExtension(Set<CoreExtension> coreExtensions) { underTest.setLoadedCoreExtensions(coreExtensions); assertThat(underTest.isInstalled("not loaded")).isFalse(); }
@Test @UseDataProvider("coreExtensionsSets") public void installed_fails_with_NPE_if_CoreExtension_is_null(Set<CoreExtension> coreExtensions) { underTest.setLoadedCoreExtensions(coreExtensions); expectedException.expect(NullPointerException.class); expectedException.expectMessage("coreExtension can't be null"); underTest.installed(null); }
@Test @UseDataProvider("coreExtensionsSets") public void loadedCoreExtensions_returns_CoreExtensions_from_setLoadedCoreExtensions(Set<CoreExtension> coreExtensions) { underTest.setLoadedCoreExtensions(coreExtensions); assertThat(underTest.loadedCoreExtensions().collect(Collectors.toSet())) .isEqualTo(coreExtensions); }
@Test public void setLoadedCoreExtensions_fails_with_NPE_if_argument_is_null() { expectedException.expect(NullPointerException.class); underTest.setLoadedCoreExtensions(null); }
@Test public void isInstalled_fails_with_ISE_if_called_before_setLoadedCoreExtensions() { expectRepositoryNotInitializedISE(); underTest.isInstalled("foo"); }
@Test public void loadedCoreExtensions_fails_with_ISE_if_called_before_setLoadedCoreExtensions() { expectRepositoryNotInitializedISE(); underTest.loadedCoreExtensions(); }
@Test public void installed_fails_with_ISE_if_called_before_setLoadedCoreExtensions() { CoreExtension coreExtension = newCoreExtension(); expectRepositoryNotInitializedISE(); underTest.installed(coreExtension); }
@Test public void isInstalled_returns_false_for_loaded_but_not_installed_CoreExtension() { CoreExtension coreExtension = newCoreExtension(); underTest.setLoadedCoreExtensions(singleton(coreExtension)); assertThat(underTest.isInstalled(coreExtension.getName())).isFalse(); }
@Test @UseDataProvider("coreExtensionsSets") public void installed_fails_with_IAE_if_CoreExtension_is_not_loaded(Set<CoreExtension> coreExtensions) { underTest.setLoadedCoreExtensions(coreExtensions); CoreExtension coreExtension = newCoreExtension(); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Specified CoreExtension has not been loaded first"); underTest.installed(coreExtension); }
@Test @UseDataProvider("coreExtensionsSets") public void setLoadedCoreExtensions_fails_with_ISE_if_called_twice(Set<CoreExtension> coreExtensions) { underTest.setLoadedCoreExtensions(coreExtensions); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Repository has already been initialized"); underTest.setLoadedCoreExtensions(coreExtensions); }
@Override public void installed(CoreExtension coreExtension) { checkInitialized(); requireNonNull(coreExtension, "coreExtension can't be null"); checkArgument(coreExtensions.contains(coreExtension), "Specified CoreExtension has not been loaded first"); this.installedCoreExtensions.add(coreExtension); }
@Override public boolean isInstalled(String coreExtensionName) { checkInitialized(); return installedCoreExtensions.stream() .anyMatch(t -> coreExtensionName.equals(t.getName())); }
@Override public Stream<CoreExtension> loadedCoreExtensions() { checkInitialized(); return coreExtensions.stream(); }
@Override public void installed(CoreExtension coreExtension) { checkInitialized(); requireNonNull(coreExtension, "coreExtension can't be null"); checkArgument(coreExtensions.contains(coreExtension), "Specified CoreExtension has not been loaded first"); this.installedCoreExtensions.add(coreExtension); }
@Override public boolean isInstalled(String coreExtensionName) { checkInitialized(); return installedCoreExtensions.stream() .anyMatch(t -> coreExtensionName.equals(t.getName())); }