use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class PayloadPublisherProviderTest method provider.
@Test
public void provider() {
ConfigFactory configFactory = mock(ConfigFactory.class);
Config config = mock(Config.class);
ServerConfig serverConfig = mock(ServerConfig.class);
when(config.getP2PServerConfig()).thenReturn(serverConfig);
when(configFactory.getConfig()).thenReturn(config);
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class);
var discoveryMockedStatic = mockStatic(Discovery.class)) {
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
discoveryMockedStatic.when(Discovery::create).thenReturn(mock(Discovery.class));
PayloadPublisher payloadPublisher = PayloadPublisherProvider.provider();
assertThat(payloadPublisher).isNotNull();
configFactoryMockedStatic.verify(ConfigFactory::create);
configFactoryMockedStatic.verifyNoMoreInteractions();
discoveryMockedStatic.verify(Discovery::create);
discoveryMockedStatic.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class RecoveryClientProviderTest method provider.
@Test
public void provider() {
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class);
var clientSSLContextFactoryMockedStatic = mockStatic(ClientSSLContextFactory.class)) {
ConfigFactory configFactory = mock(ConfigFactory.class);
Config config = mock(Config.class);
ServerConfig serverConfig = mock(ServerConfig.class);
when(config.getP2PServerConfig()).thenReturn(serverConfig);
when(configFactory.getConfig()).thenReturn(config);
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
clientSSLContextFactoryMockedStatic.when(ClientSSLContextFactory::create).thenReturn(mock(ClientSSLContextFactory.class));
RecoveryClient recoveryClient = RecoveryClientProvider.provider();
assertThat(recoveryClient).isNotNull().isExactlyInstanceOf(RestRecoveryClient.class);
clientSSLContextFactoryMockedStatic.verify(ClientSSLContextFactory::create);
clientSSLContextFactoryMockedStatic.verifyNoMoreInteractions();
configFactoryMockedStatic.verify(ConfigFactory::create);
configFactoryMockedStatic.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class RecoveryClientProvider method provider.
public static RecoveryClient provider() {
final Config config = ConfigFactory.create().getConfig();
final ServerConfig serverConfig = config.getP2PServerConfig();
final Map<String, String> properties = serverConfig.getProperties();
final String waitTime = new IntervalPropertyHelper(properties).resendWaitTime();
final SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
final ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
final Client client = clientFactory.buildFrom(config.getP2PServerConfig());
client.property("jersey.config.client.readTimeout", waitTime);
return new RestRecoveryClient(client);
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ResendClientProvider method provider.
public static ResendClient provider() {
final Config config = ConfigFactory.create().getConfig();
final ServerConfig serverConfig = config.getP2PServerConfig();
final Map<String, String> properties = serverConfig.getProperties();
final String waitTime = new IntervalPropertyHelper(properties).resendWaitTime();
final SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
final ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
final Client client = clientFactory.buildFrom(config.getP2PServerConfig());
client.property("jersey.config.client.readTimeout", waitTime);
return new RestResendClient(client);
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ServerConfigsValidatorTest method onSetUp.
@Before
public void onSetUp() {
cvc = mock(ConstraintValidatorContext.class);
for (AppType appType : AppType.values()) {
ServerConfig serverConfig = new ServerConfig();
serverConfig.setApp(appType);
serverConfig.setServerAddress("localhost:123");
serverConfig.setCommunicationType(CommunicationType.REST);
serverConfig.setSslConfig(null);
serverConfig.setInfluxConfig(null);
serverConfig.setBindingAddress(null);
serverConfigsMap.put(appType, serverConfig);
}
validator = new ServerConfigsValidator();
when(cvc.buildConstraintViolationWithTemplate(anyString())).thenReturn(mock(ConstraintValidatorContext.ConstraintViolationBuilder.class));
}
Aggregations