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

vision: update product search tests #2378

Merged
merged 2 commits into from
Mar 11, 2020
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
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