@Override
    public PackageMaterialPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
        RepositoryConfiguration repositoryConfiguration = extension.getRepositoryConfiguration(descriptor.id());
        com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration packageConfiguration = extension.getPackageConfiguration(descriptor.id());

        if (repositoryConfiguration == null) {
            throw new RuntimeException(format("Plugin[%s] returned null repository configuration", descriptor.id()));
        }
        if (packageConfiguration == null) {
            throw new RuntimeException(format("Plugin[%s] returned null package configuration", descriptor.id()));
        }
        PluggableInstanceSettings pluginSettingsAndView = getPluginSettingsAndView(descriptor, extension);

        return new PackageMaterialPluginInfo(descriptor, new PluggableInstanceSettings(packageRepoConfigurations(repositoryConfiguration)), new PluggableInstanceSettings(packageRepoConfigurations(packageConfiguration)), pluginSettingsAndView);
    }
@Test
    public void shouldThrowAnExceptionWhenPackageConfigProvidedByPluginIsNull() {
        GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();

        when(extension.getPackageConfiguration("plugin1")).thenReturn(null);
        assertThatThrownBy(() -> new PackageMaterialPluginInfoBuilder(extension).pluginInfoFor(descriptor))
                .hasMessageContaining("Plugin[plugin1] returned null package configuration");
    }