Skip to content

Commit

Permalink
test: remove extra println causing NPE in test (#495)
Browse files Browse the repository at this point in the history
* fix: remove extra println causing NPE in test

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* test: add delays to prevent quota issue

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* test: update import in DetectIntentIT

* test: tests declare they throw InterruptedException

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
kweinmeister and gcf-owl-bot[bot] authored Jul 1, 2022
1 parent a1bf0c3 commit 30e5286
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ public void setUp() throws IOException {
}

@After
public void tearDown() throws IOException {
public void tearDown() throws IOException, InterruptedException {
System.setOut(originalOut);
String apiEndpoint = "global-dialogflow.googleapis.com:443";

AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(apiEndpoint).build();
AgentsClient client = AgentsClient.create(agentsSettings);

client.deleteAgent(CreateAgentIT.agentPath);

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public static void tearDown() throws Exception {
try (FlowsClient flowsClient = FlowsClient.create(flowsSettings)) {
flowsClient.deleteFlow(newFlowNameRegional);
}

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public static void tearDown() throws Exception {
intentsClient.deleteIntent(newIntentNameRegional);
}
}

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
Expand All @@ -93,7 +96,6 @@ public void testCreateIntentRegional() throws Exception {
CreateIntent.createIntent(
DISPLAY_NAME, PROJECT_ID, LOCATION_REGIONAL, AGENT_ID_REGIONAL, TRAINING_PHRASES_PARTS);
newIntentNameRegional = result.getName();
System.out.println("intent name new:" + newIntentNameRegional);

assertEquals(result.getTrainingPhrasesCount(), TRAINING_PHRASES_PARTS.size());
for (TrainingPhrase trainingPhrase : result.getTrainingPhrasesList()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public static void tearDown() throws Exception {
try (PagesClient pagesClient = PagesClient.create()) {
pagesClient.deletePage(newPageNameGlobal);
}

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

// Delete the newly created Page in the regional location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -45,6 +46,12 @@ public class DetectIntentIT {
private static String LANGUAGE_CODE = "en-US";
private static List<String> TEXTS = Arrays.asList("hello", "book a meeting room");

@After
public void tearDown() throws InterruptedException {
// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
public void testDetectIntentGlobal() throws Exception {
Map<String, QueryResult> queryResults =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ public void setUp() {
}

@After
public void tearDown() {
public void tearDown() throws InterruptedException {
System.setOut(original);
bout.reset();

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void setUp() throws IOException {
}

@After
public void tearDown() throws IOException {
public void tearDown() throws IOException, InterruptedException {
stdOut = null;
System.setOut(null);
String apiEndpoint = "global-dialogflow.googleapis.com:443";
Expand All @@ -81,6 +81,9 @@ public void tearDown() throws IOException {

client.deleteAgent(ExportAgentIT.agentPath);
client.close();

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ public void setUp() throws IOException {
}

@After
public void tearDown() throws IOException {
public void tearDown() throws IOException, InterruptedException {
System.setOut(originalOut);

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ public void setUp() throws IOException {
}

@After
public void tearDown() throws IOException {
public void tearDown() throws IOException, InterruptedException {
stdOut = null;
System.setOut(null);

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ public static void setUp() throws IOException {
}

@AfterClass
public static void tearDown() throws IOException {
public static void tearDown() throws IOException, InterruptedException {
String apiEndpoint = "global-dialogflow.googleapis.com:443";
String parentPath = "projects/" + PROJECT_ID + "/locations/global";

AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(apiEndpoint).build();
AgentsClient client = AgentsClient.create(agentsSettings);

client.deleteAgent(parent);

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void setUp() throws IOException {
}

@After
public void tearDown() throws IOException {
public void tearDown() throws IOException, InterruptedException {
stdOut = null;
System.setOut(null);
String apiEndpoint = "global-dialogflow.googleapis.com:443";
Expand All @@ -84,6 +84,9 @@ public void tearDown() throws IOException {
AgentsClient client = AgentsClient.create(agentsSettings);

client.deleteAgent(parent);

// Small delay to prevent reaching quota limit of requests per minute
Thread.sleep(250);
}

@Test
Expand Down

0 comments on commit 30e5286

Please sign in to comment.