diff --git a/google-checks.xml b/google-checks.xml index e567fc7f8d3..aa1e5335b6b 100644 --- a/google-checks.xml +++ b/google-checks.xml @@ -2,6 +2,21 @@ + - @@ -25,11 +38,13 @@ - - - + + + + + @@ -179,6 +194,7 @@ + @@ -198,4 +214,7 @@ + + + diff --git a/monitoring/v3/README.md b/monitoring/v3/README.md index 728d7ac5a5b..f4bab7aca50 100644 --- a/monitoring/v3/README.md +++ b/monitoring/v3/README.md @@ -15,8 +15,9 @@ Go to the [Google Developers Console](https://console.developer.google.com). * Go too API Manager -> Credentials * Click ['New Credentials', and create a Service Account](https://console.developers.google.com/project/_/apiui/credential/serviceaccount) - Download the JSON for this service account, and set the `GOOGLE_APPLICATION_CREDENTIALS` - environment variable to point to the file containing the JSON credentials. + Download the JSON for this service account, and set the + `GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to the file + containing the JSON credentials. ``` export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/-0123456789abcdef.json @@ -26,23 +27,25 @@ Go to the [Google Developers Console](https://console.developer.google.com). To run locally: * `mvn clean install` - * `./run_monitoring_example.sh + * `./list_resources_example.sh * `./run_custom_metrics.sh ## Run Tests -The tests emulate what the scripts accomplish, so there isn't a reason why they need to be run if the examples work. -However, if you'd like to run them, change TEST_PROJECT_ID in ListResourcesTest to the appropriate project ID -that matches the Service Account pointed to by GOOGLE_APPLICATION_CREDENTIALS, then run: +The tests emulate what the scripts accomplish, so there isn't a reason why they +need to be run if the examples work. However, if you'd like to run them, change +`TEST_PROJECT_ID` in [`ListResourcesTest`](src/test/java/ListResourcesTest.java) +to the appropriate project ID that matches the Service Account pointed to by +`GOOGLE_APPLICATION_CREDENTIALS`, then run: mvn test -DskipTests=false ## Contributing changes -See CONTRIBUTING.md +See [CONTRIBUTING.md](../../CONTRIBUTING.md). ## Licensing -* See [LICENSE](LICENSE) +See [LICENSE](../../LICENSE). diff --git a/monitoring/v3/pom.xml b/monitoring/v3/pom.xml index 050db509de7..841e6c3bd96 100644 --- a/monitoring/v3/pom.xml +++ b/monitoring/v3/pom.xml @@ -14,7 +14,6 @@ ../.. - 1.19.0 1.19.0 @@ -43,38 +42,45 @@ google-oauth-client-jetty ${project.oauth.version} + + joda-time + joda-time + 2.9 + + + org.apache.commons + commons-lang3 + 3.4 + + + com.google.apis + google-api-services-monitoring + v3-rev1-1.21.0 + com.google.code.gson gson 2.3.1 + + junit junit - test 4.12 + test com.jcabi jcabi-matchers - test 1.3 + test - joda-time - joda-time - 2.9 - - - org.apache.commons - commons-lang3 - 3.4 - - - - com.google.apis - google-api-services-monitoring - v3-rev1-1.21.0 + com.google.truth + truth + 0.28 + test diff --git a/monitoring/v3/src/test/java/CreateCustomMetricTest.java b/monitoring/v3/src/test/java/CreateCustomMetricTest.java index c18b34c492f..f4c2aae8fe9 100644 --- a/monitoring/v3/src/test/java/CreateCustomMetricTest.java +++ b/monitoring/v3/src/test/java/CreateCustomMetricTest.java @@ -1,12 +1,12 @@ -/** +/* * Copyright (c) 2015 Google Inc. - *

+ * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - *

+ * * http://www.apache.org/licenses/LICENSE-2.0 - *

+ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -14,10 +14,14 @@ * the License. */ +import static com.google.common.truth.Truth.assertThat; + import com.google.api.services.monitoring.v3.Monitoring; import com.google.api.services.monitoring.v3.model.Point; +import com.google.common.collect.ImmutableList; + import org.apache.commons.lang3.RandomStringUtils; -import org.junit.Assert; + import org.junit.Before; import org.junit.Test; @@ -49,8 +53,6 @@ public int nextInt(int bound) { /** * Creates the monitoring service client. - * - * @throws Exception */ @Before public void setUp() throws Exception { @@ -62,8 +64,6 @@ public void setUp() throws Exception { /** * Tests that the value written for a custom metric can be read back correctly. - * - * @throws Exception */ @Test public void testValueRead() throws Exception { @@ -75,17 +75,14 @@ public void testValueRead() throws Exception { underTest.writeCustomMetricTimeseriesValue(); // give time for write to register Thread.sleep(2000); - List response = underTest.readTimeseriesValue() - .getTimeSeries().get(0).getPoints(); + List response = + underTest.readTimeseriesValue().getTimeSeries().get(0).getPoints(); - boolean found = false; + ImmutableList.Builder timeSeries = ImmutableList.builder(); for (Point p : response) { - System.out.println("found a response " + p.getValue().getInt64Value()); - if (p.getValue().getInt64Value() == 0) { - found = true; - } + timeSeries.add(p.getValue().getInt64Value()); } - Assert.assertTrue(found); + assertThat(timeSeries.build()).contains(0L); } } diff --git a/monitoring/v3/src/test/java/ListResourcesTest.java b/monitoring/v3/src/test/java/ListResourcesTest.java index f31b12eb04b..234ee858a54 100644 --- a/monitoring/v3/src/test/java/ListResourcesTest.java +++ b/monitoring/v3/src/test/java/ListResourcesTest.java @@ -1,12 +1,12 @@ -/** +/* * Copyright (c) 2015 Google Inc. - *

+ * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - *

+ * * http://www.apache.org/licenses/LICENSE-2.0 - *

+ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -14,9 +14,10 @@ * the License. */ +import static com.google.common.truth.Truth.assertThat; import com.google.api.services.monitoring.v3.Monitoring; -import junit.framework.Assert; + import org.junit.Before; import org.junit.Test; @@ -34,7 +35,7 @@ public class ListResourcesTest { /** * The project ID of the project created for the integration tests. */ - public static final String TEST_PROJECT_ID = "cloud-monitoring-dev"; + public static final String TEST_PROJECT_ID = "cloud-samples-tests"; /** * Google Cloud Monitoring client to integration test. @@ -63,7 +64,9 @@ public void setUp() throws Exception { public void testListMonitoredResourceDescriptors() throws Exception { this.underTest.listMonitoredResourceDescriptors(); String result = new String(os.toByteArray()); - Assert.assertTrue(result.contains("An application running in Google App Engine")); + assertThat(result) + .named("output text stream") + .contains("An application running in Google App Engine"); } /** @@ -74,7 +77,9 @@ public void testListMonitoredResourceDescriptors() throws Exception { public void testListMetrics() throws Exception { this.underTest.listMetricDescriptors(); String result = new String(os.toByteArray()); - Assert.assertTrue(result.contains("Delta CPU usage time. Units are second")); + assertThat(result) + .named("output text stream") + .contains("Delta CPU usage time. Units are second"); } /** @@ -85,7 +90,8 @@ public void testListMetrics() throws Exception { public void testListTimeseries() throws Exception { this.underTest.listTimeseries(); String result = new String(os.toByteArray()); - Assert.assertTrue(result.contains("listTimeseries response")); + assertThat(result) + .named("output text stream") + .contains("listTimeseries response"); } - } diff --git a/pom.xml b/pom.xml index 9bc94b812dd..2ffd5b6b4ff 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,8 @@ true true true + true + suppressions.xml check diff --git a/suppressions.xml b/suppressions.xml new file mode 100644 index 00000000000..22a348c205e --- /dev/null +++ b/suppressions.xml @@ -0,0 +1,27 @@ + + + + + + + + + + +