Search in sources :

Example 1 with SearchHashesResponse

use of com.google.webrisk.v1beta1.SearchHashesResponse in project java-webrisk by googleapis.

the class WebRiskServiceV1Beta1ClientTest method searchHashesTest.

@Test
public void searchHashesTest() throws Exception {
    SearchHashesResponse expectedResponse = SearchHashesResponse.newBuilder().addAllThreats(new ArrayList<SearchHashesResponse.ThreatHash>()).setNegativeExpireTime(Timestamp.newBuilder().build()).build();
    mockWebRiskServiceV1Beta1.addResponse(expectedResponse);
    ByteString hashPrefix = ByteString.EMPTY;
    List<ThreatType> threatTypes = new ArrayList<>();
    SearchHashesResponse actualResponse = client.searchHashes(hashPrefix, threatTypes);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockWebRiskServiceV1Beta1.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    SearchHashesRequest actualRequest = ((SearchHashesRequest) actualRequests.get(0));
    Assert.assertEquals(hashPrefix, actualRequest.getHashPrefix());
    Assert.assertEquals(threatTypes, actualRequest.getThreatTypesList());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) ThreatType(com.google.webrisk.v1beta1.ThreatType) SearchHashesRequest(com.google.webrisk.v1beta1.SearchHashesRequest) SearchHashesResponse(com.google.webrisk.v1beta1.SearchHashesResponse) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with SearchHashesResponse

use of com.google.webrisk.v1beta1.SearchHashesResponse in project java-webrisk by googleapis.

the class WebRiskServiceClientTest method searchHashesTest.

@Test
public void searchHashesTest() throws Exception {
    SearchHashesResponse expectedResponse = SearchHashesResponse.newBuilder().addAllThreats(new ArrayList<SearchHashesResponse.ThreatHash>()).setNegativeExpireTime(Timestamp.newBuilder().build()).build();
    mockWebRiskService.addResponse(expectedResponse);
    ByteString hashPrefix = ByteString.EMPTY;
    List<ThreatType> threatTypes = new ArrayList<>();
    SearchHashesResponse actualResponse = client.searchHashes(hashPrefix, threatTypes);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockWebRiskService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    SearchHashesRequest actualRequest = ((SearchHashesRequest) actualRequests.get(0));
    Assert.assertEquals(hashPrefix, actualRequest.getHashPrefix());
    Assert.assertEquals(threatTypes, actualRequest.getThreatTypesList());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) ThreatType(com.google.webrisk.v1.ThreatType) SearchHashesRequest(com.google.webrisk.v1.SearchHashesRequest) SearchHashesResponse(com.google.webrisk.v1.SearchHashesResponse) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)2 ByteString (com.google.protobuf.ByteString)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 SearchHashesRequest (com.google.webrisk.v1.SearchHashesRequest)1 SearchHashesResponse (com.google.webrisk.v1.SearchHashesResponse)1 ThreatType (com.google.webrisk.v1.ThreatType)1 SearchHashesRequest (com.google.webrisk.v1beta1.SearchHashesRequest)1 SearchHashesResponse (com.google.webrisk.v1beta1.SearchHashesResponse)1 ThreatType (com.google.webrisk.v1beta1.ThreatType)1