-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mattia Brescia
committed
May 13, 2024
1 parent
e502985
commit 0d484fc
Showing
2 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...-client-grpc/src/test/java/org/factcast/client/grpc/FactCastGrpcStubsFactoryImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.factcast.client.grpc; | ||
|
||
import io.grpc.Channel; | ||
import org.factcast.grpc.api.gen.RemoteFactStoreGrpc; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.MockedStatic; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class FactCastGrpcStubsFactoryImplTest { | ||
|
||
@Mock | ||
Channel channel; | ||
|
||
final FactCastGrpcStubsFactory uut = new FactCastGrpcStubsFactoryImpl(); | ||
|
||
@Test | ||
public void createsBlockingStub() { | ||
try (MockedStatic<RemoteFactStoreGrpc> mock = mockStatic(RemoteFactStoreGrpc.class)) { | ||
RemoteFactStoreGrpc.RemoteFactStoreBlockingStub stub = mock(RemoteFactStoreGrpc.RemoteFactStoreBlockingStub.class); | ||
mock.when(() -> RemoteFactStoreGrpc.newBlockingStub(channel)).thenReturn(stub); | ||
assertEquals(stub, uut.createBlockingStub(channel)); | ||
} | ||
} | ||
|
||
@Test | ||
public void createsStub() { | ||
try (MockedStatic<RemoteFactStoreGrpc> mock = mockStatic(RemoteFactStoreGrpc.class)) { | ||
RemoteFactStoreGrpc.RemoteFactStoreStub stub = mock(RemoteFactStoreGrpc.RemoteFactStoreStub.class); | ||
mock.when(() -> RemoteFactStoreGrpc.newStub(channel)).thenReturn(stub); | ||
assertEquals(stub, uut.createStub(channel)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters