use of com.quorum.tessera.config.ConfigFactory in project tessera by ConsenSys.
the class Q2TRestAppTest method getSingletons.
@Test
public void getSingletons() {
Config config = mock(Config.class);
ConfigFactory configFactory = mock(ConfigFactory.class);
when(configFactory.getConfig()).thenReturn(config);
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class)) {
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
Set<Object> results = q2TRestApp.getSingletons();
assertThat(results).hasSize(7);
List<Class> types = results.stream().map(Object::getClass).collect(Collectors.toList());
assertThat(types).containsExactlyInAnyOrder(TransactionResource.class, RawTransactionResource.class, EncodedPayloadResource.class, UpCheckResource.class, TransactionResource3.class, TransactionResource4.class, PrivacyGroupResource.class);
}
}
use of com.quorum.tessera.config.ConfigFactory in project tessera by ConsenSys.
the class PrivacyGroupPublisherProviderTest method provider.
@Test
public void provider() throws Exception {
Config config = mock(Config.class);
when(config.getP2PServerConfig()).thenReturn(mock(ServerConfig.class));
ConfigFactory configFactory = mock(ConfigFactory.class);
when(configFactory.getConfig()).thenReturn(config);
PrivacyGroupPublisher result;
try (var discoveryMockedStatic = mockStatic(Discovery.class);
var configFactoryMockedStatic = mockStatic(ConfigFactory.class)) {
discoveryMockedStatic.when(Discovery::create).thenReturn(mock(Discovery.class));
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
result = PrivacyGroupPublisherProvider.provider();
discoveryMockedStatic.verify(Discovery::create);
configFactoryMockedStatic.verify(ConfigFactory::create);
discoveryMockedStatic.verifyNoMoreInteractions();
configFactoryMockedStatic.verifyNoMoreInteractions();
}
assertThat(result).isNotNull();
}
use of com.quorum.tessera.config.ConfigFactory in project tessera by ConsenSys.
the class ConfigConverter method convert.
@Override
public Config convert(final String value) throws Exception {
final ConfigFactory configFactory = ConfigFactory.create();
final Path path = Paths.get(value);
if (!Files.exists(path)) {
throw new FileNotFoundException(String.format("%s not found.", path));
}
ConfigFileStore.create(path);
try (InputStream in = Files.newInputStream(path)) {
return configFactory.create(in);
}
}
use of com.quorum.tessera.config.ConfigFactory in project tessera by ConsenSys.
the class EnclaveClientProviderTest method beforeTest.
@Before
public void beforeTest() {
configFactory = mock(ConfigFactory.class);
Config config = mock(Config.class);
ServerConfig serverConfig = mock(ServerConfig.class);
when(serverConfig.getApp()).thenReturn(appType);
when(serverConfig.getServerUri()).thenReturn(URI.create("someEnclaveServerUri"));
when(config.getServerConfigs()).thenReturn(List.of(serverConfig));
when(configFactory.getConfig()).thenReturn(config);
}
use of com.quorum.tessera.config.ConfigFactory in project tessera by ConsenSys.
the class P2pClientProviderTest method provider.
@Test
public void provider() {
ConfigFactory configFactory = mock(ConfigFactory.class);
Config config = mock(Config.class);
when(config.getP2PServerConfig()).thenReturn(mock(ServerConfig.class));
when(configFactory.getConfig()).thenReturn(config);
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class)) {
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
P2pClient result = P2pClientProvider.provider();
assertThat(result).isNotNull().isExactlyInstanceOf(RestP2pClient.class);
verify(configFactory).getConfig();
verifyNoMoreInteractions(configFactory);
configFactoryMockedStatic.verify(ConfigFactory::create);
configFactoryMockedStatic.verifyNoMoreInteractions();
}
}
Aggregations