Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkstyle fixes for Cloud Monitoring sample tests. #110

Merged
merged 1 commit into from
Mar 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Checkstyle fixes for Cloud Monitoring sample tests.
Changed to using Truth for assertions.
tswast committed Mar 15, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 5bc4cbf36d44ea29c85e2525b1febbb86b5288b0
6 changes: 6 additions & 0 deletions monitoring/pom.xml
Original file line number Diff line number Diff line change
@@ -49,6 +49,12 @@
<groupId>com.jcabi</groupId>
<artifactId>jcabi-matchers</artifactId>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>0.28</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
18 changes: 10 additions & 8 deletions monitoring/src/test/java/CloudMonitoringAuthSampleTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,16 +14,14 @@
* limitations under the License.
*/

import static com.jcabi.matchers.RegexMatchers.*;
import static org.junit.Assert.*;
import static com.google.common.truth.Truth.assertThat;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.regex.Pattern;

/**
* Tests the Cloud Monitoring auth sample.
@@ -51,15 +49,19 @@ public void tearDown() {
@Test
public void testUsage() throws Exception {
CloudMonitoringAuthSample.main(new String[] { });
assertEquals("Usage: CloudMonitoringAuthSample <project-name>\n", stderr.toString());
assertThat(stderr.toString())
.named("stderr")
.isEqualTo("Usage: CloudMonitoringAuthSample <project-name>\n");
}

@Test
public void testListTimeSeries() throws Exception {
CloudMonitoringAuthSample.main(new String[] { "cloud-samples-tests" });
String out = stdout.toString();
assertThat(out, containsPattern("Timeseries.list raw response:"));
assertThat(out, containsPattern("\\{\\s*\"kind\" *: *\"cloudmonitoring#listTimeseriesResponse\","));
assertThat(out, containsPattern(".*oldest.*"));
assertThat(out).named("stdout").contains("Timeseries.list raw response:");
assertThat(out)
.named("stdout")
.containsMatch("\\{\\s*\"kind\" *: *\"cloudmonitoring#listTimeseriesResponse\",");
assertThat(out).named("stdout").containsMatch(".*oldest.*");
}
}