Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions monitoring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
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");
Expand All @@ -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.
Expand Down Expand Up @@ -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.*");
}
}