Search in sources :

Example 41 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class MetricsClientTest method updateLogMetricTest.

@Test
@SuppressWarnings("all")
public void updateLogMetricTest() {
    String name = "name3373707";
    String description = "description-1724546052";
    String filter = "filter-1274492040";
    LogMetric expectedResponse = LogMetric.newBuilder().setName(name).setDescription(description).setFilter(filter).build();
    mockMetricsServiceV2.addResponse(expectedResponse);
    MetricNameOneof metricName = MetricNameOneof.from(MetricName.create("[PROJECT]", "[METRIC]"));
    LogMetric metric = LogMetric.newBuilder().build();
    LogMetric actualResponse = client.updateLogMetric(metricName, metric);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateLogMetricRequest actualRequest = (UpdateLogMetricRequest) actualRequests.get(0);
    Assert.assertEquals(metricName, actualRequest.getMetricNameAsMetricNameOneof());
    Assert.assertEquals(metric, actualRequest.getMetric());
}
Also used : UpdateLogMetricRequest(com.google.logging.v2.UpdateLogMetricRequest) LogMetric(com.google.logging.v2.LogMetric) MetricNameOneof(com.google.logging.v2.MetricNameOneof) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 42 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class MetricsClientTest method getLogMetricTest.

@Test
@SuppressWarnings("all")
public void getLogMetricTest() {
    String name = "name3373707";
    String description = "description-1724546052";
    String filter = "filter-1274492040";
    LogMetric expectedResponse = LogMetric.newBuilder().setName(name).setDescription(description).setFilter(filter).build();
    mockMetricsServiceV2.addResponse(expectedResponse);
    MetricNameOneof metricName = MetricNameOneof.from(MetricName.create("[PROJECT]", "[METRIC]"));
    LogMetric actualResponse = client.getLogMetric(metricName);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetLogMetricRequest actualRequest = (GetLogMetricRequest) actualRequests.get(0);
    Assert.assertEquals(metricName, actualRequest.getMetricNameAsMetricNameOneof());
}
Also used : LogMetric(com.google.logging.v2.LogMetric) MetricNameOneof(com.google.logging.v2.MetricNameOneof) GetLogMetricRequest(com.google.logging.v2.GetLogMetricRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 43 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class TraceServiceClientTest method listTracesTest.

@Test
@SuppressWarnings("all")
public void listTracesTest() {
    String nextPageToken = "";
    Trace tracesElement = Trace.newBuilder().build();
    List<Trace> traces = Arrays.asList(tracesElement);
    ListTracesResponse expectedResponse = ListTracesResponse.newBuilder().setNextPageToken(nextPageToken).addAllTraces(traces).build();
    mockTraceService.addResponse(expectedResponse);
    String projectId = "projectId-1969970175";
    ListTracesPagedResponse pagedListResponse = client.listTraces(projectId);
    List<Trace> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTracesList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockTraceService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTracesRequest actualRequest = (ListTracesRequest) actualRequests.get(0);
    Assert.assertEquals(projectId, actualRequest.getProjectId());
}
Also used : Trace(com.google.devtools.cloudtrace.v1.Trace) ListTracesResponse(com.google.devtools.cloudtrace.v1.ListTracesResponse) ListTracesPagedResponse(com.google.cloud.trace.spi.v1.PagedResponseWrappers.ListTracesPagedResponse) ListTracesRequest(com.google.devtools.cloudtrace.v1.ListTracesRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 44 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class TraceServiceClientTest method getTraceTest.

@Test
@SuppressWarnings("all")
public void getTraceTest() {
    String projectId2 = "projectId2939242356";
    String traceId2 = "traceId2987826376";
    Trace expectedResponse = Trace.newBuilder().setProjectId(projectId2).setTraceId(traceId2).build();
    mockTraceService.addResponse(expectedResponse);
    String projectId = "projectId-1969970175";
    String traceId = "traceId1270300245";
    Trace actualResponse = client.getTrace(projectId, traceId);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockTraceService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetTraceRequest actualRequest = (GetTraceRequest) actualRequests.get(0);
    Assert.assertEquals(projectId, actualRequest.getProjectId());
    Assert.assertEquals(traceId, actualRequest.getTraceId());
}
Also used : Trace(com.google.devtools.cloudtrace.v1.Trace) GetTraceRequest(com.google.devtools.cloudtrace.v1.GetTraceRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 45 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class TraceServiceClientTest method patchTracesTest.

@Test
@SuppressWarnings("all")
public void patchTracesTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockTraceService.addResponse(expectedResponse);
    String projectId = "projectId-1969970175";
    Traces traces = Traces.newBuilder().build();
    client.patchTraces(projectId, traces);
    List<GeneratedMessageV3> actualRequests = mockTraceService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    PatchTracesRequest actualRequest = (PatchTracesRequest) actualRequests.get(0);
    Assert.assertEquals(projectId, actualRequest.getProjectId());
    Assert.assertEquals(traces, actualRequest.getTraces());
}
Also used : Empty(com.google.protobuf.Empty) Traces(com.google.devtools.cloudtrace.v1.Traces) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) PatchTracesRequest(com.google.devtools.cloudtrace.v1.PatchTracesRequest) Test(org.junit.Test)

Aggregations

GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)75 Test (org.junit.Test)75 ByteString (com.google.protobuf.ByteString)13 Empty (com.google.protobuf.Empty)13 SubscriptionName (com.google.pubsub.v1.SubscriptionName)9 ArrayList (java.util.ArrayList)8 TopicName (com.google.pubsub.v1.TopicName)7 Document (com.google.cloud.language.v1beta2.Document)5 GroupName (com.google.monitoring.v3.GroupName)5 ProjectName (com.google.monitoring.v3.ProjectName)5 Document (com.google.cloud.language.v1.Document)4 EncodingType (com.google.cloud.language.v1beta2.EncodingType)4 ProjectName (com.google.devtools.clouderrorreporting.v1beta1.ProjectName)4 LogMetric (com.google.logging.v2.LogMetric)4 LogSink (com.google.logging.v2.LogSink)4 ParentNameOneof (com.google.logging.v2.ParentNameOneof)4 MetricDescriptor (com.google.api.MetricDescriptor)3 ResourceName (com.google.api.resourcenames.ResourceName)3 EncodingType (com.google.cloud.language.v1.EncodingType)3 Policy (com.google.iam.v1.Policy)3