SecurityAnalysisPreprocessors { public static SecurityAnalysisPreprocessorFactory wrap(ContingenciesProviderFactory factory) { return new ContingenciesProviderPreprocessorFactory(factory); } private  SecurityAnalysisPreprocessors(); static SecurityAnalysisPreprocessorFactory factoryForName(String name); static Optional<SecurityAnalysisPreprocessorFactory> defaultConfiguredFactory(); static Optional<SecurityAnalysisPreprocessorFactory> configuredFactory(PlatformConfig platformConfig); static Optional<SecurityAnalysisPreprocessorFactory> configuredFactory(SecurityAnalysisConfig config); static SecurityAnalysisPreprocessorFactory wrap(ContingenciesProviderFactory factory); static SecurityAnalysisPreprocessor contingenciesPreprocessor(ContingenciesProviderFactory factory,
                                                                   ByteSource source);  }
@Test public void contingenciesProviderPreprocessor() { ContingenciesProvider provider = Mockito.mock(ContingenciesProvider.class); ContingenciesProviderFactory providerFactory = () -> provider; SecurityAnalysisPreprocessorFactory factory = new ContingenciesProviderPreprocessorFactory(providerFactory); assertEquals("default", factory.getName()); SecurityAnalysisPreprocessor preprocessor = factory.newPreprocessor(ByteSource.wrap("".getBytes())); SecurityAnalysisInput input = new SecurityAnalysisInput(Mockito.mock(Network.class), "variant"); preprocessor.preprocess(input); assertSame(provider, input.getContingenciesProvider()); }
@Test public void wrappedContingenciesProviderFactory() { SecurityAnalysisPreprocessorFactory factory = SecurityAnalysisPreprocessors.wrap(new EmptyContingencyListProviderFactory()); assertNotNull(factory); SecurityAnalysisPreprocessor preprocessor = factory.newPreprocessor(ByteSource.empty()); SecurityAnalysisInput input = new SecurityAnalysisInput(Mockito.mock(Network.class), ""); preprocessor.preprocess(input); assertThat(input.getContingenciesProvider()) .isNotNull() .isInstanceOf(EmptyContingencyListProvider.class); }