Skip to content

Commit

Permalink
samples: vision: update product search tests (#2378)
Browse files Browse the repository at this point in the history
* vision: update product search tests

* update other broken tests
  • Loading branch information
nnegrey authored and chingor13 committed Aug 13, 2020
1 parent a61d4d4 commit 80283cb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import static com.google.common.truth.Truth.assertThat;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.UUID;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -33,52 +34,36 @@
public class ProductSetManagementIT {
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String COMPUTE_REGION = "us-west1";
private static final String PRODUCT_SET_ID = "fake_prodt_set_id_for_testing";
private static final String PRODUCT_SET_ID =
String.format("test_%s", UUID.randomUUID().toString());
private static final String PRODUCT_SET_DISPLAY_NAME =
"fake_prodt_set_display_name_for_testing";
String.format("test_%s", UUID.randomUUID().toString());
private ByteArrayOutputStream bout;
private PrintStream out;

@Before
public void setUp() throws IOException {
public void setUp() {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
System.setOut(out);
}

@After
public void tearDown() {

System.setOut(null);
}

@Test
public void testCreateDeleteProductSet() throws Exception {
// Act
ProductSetManagement.listProductSets(PROJECT_ID, COMPUTE_REGION);

// Assert
String got = bout.toString();
assertThat(got).doesNotContain(PRODUCT_SET_ID);

bout.reset();

// Act
ProductSetManagement.createProductSet(
PROJECT_ID, COMPUTE_REGION, PRODUCT_SET_ID, PRODUCT_SET_DISPLAY_NAME);
ProductSetManagement.listProductSets(PROJECT_ID, COMPUTE_REGION);

// Assert
got = bout.toString();
PROJECT_ID, COMPUTE_REGION, PRODUCT_SET_ID, PRODUCT_SET_DISPLAY_NAME);
String got = bout.toString();
assertThat(got).contains(PRODUCT_SET_ID);

bout.reset();

// Act
ProductSetManagement.deleteProductSet(PROJECT_ID, COMPUTE_REGION, PRODUCT_SET_ID);
ProductSetManagement.listProductSets(PROJECT_ID, COMPUTE_REGION);

// Assert
got = bout.toString();
assertThat(got).doesNotContain(PRODUCT_SET_ID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public class ProductInProductSetManagementTests {
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String COMPUTE_REGION = "us-west1";
private static final String PRODUCT_SET_DISPLAY_NAME =
"fake_pdt_set_display_name_for_testing";
private static final String PRODUCT_SET_ID = "fake_pdt_set_id_for_testing" + UUID.randomUUID();
private static final String PRODUCT_DISPLAY_NAME = "fake_pdt_display_name_for_testing";
String.format("test_%s", UUID.randomUUID().toString());
private static final String PRODUCT_SET_ID =
String.format("test_%s", UUID.randomUUID().toString());
private static final String PRODUCT_DISPLAY_NAME =
String.format("test_%s", UUID.randomUUID().toString());
private static final String PRODUCT_CATEGORY = "apparel";
private static final String PRODUCT_ID = "fake_pdt_id_for_testing";
private static final String PRODUCT_ID = String.format("test_%s", UUID.randomUUID().toString());
private ByteArrayOutputStream bout;
private PrintStream out;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.UUID;

import org.junit.After;
import org.junit.Before;
Expand All @@ -35,9 +36,10 @@ public class ProductManagementTests {

private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String COMPUTE_REGION = "us-west1";
private static final String PRODUCT_DISPLAY_NAME = "fake_prod_display_name_for_testing";
private static final String PRODUCT_DISPLAY_NAME =
String.format("test_%s", UUID.randomUUID().toString());
private static final String PRODUCT_CATEGORY = "homegoods";
private static final String PRODUCT_ID = "fake_prod_id_for_testing";
private static final String PRODUCT_ID = String.format("test_%s", UUID.randomUUID().toString());
private ByteArrayOutputStream bout;
private PrintStream out;

Expand Down

0 comments on commit 80283cb

Please sign in to comment.