forked from grpc/grpc-java
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
a002bc2
commit b2bb9e1
Showing
3 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
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
10 changes: 6 additions & 4 deletions
10
services/src/main/java/io/grpc/protobuf/services/util/ReflectionServiceProtoAdapter.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 |
---|---|---|
@@ -1,17 +1,19 @@ | ||
package io.grpc.protobuf.services.util; | ||
|
||
|
||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import io.grpc.reflection.v1.ServerReflectionRequest; | ||
import io.grpc.reflection.v1.ServerReflectionResponse; | ||
|
||
public class ReflectionServiceProtoAdapter { | ||
public static ServerReflectionRequest toV1Request( | ||
io.grpc.reflection.v1alpha.ServerReflectionRequest serverReflectionRequest) { | ||
return null; | ||
io.grpc.reflection.v1alpha.ServerReflectionRequest serverReflectionRequest) | ||
throws InvalidProtocolBufferException { | ||
return ServerReflectionRequest.parseFrom(serverReflectionRequest.toByteArray()); | ||
} | ||
|
||
public static io.grpc.reflection.v1alpha.ServerReflectionResponse toV1AlphaResponse( | ||
ServerReflectionResponse serverReflectionResponse) { | ||
return null; | ||
ServerReflectionResponse serverReflectionResponse) throws InvalidProtocolBufferException { | ||
return io.grpc.reflection.v1alpha.ServerReflectionResponse.parseFrom(serverReflectionResponse.toByteArray()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
services/src/test/java/io/grpc/protobuf/services/ProtoReflectionServiceTest.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,27 @@ | ||
package io.grpc.protobuf.services; | ||
|
||
import io.grpc.reflection.v1alpha.ServerReflectionRequest; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnit; | ||
import org.mockito.junit.MockitoRule; | ||
|
||
@RunWith(JUnit4.class) | ||
public class ProtoReflectionServiceTest { | ||
@Rule | ||
public final MockitoRule mocks = MockitoJUnit.rule(); | ||
ProtoReflectionService protoReflectionService = (ProtoReflectionService) ProtoReflectionService.newInstance(); | ||
@Mock | ||
ProtoReflectionServiceV1 mockProtoReflectionServiceV1; | ||
private final ServerReflectionRequest serverReflectionRequestV1Alpha = ServerReflectionRequest.newBuilder() | ||
.build(); | ||
@Before | ||
public void setUp() { | ||
protoReflectionService.setProtoReflectionServiceV1(mockProtoReflectionServiceV1); | ||
} | ||
|
||
|
||
} |