use of com.quorum.tessera.transaction.EncodedPayloadManager in project tessera by ConsenSys.
the class EncodedPayloadManagerProviderTest method provider.
@Test
public void provider() {
try (var mockedEnclaveFactory = mockStatic(Enclave.class);
var mockedPrivacyHelper = mockStatic(PrivacyHelper.class);
var mockedPayloadDigest = mockStatic(PayloadDigest.class)) {
mockedPayloadDigest.when(PayloadDigest::create).thenReturn(mock(PayloadDigest.class));
mockedPrivacyHelper.when(PrivacyHelper::create).thenReturn(mock(PrivacyHelper.class));
mockedEnclaveFactory.when(Enclave::create).thenReturn(mock(Enclave.class));
EncodedPayloadManager encodedPayloadManager = EncodedPayloadManagerProvider.provider();
assertThat(encodedPayloadManager).isNotNull();
assertThat(encodedPayloadManager).describedAs("Subsequent invocations should return the same instance").isSameAs(EncodedPayloadManagerProvider.provider());
mockedPrivacyHelper.verify(PrivacyHelper::create);
mockedPrivacyHelper.verifyNoMoreInteractions();
mockedEnclaveFactory.verify(Enclave::create);
mockedEnclaveFactory.verifyNoMoreInteractions();
mockedPayloadDigest.verify(PayloadDigest::create);
mockedPayloadDigest.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.transaction.EncodedPayloadManager in project tessera by ConsenSys.
the class EncodedPayloadManagerProvider method provider.
public static EncodedPayloadManager provider() {
EncodedPayloadManagerHolder encodedPayloadManagerHolder = EncodedPayloadManagerHolder.INSTANCE;
if (encodedPayloadManagerHolder.getEncodedPayloadManager().isPresent()) {
return encodedPayloadManagerHolder.getEncodedPayloadManager().get();
}
Enclave enclave = Enclave.create();
PrivacyHelper privacyHelper = PrivacyHelper.create();
PayloadDigest payloadDigest = PayloadDigest.create();
EncodedPayloadManager encodedPayloadManager = new EncodedPayloadManagerImpl(enclave, privacyHelper, payloadDigest);
encodedPayloadManagerHolder.storeInstance(encodedPayloadManager);
return encodedPayloadManager;
}
Aggregations