Search in sources :

Example 6 with ConfigFactory

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);
    }
}
Also used : Config(com.quorum.tessera.config.Config) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Example 7 with ConfigFactory

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();
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) Discovery(com.quorum.tessera.discovery.Discovery) PrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.PrivacyGroupPublisher) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Example 8 with ConfigFactory

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);
    }
}
Also used : Path(java.nio.file.Path) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) ConfigFactory(com.quorum.tessera.config.ConfigFactory)

Example 9 with ConfigFactory

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);
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) ServerConfig(com.quorum.tessera.config.ServerConfig) Config(com.quorum.tessera.config.Config) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Before(org.junit.Before)

Example 10 with ConfigFactory

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();
    }
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) P2pClient(com.quorum.tessera.partyinfo.P2pClient) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Aggregations

ConfigFactory (com.quorum.tessera.config.ConfigFactory)20 Config (com.quorum.tessera.config.Config)17 Test (org.junit.Test)17 ServerConfig (com.quorum.tessera.config.ServerConfig)6 JdbcConfig (com.quorum.tessera.config.JdbcConfig)4 DataSourceFactory (com.quorum.tessera.data.DataSourceFactory)4 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)4 EncryptedRawTransactionDAO (com.quorum.tessera.data.EncryptedRawTransactionDAO)2 EncryptedTransactionDAO (com.quorum.tessera.data.EncryptedTransactionDAO)2 Discovery (com.quorum.tessera.discovery.Discovery)2 ClientSSLContextFactory (com.quorum.tessera.ssl.context.ClientSSLContextFactory)2 PayloadPublisher (com.quorum.tessera.transaction.publish.PayloadPublisher)2 Before (org.junit.Before)2 PrivacyGroupDAO (com.quorum.tessera.data.PrivacyGroupDAO)1 StagingEntityDAO (com.quorum.tessera.data.staging.StagingEntityDAO)1 Enclave (com.quorum.tessera.enclave.Enclave)1 EnclaveClient (com.quorum.tessera.enclave.EnclaveClient)1 PayloadDigest (com.quorum.tessera.enclave.PayloadDigest)1 P2pClient (com.quorum.tessera.partyinfo.P2pClient)1 PrivacyGroupPublisher (com.quorum.tessera.privacygroup.publish.PrivacyGroupPublisher)1